[PATCH 2/4] Change the return type of scsi_target_block() from 'void' into 'int'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since scsi_target_block() can fail, return a value that indicates whether
or not this function succeeded.

Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Hannes Reinecke <hare@xxxxxxxx>
Cc: Johannes Thumshirn <jthumshirn@xxxxxxx>
Cc: Ming Lei <ming.lei@xxxxxxxxxx>
Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
---
 drivers/scsi/scsi_lib.c    | 24 +++++++++++++++++-------
 include/scsi/scsi_device.h |  2 +-
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 497cd4799e0a..bbed72eff9c9 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2741,26 +2741,36 @@ static int scsi_internal_device_unblock(struct scsi_device *sdev,
 static void
 device_block(struct scsi_device *sdev, void *data)
 {
-	scsi_internal_device_block(sdev);
+	int ret, *retp = data;
+
+	ret = scsi_internal_device_block(sdev);
+	if (*retp == 0 && ret != 0)
+		*retp = ret;
 }
 
 static int
 target_block(struct device *dev, void *data)
 {
+	int *retp = data;
+
 	if (scsi_is_target_device(dev))
-		starget_for_each_device(to_scsi_target(dev), NULL,
+		starget_for_each_device(to_scsi_target(dev), data,
 					device_block);
-	return 0;
+
+	return *retp;
 }
 
-void
-scsi_target_block(struct device *dev)
+int scsi_target_block(struct device *dev)
 {
+	int ret = 0;
+
 	if (scsi_is_target_device(dev))
-		starget_for_each_device(to_scsi_target(dev), NULL,
+		starget_for_each_device(to_scsi_target(dev), &ret,
 					device_block);
 	else
-		device_for_each_child(dev, NULL, target_block);
+		device_for_each_child(dev, &ret, target_block);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(scsi_target_block);
 
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 202f4d6a4342..e5d24abd292d 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -421,7 +421,7 @@ extern void scsi_scan_target(struct device *parent, unsigned int channel,
 			     unsigned int id, u64 lun,
 			     enum scsi_scan_mode rescan);
 extern void scsi_target_reap(struct scsi_target *);
-extern void scsi_target_block(struct device *);
+extern int scsi_target_block(struct device *);
 extern void scsi_target_unblock(struct device *, enum scsi_device_state);
 extern void scsi_remove_target(struct device *);
 extern const char *scsi_device_state_name(enum scsi_device_state);
-- 
2.22.0.709.g102302147b-goog




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux