ufs: tune bkops while power managment events
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / scsi_sysfs.c
index 406b3038bbad919e560fc3eebcd64caa1fe55a8c..f4cb7b3e9e2350d8b12f28d366cf90ab6c552262 100644 (file)
@@ -910,9 +910,9 @@ sdev_store_queue_ramp_up_period(struct device *dev,
                                const char *buf, size_t count)
 {
        struct scsi_device *sdev = to_scsi_device(dev);
-       unsigned long period;
+       unsigned int period;
 
-       if (strict_strtoul(buf, 10, &period))
+       if (kstrtouint(buf, 10, &period))
                return -EINVAL;
 
        sdev->queue_ramp_up_period = msecs_to_jiffies(period);
@@ -1044,10 +1044,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
        pm_runtime_enable(&sdev->sdev_gendev);
        scsi_autopm_put_target(starget);
 
-       /* The following call will keep sdev active indefinitely, until
-        * its driver does a corresponding scsi_autopm_pm_device().  Only
-        * drivers supporting autosuspend will do this.
-        */
        scsi_autopm_get_device(sdev);
 
        error = device_add(&sdev->sdev_gendev);
@@ -1085,6 +1081,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
                }
        }
 
+       scsi_autopm_put_device(sdev);
        return error;
 }
 
@@ -1263,7 +1260,19 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
        sdev->sdev_dev.class = &sdev_class;
        dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%llu",
                     sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
+       /*
+        * Get a default scsi_level from the target (derived from sibling
+        * devices).  This is the best we can do for guessing how to set
+        * sdev->lun_in_cdb for the initial INQUIRY command.  For LUN 0 the
+        * setting doesn't matter, because all the bits are zero anyway.
+        * But it does matter for higher LUNs.
+        */
        sdev->scsi_level = starget->scsi_level;
+       if (sdev->scsi_level <= SCSI_2 &&
+                       sdev->scsi_level != SCSI_UNKNOWN &&
+                       !shost->no_scsi2_lun_in_cdb)
+               sdev->lun_in_cdb = 1;
+
        transport_setup_device(&sdev->sdev_gendev);
        spin_lock_irqsave(shost->host_lock, flags);
        list_add_tail(&sdev->same_target_siblings, &starget->devices);