Commit 0c077ecd authored by Kai-Heng Feng's avatar Kai-Heng Feng Committed by Stefan Bader

memstick: Prevent memstick host from getting runtime suspended during card detection

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

[ Upstream commit e03e303e ]

We can use MEMSTICK_POWER_{ON,OFF} along with pm_runtime_{get,put}
helpers to let memstick host support runtime pm.

The rpm count may go down to zero before the memstick host powers on, so
the host can be runtime suspended.

So before doing card detection, increment the rpm count to avoid the
host gets runtime suspended. Balance the rpm count after card detection
is done.
Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: default avatarOleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 929821d3
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm_runtime.h>
#define DRIVER_NAME "memstick" #define DRIVER_NAME "memstick"
...@@ -436,6 +437,7 @@ static void memstick_check(struct work_struct *work) ...@@ -436,6 +437,7 @@ static void memstick_check(struct work_struct *work)
struct memstick_dev *card; struct memstick_dev *card;
dev_dbg(&host->dev, "memstick_check started\n"); dev_dbg(&host->dev, "memstick_check started\n");
pm_runtime_get_noresume(host->dev.parent);
mutex_lock(&host->lock); mutex_lock(&host->lock);
if (!host->card) { if (!host->card) {
if (memstick_power_on(host)) if (memstick_power_on(host))
...@@ -479,6 +481,7 @@ static void memstick_check(struct work_struct *work) ...@@ -479,6 +481,7 @@ static void memstick_check(struct work_struct *work)
host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
mutex_unlock(&host->lock); mutex_unlock(&host->lock);
pm_runtime_put(host->dev.parent);
dev_dbg(&host->dev, "memstick_check finished\n"); dev_dbg(&host->dev, "memstick_check finished\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment