]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/hosts.c
Driver Core: add ability for class_find_device to start in middle of list
[linux-2.6-omap-h63xx.git] / drivers / scsi / hosts.c
index 3690360d7a798ec98f73e58bb83880fe01e99de3..78dad28b70d5e346a4365ed7b05fca5a20d78a9a 100644 (file)
@@ -290,7 +290,7 @@ static void scsi_host_dev_release(struct device *dev)
        kfree(shost);
 }
 
-struct device_type scsi_host_type = {
+static struct device_type scsi_host_type = {
        .name =         "scsi_host",
        .release =      scsi_host_dev_release,
 };
@@ -456,16 +456,22 @@ static int __scsi_host_match(struct device *dev, void *data)
  *
  * Return value:
  *     A pointer to located Scsi_Host or NULL.
+ *
+ *     The caller must do a scsi_host_put() to drop the reference
+ *     that scsi_host_get() took. The put_device() below dropped
+ *     the reference from class_find_device().
  **/
 struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
 {
        struct device *cdev;
        struct Scsi_Host *shost = ERR_PTR(-ENXIO);
 
-       cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match);
-       if (cdev)
+       cdev = class_find_device(&shost_class, NULL, &hostnum,
+                                __scsi_host_match);
+       if (cdev) {
                shost = scsi_host_get(class_to_shost(cdev));
-
+               put_device(cdev);
+       }
        return shost;
 }
 EXPORT_SYMBOL(scsi_host_lookup);