Patches to clean up SCSI code
cover Patches to clean up SCSI code
From: "Ewan D. Milne" <[email protected]>
This is a set of 5 patches to clean up the SCSI code. They consist of various things found during development and review of some changes for Unit Attention handling (which was submitted as a separate patch).
Ewan D. Milne (5):
scsi: Fix incorrect function name in comment
scsi: Correct size of envp[]
scsi: Add missing newline to scsi_sysfs.c
scsi: Change to use list_for_each_entry_safe
scsi: Rename scsi_evt_thread() to scsi_evt_work()
drivers/scsi/scsi_lib.c | 8 ++++---- drivers/scsi/scsi_priv.h | 1 + drivers/scsi/scsi_scan.c | 3 +-- drivers/scsi/scsi_sysfs.c | 10 ++++------ 4 files changed, 10 insertions(+), 12 deletions(-)
Signature · 1 line
1.7.11.7
PATCH 1/5 scsi: Fix incorrect function name in comment
From: "Ewan D. Milne" <[email protected]>
The function name is "scsi_evt_emit", not "sdev_evt_emit".
--- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
@@ -2171,7 +2171,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)EXPORT_SYMBOL (scsi_device_set_state);/** -* sdev_evt_emit - emit a single SCSI device uevent +* scsi_evt_emit - emit a single SCSI device uevent * @sdev: associated SCSI device * @evt: event to emit *
Signature · 1 line
1.7.11.7
PATCH 2/5 scsi: Correct size of envp[]
In reply to Ewan D. MilneFrom: "Ewan D. Milne" <[email protected]>
The envp[] array in scsi_evt_emit() only needs to have 2 entries.
--- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
@@ -2180,7 +2180,7 @@ EXPORT_SYMBOL(scsi_device_set_state);static void scsi_evt_emit (struct scsi_device *sdev,struct scsi_event *evt) {int idx =0 ; -char *envp[3 ]; +char *envp[2 ];switch (evt->evt_type) {case SDEV_EVT_MEDIA_CHANGE :
Signature · 1 line
1.7.11.7
PATCH 3/5 scsi: Add missing newline to scsi_sysfs.c
In reply to Ewan D. MilneFrom: "Ewan D. Milne" <[email protected]>
show_iostat_counterbits() is obviously missing a newline in the function declaration.
--- drivers/scsi/scsi_sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/scsi_sysfs.c +2 -1
@@ -647,7 +647,8 @@ show_queue_type_field(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL);static ssize_t -show_iostat_counterbits (struct device *dev,struct device_attribute *attr,char *buf) +show_iostat_counterbits (struct device *dev,struct device_attribute *attr, +char *buf) {return snprintf (buf,20 ,"%d\n" , (int )sizeof (atomic_t) *8 ); }
Signature · 1 line
1.7.11.7
PATCH 4/5 scsi: Change to use list_for_each_entry_safe
In reply to Ewan D. MilneFrom: "Ewan D. Milne" <[email protected]>
scsi_device_dev_release_usercontext() should be using "list_for_each_entry_safe" instead of "list_for_each_safe".
--- drivers/scsi/scsi_sysfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/scsi/scsi_sysfs.c +2 -5
@@ -335,7 +335,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)struct scsi_device *sdev;struct device *parent;struct scsi_target *starget; -struct list_head *this, *tmp; +struct scsi_event *evt, *next;unsigned long flags; sdev = container_of(work, struct scsi_device, ew.work);
@@ -352,10 +352,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)cancel_work_sync (&sdev->event_work); -list_for_each_safe (this, tmp, &sdev->event_list) { -struct scsi_event *evt; - - evt = list_entry(this, struct scsi_event, node); +list_for_each_entry_safe (evt, next, &sdev->event_list, node) {list_del (&evt->node);kfree (evt); }
Signature · 1 line
1.7.11.7
PATCH 5/5 scsi: Rename scsi_evt_thread() to scsi_evt_work()
In reply to Ewan D. MilneFrom: "Ewan D. Milne" <[email protected]>
The scsi_evt_thread() function is not actually a thread, it is a work function. So it should be named scsi_evt_work() instead.
--- drivers/scsi/scsi_lib.c | 4 ++-- drivers/scsi/scsi_priv.h | 1 + drivers/scsi/scsi_scan.c | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/scsi_lib.c +2 -2
@@ -2198,13 +2198,13 @@ static void scsi_evt_emit(struct scsi_device *sdev, struct scsi_event *evt) }/** -* sdev_evt_thread - send a uevent for each scsi event +* scsi_evt_work - send a uevent for each scsi event * @work: work struct for scsi_device * * Dispatch queued events to their associated scsi_device kobjects * as uevents. */ -void scsi_evt_thread (struct work_struct *work) +void scsi_evt_work (struct work_struct *work) {struct scsi_device *sdev;LIST_HEAD (event_list);
drivers/scsi/scsi_priv.h +1 -0
@@ -90,6 +90,7 @@ extern void scsi_exit_queue(void);struct request_queue ;struct request ;extern struct kmem_cache *scsi_sdb_cache; +extern void scsi_evt_work (struct work_struct *work);/* scsi_proc.c */ #ifdef CONFIG_SCSI_PROC_FS
drivers/scsi/scsi_scan.c +1 -2
@@ -244,7 +244,6 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,struct scsi_device *sdev;int display_failure_msg =1 , ret;struct Scsi_Host *shost =dev_to_shost (starget->dev.parent); -extern void scsi_evt_thread (struct work_struct *work);extern void scsi_requeue_run_queue (struct work_struct *work); sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
@@ -267,7 +266,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,INIT_LIST_HEAD (&sdev->starved_entry);INIT_LIST_HEAD (&sdev->event_list);spin_lock_init (&sdev->list_lock); -INIT_WORK (&sdev->event_work, scsi_evt_thread); +INIT_WORK (&sdev->event_work, scsi_evt_work);INIT_WORK (&sdev->requeue_work, scsi_requeue_run_queue); sdev->sdev_gendev.parent =get_device (&starget->dev);
Signature · 1 line
1.7.11.7