Skip to content

Commit e03e303

Browse files
khfengstorulf
authored andcommitted
memstick: Prevent memstick host from getting runtime suspended during card detection
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: Kai-Heng Feng <kai.heng.feng@canonical.com> Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 883a87d commit e03e303

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/memstick/core/memstick.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/delay.h>
1919
#include <linux/slab.h>
2020
#include <linux/module.h>
21+
#include <linux/pm_runtime.h>
2122

2223
#define DRIVER_NAME "memstick"
2324

@@ -436,6 +437,7 @@ static void memstick_check(struct work_struct *work)
436437
struct memstick_dev *card;
437438

438439
dev_dbg(&host->dev, "memstick_check started\n");
440+
pm_runtime_get_noresume(host->dev.parent);
439441
mutex_lock(&host->lock);
440442
if (!host->card) {
441443
if (memstick_power_on(host))
@@ -479,6 +481,7 @@ static void memstick_check(struct work_struct *work)
479481
host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
480482

481483
mutex_unlock(&host->lock);
484+
pm_runtime_put(host->dev.parent);
482485
dev_dbg(&host->dev, "memstick_check finished\n");
483486
}
484487

0 commit comments

Comments
 (0)