aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@steeleye.com>2005-09-10 13:44:09 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-09-10 15:43:25 -0400
commit146f7262ee0ec7fc6882f06e5fcb13883308073c (patch)
treeccaea3545313046dce9e012f8db5ef57236e0f90
parentb70d37bf61f278f9d9adf17c52af6b2d0ae7800c (diff)
[SCSI] Alter the scsi_add_device() API to conform to what users expect
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>
-rw-r--r--drivers/ieee1394/sbp2.c8
-rw-r--r--drivers/scsi/scsi_scan.c13
-rw-r--r--include/scsi/scsi_device.h4
3 files changed, 19 insertions, 6 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 627af507643..de88218ef7c 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -790,7 +790,7 @@ static void sbp2_host_reset(struct hpsb_host *host)
790static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) 790static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
791{ 791{
792 struct sbp2scsi_host_info *hi = scsi_id->hi; 792 struct sbp2scsi_host_info *hi = scsi_id->hi;
793 struct scsi_device *sdev; 793 int error;
794 794
795 SBP2_DEBUG("sbp2_start_device"); 795 SBP2_DEBUG("sbp2_start_device");
796 796
@@ -939,10 +939,10 @@ alloc_fail:
939 sbp2_max_speed_and_size(scsi_id); 939 sbp2_max_speed_and_size(scsi_id);
940 940
941 /* Add this device to the scsi layer now */ 941 /* Add this device to the scsi layer now */
942 sdev = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0); 942 error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0);
943 if (IS_ERR(sdev)) { 943 if (error) {
944 SBP2_ERR("scsi_add_device failed"); 944 SBP2_ERR("scsi_add_device failed");
945 return PTR_ERR(sdev); 945 return error;
946 } 946 }
947 947
948 return 0; 948 return 0;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index a0975c78b96..b86f170fa8e 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1264,6 +1264,19 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
1264} 1264}
1265EXPORT_SYMBOL(__scsi_add_device); 1265EXPORT_SYMBOL(__scsi_add_device);
1266 1266
1267int scsi_add_device(struct Scsi_Host *host, uint channel,
1268 uint target, uint lun)
1269{
1270 struct scsi_device *sdev =
1271 __scsi_add_device(host, channel, target, lun, NULL);
1272 if (IS_ERR(sdev))
1273 return PTR_ERR(sdev);
1274
1275 scsi_device_put(sdev);
1276 return 0;
1277}
1278EXPORT_SYMBOL(scsi_add_device);
1279
1267void scsi_rescan_device(struct device *dev) 1280void scsi_rescan_device(struct device *dev)
1268{ 1281{
1269 struct scsi_driver *drv; 1282 struct scsi_driver *drv;
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index da63722c012..c0e4c67d836 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -178,8 +178,8 @@ static inline struct scsi_target *scsi_target(struct scsi_device *sdev)
178 178
179extern struct scsi_device *__scsi_add_device(struct Scsi_Host *, 179extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
180 uint, uint, uint, void *hostdata); 180 uint, uint, uint, void *hostdata);
181#define scsi_add_device(host, channel, target, lun) \ 181extern int scsi_add_device(struct Scsi_Host *host, uint channel,
182 __scsi_add_device(host, channel, target, lun, NULL) 182 uint target, uint lun);
183extern void scsi_remove_device(struct scsi_device *); 183extern void scsi_remove_device(struct scsi_device *);
184extern int scsi_device_cancel(struct scsi_device *, int); 184extern int scsi_device_cancel(struct scsi_device *, int);
185 185