[03/12,SRU,B,C,D,OEM-B] mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing led

Message ID 20190111083019.32135-4-acelan.kao@canonical.com
State New
Headers show
Series
  • To reduce the Realtek USB cardreader power consumption
Related show

Commit Message

AceLan Kao Jan. 11, 2019, 8:30 a.m.
From: Ulf Hansson <ulf.hansson@linaro.org>

BugLink: https://bugs.launchpad.net/bugs/1811337

In case the card has been powered off, it seems silly to continue to allow
the led to be updated. Instead let's forbid that, as it enables us to
prevent runtime resuming the device and thus avoids wasting energy.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
(cherry picked from commit 4bfdd76dcb672dd55121b04ed7f1c1ff4343f1ef)
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index 78422079ecfa..bb0ec00ef357 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -1309,14 +1309,18 @@  static void rtsx_usb_update_led(struct work_struct *work)
 		container_of(work, struct rtsx_usb_sdmmc, led_work);
 	struct rtsx_ucr *ucr = host->ucr;
 
-	pm_runtime_get_sync(sdmmc_dev(host));
+	pm_runtime_get_noresume(sdmmc_dev(host));
 	mutex_lock(&ucr->dev_mutex);
 
+	if (host->power_mode == MMC_POWER_OFF)
+		goto out;
+
 	if (host->led.brightness == LED_OFF)
 		rtsx_usb_turn_off_led(ucr);
 	else
 		rtsx_usb_turn_on_led(ucr);
 
+out:
 	mutex_unlock(&ucr->dev_mutex);
 	pm_runtime_put(sdmmc_dev(host));
 }