aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDave Young <hidave.darkstar@gmail.com>2008-01-22 01:01:34 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:45 -0500
commit9c7701088a61cc0cf8a6e1c68d1e74e3cc2ee0b7 (patch)
tree477def1de51833a3d8c1b9e4b080b52fd51d51ab /drivers
parent71da890509fec13d54329485bf5e4ac16b992bb6 (diff)
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 'drivers')
-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)
429} 429}
430EXPORT_SYMBOL(scsi_unregister); 430EXPORT_SYMBOL(scsi_unregister);
431 431
432static int __scsi_host_match(struct class_device *cdev, void *data)
433{
434 struct Scsi_Host *p;
435 unsigned short *hostnum = (unsigned short *)data;
436
437 p = class_to_shost(cdev);
438 return p->host_no == *hostnum;
439}
440
432/** 441/**
433 * scsi_host_lookup - get a reference to a Scsi_Host by host no 442 * scsi_host_lookup - get a reference to a Scsi_Host by host no
434 * 443 *
@@ -439,19 +448,12 @@ EXPORT_SYMBOL(scsi_unregister);
439 **/ 448 **/
440struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) 449struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
441{ 450{
442 struct class *class = &shost_class;
443 struct class_device *cdev; 451 struct class_device *cdev;
444 struct Scsi_Host *shost = ERR_PTR(-ENXIO), *p; 452 struct Scsi_Host *shost = ERR_PTR(-ENXIO);
445 453
446 down(&class->sem); 454 cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match);
447 list_for_each_entry(cdev, &class->children, node) { 455 if (cdev)
448 p = class_to_shost(cdev); 456 shost = scsi_host_get(class_to_shost(cdev));
449 if (p->host_no == hostnum) {
450 shost = scsi_host_get(p);
451 break;
452 }
453 }
454 up(&class->sem);
455 457
456 return shost; 458 return shost;
457} 459}