From: Bart Van Assche <bart.vanassche@sandisk.com>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
Israel Rukshin <israelr@mellanox.com>,
Max Gurtovoy <maxg@mellanox.com>,
Bart Van Assche <bart.vanassche@sandisk.com>,
stable@vger.kernel.org
Subject: [PATCH 1/3] __scsi_iterate_devices(): Make the get and put functions arguments
Date: Thu, 16 Mar 2017 13:56:48 -0700 [thread overview]
Message-ID: <20170316205650.3322-2-bart.vanassche@sandisk.com> (raw)
In-Reply-To: <20170316205650.3322-1-bart.vanassche@sandisk.com>
This patch does not change any functionality.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Tested-by: Israel Rukshin <israelr@mellanox.com>
Cc: Max Gurtovoy <maxg@mellanox.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: <stable@vger.kernel.org>
---
drivers/scsi/scsi.c | 8 +++++---
include/scsi/scsi_device.h | 11 ++++++-----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 7bfbcfa7af40..5ac16fecbdab 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -609,7 +609,9 @@ EXPORT_SYMBOL(scsi_device_put);
/* helper for shost_for_each_device, see that for documentation */
struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *shost,
- struct scsi_device *prev)
+ struct scsi_device *prev,
+ int (*get)(struct scsi_device *),
+ void (*put)(struct scsi_device *))
{
struct list_head *list = (prev ? &prev->siblings : &shost->__devices);
struct scsi_device *next = NULL;
@@ -619,7 +621,7 @@ struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *shost,
while (list->next != &shost->__devices) {
next = list_entry(list->next, struct scsi_device, siblings);
/* skip devices that we can't get a reference to */
- if (!scsi_device_get(next))
+ if (!get(next))
break;
next = NULL;
list = list->next;
@@ -627,7 +629,7 @@ struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *shost,
spin_unlock_irqrestore(shost->host_lock, flags);
if (prev)
- scsi_device_put(prev);
+ put(prev);
return next;
}
EXPORT_SYMBOL(__scsi_iterate_devices);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 080c7ce9bae8..434b617c9f76 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -334,7 +334,9 @@ extern void __starget_for_each_device(struct scsi_target *, void *,
/* only exposed to implement shost_for_each_device */
extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
- struct scsi_device *);
+ struct scsi_device *,
+ int (*get)(struct scsi_device *),
+ void (*put)(struct scsi_device *));
/**
* shost_for_each_device - iterate over all devices of a host
@@ -345,10 +347,9 @@ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
* takes a reference on each device and releases it at the end. If
* you break out of the loop, you must call scsi_device_put(sdev).
*/
-#define shost_for_each_device(sdev, shost) \
- for ((sdev) = __scsi_iterate_devices((shost), NULL); \
- (sdev); \
- (sdev) = __scsi_iterate_devices((shost), (sdev)))
+#define shost_for_each_device(sdev, shost) \
+ for ((sdev) = NULL; ((sdev) = __scsi_iterate_devices((shost), (sdev), \
+ scsi_device_get, scsi_device_put)) != NULL; )
/**
* __shost_for_each_device - iterate over all devices of a host (UNLOCKED)
--
2.12.0
next prev parent reply other threads:[~2017-03-16 20:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-16 20:56 [PATCH 0/3] Unblock SCSI devices even if the LLD is being unloaded Bart Van Assche
2017-03-16 20:56 ` Bart Van Assche [this message]
2017-03-16 20:56 ` [PATCH 2/3] Introduce starget_for_all_devices() and shost_for_all_devices() Bart Van Assche
2017-03-18 17:14 ` kbuild test robot
2017-03-16 20:56 ` [PATCH 3/3] Ensure that scsi_target_unblock() examines all devices Bart Van Assche
2017-03-18 20:22 ` kbuild test robot
2017-03-16 22:53 ` [PATCH 0/3] Unblock SCSI devices even if the LLD is being unloaded James Bottomley
2017-03-16 23:19 ` Bart Van Assche
2017-03-17 12:54 ` James Bottomley
2017-03-17 16:40 ` Bart Van Assche
2017-03-18 12:44 ` James Bottomley
2017-03-18 20:49 ` Bart Van Assche
2017-04-10 17:46 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170316205650.3322-2-bart.vanassche@sandisk.com \
--to=bart.vanassche@sandisk.com \
--cc=hare@suse.de \
--cc=israelr@mellanox.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=maxg@mellanox.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox