Message ID | 20180407204738.28308-3-0v3rdr0n3@gmail.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Hello! On 4/7/2018 11:47 PM, 0v3rdr0n3@gmail.com wrote: > From: Samuel Morris <samorris@lexmark.com> > > If no devices are detected on boot, and hotplug is disabled, let the > transport layer suspend automatically to save power automatically. Sounds tautological. > Signed-off-by: Samuel Morris <samorris@lexmark.com> > --- > drivers/ata/libata-scsi.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c > index 89a9d4a2efc8..0f28af19f463 100644 > --- a/drivers/ata/libata-scsi.c > +++ b/drivers/ata/libata-scsi.c [...] > @@ -4568,6 +4569,7 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht) > void ata_scsi_scan_host(struct ata_port *ap, int sync) > { > int tries = 5; > + int devAttached = 0; No camelCase names, please. And this variable should be *bool*. [...] MBR, Sergei
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 89a9d4a2efc8..0f28af19f463 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -51,6 +51,7 @@ #include <linux/suspend.h> #include <asm/unaligned.h> #include <linux/ioprio.h> +#include <linux/pm_runtime.h> #include "libata.h" #include "libata-transport.h" @@ -4568,6 +4569,7 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht) void ata_scsi_scan_host(struct ata_port *ap, int sync) { int tries = 5; + int devAttached = 0; struct ata_device *last_failed_dev = NULL; struct ata_link *link; struct ata_device *dev; @@ -4591,12 +4593,18 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync) if (!IS_ERR(sdev)) { dev->sdev = sdev; scsi_device_put(sdev); + devAttached = 1; } else { dev->sdev = NULL; } } } +#ifdef CONFIG_AHCI_HOTPLUG_DISABLED + if (!devAttached) + pm_runtime_allow(&ap->tdev); +#endif + /* If we scanned while EH was in progress or allocation * failure occurred, scan would have failed silently. Check * whether all devices are attached.