[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-ide
Subject: [PATCH v2 3/3] ata: runtime suspend port if no device attached
From: Lin Ming <ming.m.lin () intel ! com>
Date: 2011-12-27 5:42:34
Message-ID: 1324964554-9719-4-git-send-email-ming.m.lin () intel ! com
[Download RAW message or body]
Add a new function ata_device_probed(...) to check if device was probed.
Runtime suspend scsi_host--->ata port if no device was probed.
Controller will be runtime suspended if all port were suspended already.
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
drivers/ata/libata-core.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c04ad68..1ff921b 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5906,6 +5906,21 @@ int ata_port_probe(struct ata_port *ap)
return rc;
}
+/**
+ * ata_device_probed - Check if device is probed
+ * @ap: port to check
+ */
+static bool ata_device_probed(struct ata_port *ap)
+{
+ struct ata_link *link;
+ struct ata_device *dev;
+
+ ata_for_each_link(link, ap, EDGE)
+ ata_for_each_dev(dev, link, ENABLED)
+ return true;
+
+ return false;
+}
static void async_port_probe(void *data, async_cookie_t cookie)
{
@@ -5926,7 +5941,11 @@ static void async_port_probe(void *data, async_cookie_t cookie)
/* in order to keep device order, we need to synchronize at this point */
async_synchronize_cookie(cookie);
- ata_scsi_scan_host(ap, 1);
+ if (ata_device_probed(ap))
+ ata_scsi_scan_host(ap, 1);
+ else
+ /* Runtime suspend it if no device is attached */
+ pm_runtime_idle(&ap->scsi_host->shost_gendev);
}
/**
--
1.7.2.5
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic