/* Dispatch queued events to their associated scsi_device kobjects as uevents.  */
void scsi_evt_thread(struct work_struct *work)
/* Dispatch queued events to their associated scsi_device kobjects as uevents.  */
void scsi_evt_thread(struct work_struct *work)
{
	struct scsi_device *sdev;
	LIST_HEAD(event_list);
	sdev = container_of(work, struct scsi_device, event_work);
	while (1) {
		struct scsi_event *evt;
		struct list_head *this, *tmp;
		unsigned long flags;
		spin_lock_irqsave(&sdev->list_lock, flags);
		list_splice_init(&sdev->event_list, &event_list);
		spin_unlock_irqrestore(&sdev->list_lock, flags);
		if (list_empty(&event_list))
			break;
		list_for_each_safe(this, tmp, &event_list) {
			evt = list_entry(this, struct scsi_event, node);
			list_del(&evt->node);
			scsi_evt_emit(sdev, evt);
			kfree(evt);
		}
	}
}