diff mbox series

[08/13] scsi: add scsi_host_(block,unblock) helper function

Message ID 20200213140422.128382-9-hare@suse.de (mailing list archive)
State Superseded
Headers show
Series scsi: remove legacy cmd_list implementation | expand

Commit Message

Hannes Reinecke Feb. 13, 2020, 2:04 p.m. UTC
Add helper functions to call scsi_internal_device_block()/
scsi_internal_device_unblock() for all attached devices on a
scsi host.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/scsi_lib.c  | 30 ++++++++++++++++++++++++++++++
 include/scsi/scsi_host.h |  2 ++
 2 files changed, 32 insertions(+)

Comments

Bart Van Assche Feb. 20, 2020, 4:53 a.m. UTC | #1
On 2020-02-13 06:04, Hannes Reinecke wrote:
> Add helper functions to call scsi_internal_device_block()/
> scsi_internal_device_unblock() for all attached devices on a
> scsi host.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Christoph Hellwig Feb. 26, 2020, 5:42 p.m. UTC | #2
On Thu, Feb 13, 2020 at 03:04:17PM +0100, Hannes Reinecke wrote:

> +extern int scsi_host_block(struct Scsi_Host *shost);
> +extern int scsi_host_unblock(struct Scsi_Host *shost, int new_state);

No need for the externs here.  Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 610ee41fa54c..a48a5727831b 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2845,6 +2845,36 @@  scsi_target_unblock(struct device *dev, enum scsi_device_state new_state)
 }
 EXPORT_SYMBOL_GPL(scsi_target_unblock);
 
+int
+scsi_host_block(struct Scsi_Host *shost)
+{
+	struct scsi_device *sdev;
+	int ret = 0;
+
+	shost_for_each_device(sdev, shost) {
+		ret = scsi_internal_device_block(sdev);
+		if (ret)
+			break;
+	}
+	return ret;
+}
+EXPORT_SYMBOL_GPL(scsi_host_block);
+
+int
+scsi_host_unblock(struct Scsi_Host *shost, int new_state)
+{
+	struct scsi_device *sdev;
+	int ret = 0;
+
+	shost_for_each_device(sdev, shost) {
+		ret = scsi_internal_device_unblock(sdev, new_state);
+		if (ret)
+			break;
+	}
+	return ret;
+}
+EXPORT_SYMBOL_GPL(scsi_host_unblock);
+
 /**
  * scsi_kmap_atomic_sg - find and atomically map an sg-elemnt
  * @sgl:	scatter-gather list
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index d11a0a030dd3..a230e2c0e11f 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -757,6 +757,8 @@  static inline int scsi_host_scan_allowed(struct Scsi_Host *shost)
 
 extern void scsi_unblock_requests(struct Scsi_Host *);
 extern void scsi_block_requests(struct Scsi_Host *);
+extern int scsi_host_block(struct Scsi_Host *shost);
+extern int scsi_host_unblock(struct Scsi_Host *shost, int new_state);
 
 struct class_container;