cleanup code for /proc add/remove single device
PATCH 1/1 cleanup code for /proc add/remove single device
two new helpers in scsi_scan.c: scsi_add_single_device and scsi_remove_single_device that do all hard work. Thanks to beeing in scsi_scan.c and using proper helpers they're a lot smaller and cleaner.
drivers/scsi/scsi.h +2 -0
@@ -525,6 +525,8 @@extern struct scsi_device *scsi_alloc_sdev (struct Scsi_Host *,uint ,uint ,uint );extern void scsi_free_sdev (struct scsi_device *); +extern int scsi_add_single_device (uint ,uint ,uint ,uint ); +extern int scsi_remove_single_device (uint ,uint ,uint ,uint );/* * Prototypes for functions in constants.c
===== drivers/scsi/scsi_proc.c 1.9 vs edited =====
drivers/scsi/scsi_proc.c +6 -67
98 lines not on this page · raw message
===== drivers/scsi/scsi_scan.c 1.38 vs edited =====
drivers/scsi/scsi_scan.c +63 -0
69 lines not on this page · raw message
Quoted 31 lines · Christoph Hellwig
two new helpers in
scsi_scan.c:scsi_add_single_deviceandscsi_remove_single_devicethat do all hard work. Thanks to beeing inscsi_scan.cand using proper helpers they're a lot smaller and cleaner.drivers/scsi/scsi.h +3
-9- - err = -ENOSYS ; -if (sdev) - goto out;/* We do not yet support unplugging */ - -scan_scsis (shost,1 , channel, id, lun); - err = length; - goto out; - } + err =scsi_add_single_device (host, channel, id, lun); +if (err >=0 ) + err = length;=====
drivers/scsi/scsi_scan.c1.38 vs edited =====drivers/scsi/scsi_scan.c +3
-0@@ -1862,6 +1862,69 @@ } +int scsi_add_single_device (uint host,uint channel,uint id,uint lun) +{ +struct scsi_device *sdevscan, *sdev;
drivers/scsi/scsi_scan.c line 1877
Quoted 10 lines
drivers/scsi/scsi_scan.c +10
-0+struct Scsi_Host *shost; +int error = -ENODEV ; + + shost =scsi_host_hn_get (host); +if (!shost) +return -ENODEV ; + sdev =scsi_find_device (shost, channel, id, lun); +if (!sdev) + goto out; +
James/Christoph -
I had to change the above to a "if (sdev)" per the following patch (against current scsi-misc-2.5) to get the add to work correctly. Otherwise, this worked fine.
drivers/scsi/scsi_scan.c +1 -1
@@ -1872,7 +1872,7 @@if (!shost)return -ENODEV ; sdev =scsi_find_device (shost, channel, id, lun); -if (!sdev) +if (sdev) goto out; error = -ENOMEM ;
-- Patrick Mansfield
Quoted 2 lines · Patrick Mansfield
current scsi-misc-2.5) to get the add to work correctly. Otherwise, this worked fine.
Duh! thanks for the fix. The other patch also looks okay, although I wonder why you need hardirq.h.
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Patrick Mansfield
current scsi-misc-2.5) to get the add to work correctly. Otherwise, this worked fine.
Duh! thanks for the fix. The other patch also looks okay, although I wonder why you need
hardirq.h.
For the in_atomic check in scsi_init_io.
-- Patrick Mansfield