]> err.no Git - linux-2.6/commitdiff
[SCSI] Alter the scsi_add_device() API to conform to what users expect
authorJames Bottomley <James.Bottomley@steeleye.com>
Sat, 10 Sep 2005 17:44:09 +0000 (12:44 -0500)
committerJames Bottomley <jejb@mulgrave.(none)>
Sat, 10 Sep 2005 19:43:25 +0000 (14:43 -0500)
The original API returned either an ERR_PTR() or a refcounted sdev.
Unfortunately, if it's successful, you need to do a scsi_device_put() on
the sdev otherwise the refcounting is wrong.

Everyone seems to expect that scsi_add_device() should be callable
without doing the ref put, so alter the API so it is (we still have
__scsi_add_device with the original behaviour).

The only actual caller that needs altering is the one in firewire ...
not because it gets this right, but because it acts on the error if one
is returned.

Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/ieee1394/sbp2.c
drivers/scsi/scsi_scan.c
include/scsi/scsi_device.h

index 627af507643a00453a2d97cf51257ebf405cd4c3..de88218ef7cce8c8eb4912aedb4bdffbd64f7561 100644 (file)
@@ -790,7 +790,7 @@ static void sbp2_host_reset(struct hpsb_host *host)
 static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
 {
        struct sbp2scsi_host_info *hi = scsi_id->hi;
-       struct scsi_device *sdev;
+       int error;
 
        SBP2_DEBUG("sbp2_start_device");
 
@@ -939,10 +939,10 @@ alloc_fail:
        sbp2_max_speed_and_size(scsi_id);
 
        /* Add this device to the scsi layer now */
-       sdev = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0);
-       if (IS_ERR(sdev)) {
+       error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0);
+       if (error) {
                SBP2_ERR("scsi_add_device failed");
-               return PTR_ERR(sdev);
+               return error;
        }
 
        return 0;
index a0975c78b968de2fab8777fefc67bd3232a9a052..b86f170fa8ed5a4dafbbd65bb1b3293ea9de21e8 100644 (file)
@@ -1264,6 +1264,19 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
 }
 EXPORT_SYMBOL(__scsi_add_device);
 
+int scsi_add_device(struct Scsi_Host *host, uint channel,
+                   uint target, uint lun)
+{
+       struct scsi_device *sdev = 
+               __scsi_add_device(host, channel, target, lun, NULL);
+       if (IS_ERR(sdev))
+               return PTR_ERR(sdev);
+
+       scsi_device_put(sdev);
+       return 0;
+}
+EXPORT_SYMBOL(scsi_add_device);
+
 void scsi_rescan_device(struct device *dev)
 {
        struct scsi_driver *drv;
index da63722c0123b8e77feadd5cd6ee118c757c153e..c0e4c67d836fa66e4f72f520e33e50f7526e597d 100644 (file)
@@ -178,8 +178,8 @@ static inline struct scsi_target *scsi_target(struct scsi_device *sdev)
 
 extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
                uint, uint, uint, void *hostdata);
-#define scsi_add_device(host, channel, target, lun) \
-       __scsi_add_device(host, channel, target, lun, NULL)
+extern int scsi_add_device(struct Scsi_Host *host, uint channel,
+                          uint target, uint lun);
 extern void scsi_remove_device(struct scsi_device *);
 extern int scsi_device_cancel(struct scsi_device *, int);