diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 405f9f76bf42..56cf555fd70a 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1092,8 +1092,7 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) * will be woken up by ata_port_pm_resume() with a port reset * and device revalidation. */ - sdev->manage_system_start_stop = true; - sdev->manage_runtime_start_stop = true; + sdev->manage_start_stop = 1; sdev->no_start_on_resume = 1; } diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index e322a326546b..60051c0cabea 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c @@ -81,8 +81,7 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device " * * - power condition * Set the power condition field in the START STOP UNIT commands sent by - * sd_mod on suspend, resume, and shutdown (if manage_system_start_stop or - * manage_runtime_start_stop is on). + * sd_mod on suspend, resume, and shutdown (if manage_start_stop is on). * Some disks need this to spin down or to resume properly. * * - override internal blacklist @@ -1518,10 +1517,8 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev) sdev->use_10_for_rw = 1; - if (sbp2_param_exclusive_login) { - sdev->manage_system_start_stop = true; - sdev->manage_runtime_start_stop = true; - } + if (sbp2_param_exclusive_login) + sdev->manage_start_stop = 1; if (sdev->type == TYPE_ROM) sdev->use_10_for_ms = 1; diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index e0efeed178d8..350936860554 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -213,32 +213,18 @@ cache_type_store(struct device *dev, struct device_attribute *attr, } static ssize_t -manage_start_stop_show(struct device *dev, - struct device_attribute *attr, char *buf) +manage_start_stop_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; - return sysfs_emit(buf, "%u\n", - sdp->manage_system_start_stop && - sdp->manage_runtime_start_stop); -} -static DEVICE_ATTR_RO(manage_start_stop); - -static ssize_t -manage_system_start_stop_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct scsi_disk *sdkp = to_scsi_disk(dev); - struct scsi_device *sdp = sdkp->device; - - return sysfs_emit(buf, "%u\n", sdp->manage_system_start_stop); + return sprintf(buf, "%u\n", sdp->manage_start_stop); } static ssize_t -manage_system_start_stop_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +manage_start_stop_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct scsi_disk *sdkp = to_scsi_disk(dev); struct scsi_device *sdp = sdkp->device; @@ -250,42 +236,11 @@ manage_system_start_stop_store(struct device *dev, if (kstrtobool(buf, &v)) return -EINVAL; - sdp->manage_system_start_stop = v; + sdp->manage_start_stop = v; return count; } -static DEVICE_ATTR_RW(manage_system_start_stop); - -static ssize_t -manage_runtime_start_stop_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct scsi_disk *sdkp = to_scsi_disk(dev); - struct scsi_device *sdp = sdkp->device; - - return sysfs_emit(buf, "%u\n", sdp->manage_runtime_start_stop); -} - -static ssize_t -manage_runtime_start_stop_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct scsi_disk *sdkp = to_scsi_disk(dev); - struct scsi_device *sdp = sdkp->device; - bool v; - - if (!capable(CAP_SYS_ADMIN)) - return -EACCES; - - if (kstrtobool(buf, &v)) - return -EINVAL; - - sdp->manage_runtime_start_stop = v; - - return count; -} -static DEVICE_ATTR_RW(manage_runtime_start_stop); +static DEVICE_ATTR_RW(manage_start_stop); static ssize_t allow_restart_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -617,8 +572,6 @@ static struct attribute *sd_disk_attrs[] = { &dev_attr_FUA.attr, &dev_attr_allow_restart.attr, &dev_attr_manage_start_stop.attr, - &dev_attr_manage_system_start_stop.attr, - &dev_attr_manage_runtime_start_stop.attr, &dev_attr_protection_type.attr, &dev_attr_protection_mode.attr, &dev_attr_app_tag_own.attr, @@ -3723,20 +3676,13 @@ static void sd_shutdown(struct device *dev) sd_sync_cache(sdkp, NULL); } - if (system_state != SYSTEM_RESTART && - sdkp->device->manage_system_start_stop) { + if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) { sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); sd_start_stop_device(sdkp, 0); } } -static inline bool sd_do_start_stop(struct scsi_device *sdev, bool runtime) -{ - return (sdev->manage_system_start_stop && !runtime) || - (sdev->manage_runtime_start_stop && runtime); -} - -static int sd_suspend_common(struct device *dev, bool runtime) +static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) { struct scsi_disk *sdkp = dev_get_drvdata(dev); struct scsi_sense_hdr sshdr; @@ -3768,12 +3714,12 @@ static int sd_suspend_common(struct device *dev, bool runtime) } } - if (sd_do_start_stop(sdkp->device, runtime)) { + if (sdkp->device->manage_start_stop) { if (!sdkp->device->silence_suspend) sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); /* an error is not worth aborting a system sleep */ ret = sd_start_stop_device(sdkp, 0); - if (!runtime) + if (ignore_stop_errors) ret = 0; } @@ -3785,23 +3731,23 @@ static int sd_suspend_system(struct device *dev) if (pm_runtime_suspended(dev)) return 0; - return sd_suspend_common(dev, false); + return sd_suspend_common(dev, true); } static int sd_suspend_runtime(struct device *dev) { - return sd_suspend_common(dev, true); + return sd_suspend_common(dev, false); } -static int sd_resume(struct device *dev, bool runtime) +static int sd_resume(struct device *dev) { struct scsi_disk *sdkp = dev_get_drvdata(dev); - int ret; + int ret = 0; if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ return 0; - if (!sd_do_start_stop(sdkp->device, runtime)) + if (!sdkp->device->manage_start_stop) return 0; if (!sdkp->device->no_start_on_resume) { @@ -3819,7 +3765,7 @@ static int sd_resume_system(struct device *dev) if (pm_runtime_suspended(dev)) return 0; - return sd_resume(dev, false); + return sd_resume(dev); } static int sd_resume_runtime(struct device *dev) @@ -3846,7 +3792,7 @@ static int sd_resume_runtime(struct device *dev) "Failed to clear sense data\n"); } - return sd_resume(dev, true); + return sd_resume(dev); } /** diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index b6610b2b66bd..506af7a1762e 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -162,10 +162,6 @@ struct scsi_device { * pass settings from slave_alloc to scsi * core. */ unsigned int eh_timeout; /* Error handling timeout */ - - bool manage_system_start_stop; /* Let HLD (sd) manage system start/stop */ - bool manage_runtime_start_stop; /* Let HLD (sd) manage runtime start/stop */ - unsigned removable:1; unsigned changed:1; /* Data invalid due to media change */ unsigned busy:1; /* Used to prevent races */ @@ -197,6 +193,7 @@ struct scsi_device { unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ unsigned no_start_on_add:1; /* do not issue start on add */ unsigned allow_restart:1; /* issue START_UNIT in error handler */ + unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ unsigned no_start_on_resume:1; /* Do not issue START_STOP_UNIT on resume */ unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */ unsigned no_uld_attach:1; /* disable connecting to upper level drivers */