Merge branch 'linux-linaro-lsk-v4.4-android' of git://git.linaro.org/kernel/linux...
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / scsi_sysfs.c
index c8115b4fe474474a29816ad677030749cc46343b..7232d43e2207d36c0b8368c7c880352e82abe60e 100644 (file)
@@ -1058,11 +1058,12 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
        }
 
        error = scsi_dh_add_device(sdev);
-       if (error) {
+       if (error)
+               /*
+                * device_handler is optional, so any error can be ignored
+                */
                sdev_printk(KERN_INFO, sdev,
                                "failed to add device handler: %d\n", error);
-               return error;
-       }
 
        device_enable_async_suspend(&sdev->sdev_dev);
        error = device_add(&sdev->sdev_dev);
@@ -1192,18 +1193,18 @@ static void __scsi_remove_target(struct scsi_target *starget)
 void scsi_remove_target(struct device *dev)
 {
        struct Scsi_Host *shost = dev_to_shost(dev->parent);
-       struct scsi_target *starget, *last_target = NULL;
+       struct scsi_target *starget;
        unsigned long flags;
 
 restart:
        spin_lock_irqsave(shost->host_lock, flags);
        list_for_each_entry(starget, &shost->__targets, siblings) {
                if (starget->state == STARGET_DEL ||
-                   starget == last_target)
+                   starget->state == STARGET_REMOVE)
                        continue;
                if (starget->dev.parent == dev || &starget->dev == dev) {
                        kref_get(&starget->reap_ref);
-                       last_target = starget;
+                       starget->state = STARGET_REMOVE;
                        spin_unlock_irqrestore(shost->host_lock, flags);
                        __scsi_remove_target(starget);
                        scsi_target_reap(starget);