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>
This commit is contained in:
parent
71da890509
commit
9c7701088a
@ -429,6 +429,15 @@ void scsi_unregister(struct Scsi_Host *shost)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(scsi_unregister);
|
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
|
* 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 Scsi_Host *scsi_host_lookup(unsigned short hostnum)
|
||||||
{
|
{
|
||||||
struct class *class = &shost_class;
|
|
||||||
struct class_device *cdev;
|
struct class_device *cdev;
|
||||||
struct Scsi_Host *shost = ERR_PTR(-ENXIO), *p;
|
struct Scsi_Host *shost = ERR_PTR(-ENXIO);
|
||||||
|
|
||||||
down(&class->sem);
|
cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match);
|
||||||
list_for_each_entry(cdev, &class->children, node) {
|
if (cdev)
|
||||||
p = class_to_shost(cdev);
|
shost = scsi_host_get(class_to_shost(cdev));
|
||||||
if (p->host_no == hostnum) {
|
|
||||||
shost = scsi_host_get(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
up(&class->sem);
|
|
||||||
|
|
||||||
return shost;
|
return shost;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user