]>
Commit | Line | Data |
---|---|---|
5ddacef6 SLM |
1 | From b38a9c4b3f991166aeb9c761cc0fd829d86b6c78 Mon Sep 17 00:00:00 2001 |
2 | From: Robert Jarzmik <robert.jarzmik@free.fr> | |
3 | Date: Sat, 25 Aug 2018 10:44:17 +0200 | |
4 | Subject: gpio: pxa: handle corner case of unprobed device | |
5 | ||
6 | [ Upstream commit 9ce3ebe973bf4073426f35f282c6b955ed802765 ] | |
7 | ||
8 | In the corner case where the gpio driver probe fails, for whatever | |
9 | reason, the suspend and resume handlers will still be called as they | |
10 | have to be registered as syscore operations. This applies as well when | |
11 | no probe was called while the driver has been built in the kernel. | |
12 | ||
13 | Nicolas tracked this in : | |
14 | https://bugzilla.kernel.org/show_bug.cgi?id=200905 | |
15 | ||
16 | Therefore, add a failsafe in these function, and test if a proper probe | |
17 | succeeded and the driver is functional. | |
18 | ||
19 | Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> | |
20 | Reported-by: Nicolas Chauvet <kwizart@gmail.com> | |
21 | Signed-off-by: Linus Walleij <linus.walleij@linaro.org> | |
22 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
23 | --- | |
24 | drivers/gpio/gpio-pxa.c | 6 ++++++ | |
25 | 1 file changed, 6 insertions(+) | |
26 | ||
27 | diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c | |
28 | index 7a6305884f97..32d22bdf7164 100644 | |
29 | --- a/drivers/gpio/gpio-pxa.c | |
30 | +++ b/drivers/gpio/gpio-pxa.c | |
31 | @@ -774,6 +774,9 @@ static int pxa_gpio_suspend(void) | |
32 | struct pxa_gpio_bank *c; | |
33 | int gpio; | |
34 | ||
35 | + if (!pchip) | |
36 | + return 0; | |
37 | + | |
38 | for_each_gpio_bank(gpio, c, pchip) { | |
39 | c->saved_gplr = readl_relaxed(c->regbase + GPLR_OFFSET); | |
40 | c->saved_gpdr = readl_relaxed(c->regbase + GPDR_OFFSET); | |
41 | @@ -792,6 +795,9 @@ static void pxa_gpio_resume(void) | |
42 | struct pxa_gpio_bank *c; | |
43 | int gpio; | |
44 | ||
45 | + if (!pchip) | |
46 | + return; | |
47 | + | |
48 | for_each_gpio_bank(gpio, c, pchip) { | |
49 | /* restore level with set/clear */ | |
50 | writel_relaxed(c->saved_gplr, c->regbase + GPSR_OFFSET); | |
51 | -- | |
52 | 2.19.1 | |
53 |