]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.170/gpio-pxa-handle-corner-case-of-unprobed-device.patch
Linux 4.9.170
[thirdparty/kernel/stable-queue.git] / releases / 4.9.170 / gpio-pxa-handle-corner-case-of-unprobed-device.patch
CommitLineData
5ddacef6
SLM
1From b38a9c4b3f991166aeb9c761cc0fd829d86b6c78 Mon Sep 17 00:00:00 2001
2From: Robert Jarzmik <robert.jarzmik@free.fr>
3Date: Sat, 25 Aug 2018 10:44:17 +0200
4Subject: gpio: pxa: handle corner case of unprobed device
5
6[ Upstream commit 9ce3ebe973bf4073426f35f282c6b955ed802765 ]
7
8In the corner case where the gpio driver probe fails, for whatever
9reason, the suspend and resume handlers will still be called as they
10have to be registered as syscore operations. This applies as well when
11no probe was called while the driver has been built in the kernel.
12
13Nicolas tracked this in :
14https://bugzilla.kernel.org/show_bug.cgi?id=200905
15
16Therefore, add a failsafe in these function, and test if a proper probe
17succeeded and the driver is functional.
18
19Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
20Reported-by: Nicolas Chauvet <kwizart@gmail.com>
21Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
22Signed-off-by: Sasha Levin <sashal@kernel.org>
23---
24 drivers/gpio/gpio-pxa.c | 6 ++++++
25 1 file changed, 6 insertions(+)
26
27diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
28index 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--
522.19.1
53