summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hosts.c
diff options
context:
space:
mode:
authorDave Young <hidave.darkstar@gmail.com>2008-01-22 07:01:34 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-25 05:40:45 +0100
commit9c7701088a61cc0cf8a6e1c68d1e74e3cc2ee0b7 (patch)
tree477def1de51833a3d8c1b9e4b080b52fd51d51ab /drivers/scsi/hosts.c
parentrtc: use class iteration api (diff)
downloadlinux-9c7701088a61cc0cf8a6e1c68d1e74e3cc2ee0b7.tar.xz
linux-9c7701088a61cc0cf8a6e1c68d1e74e3cc2ee0b7.zip
scsi: use class iteration api
Convert to use the class iteration api. Signed-off-by: Dave Young <hidave.darkstar@gmail.com> Cc: James Bottomley <James.Bottomley@hansenpartnership.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to '')
-rw-r--r--drivers/scsi/hosts.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 24271a871b8c..6325115e5b3d 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -429,6 +429,15 @@ void scsi_unregister(struct Scsi_Host *shost)
}
EXPORT_SYMBOL(scsi_unregister);
+static int __scsi_host_match(struct class_device *cdev, void *data)
+{
+ struct Scsi_Host *p;
+ unsigned short *hostnum = (unsigned short *)data;
+
+ p = class_to_shost(cdev);
+ return p->host_no == *hostnum;
+}
+
/**
* scsi_host_lookup - get a reference to a Scsi_Host by host no
*
@@ -439,19 +448,12 @@ EXPORT_SYMBOL(scsi_unregister);
**/
struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
{
- struct class *class = &shost_class;
struct class_device *cdev;
- struct Scsi_Host *shost = ERR_PTR(-ENXIO), *p;
+ struct Scsi_Host *shost = ERR_PTR(-ENXIO);
- down(&class->sem);
- list_for_each_entry(cdev, &class->children, node) {
- p = class_to_shost(cdev);
- if (p->host_no == hostnum) {
- shost = scsi_host_get(p);
- break;
- }
- }
- up(&class->sem);
+ cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match);
+ if (cdev)
+ shost = scsi_host_get(class_to_shost(cdev));
return shost;
}