pgreco / rpms / kernel

Forked from rpms/kernel 4 years ago
Clone
e336be
From patchwork Sat Aug 25 08:44:17 2018
e336be
Content-Type: text/plain; charset="utf-8"
e336be
MIME-Version: 1.0
e336be
Content-Transfer-Encoding: 7bit
e336be
Subject: gpio: pxa: handle corner case of unprobed device
e336be
X-Patchwork-Submitter: Robert Jarzmik <robert.jarzmik@free.fr>
e336be
X-Patchwork-Id: 962145
e336be
Message-Id: <20180825084417.13526-1-robert.jarzmik@free.fr>
e336be
To: Robert Jarzmik <robert.jarzmik@free.fr>,
e336be
 Linus Walleij <linus.walleij@linaro.org>
e336be
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
e336be
Date: Sat, 25 Aug 2018 10:44:17 +0200
e336be
From: Robert Jarzmik <robert.jarzmik@free.fr>
e336be
List-Id: <linux-gpio.vger.kernel.org>
e336be
e336be
In the corner case where the gpio driver probe fails, for whatever
e336be
reason, the suspend and resume handlers will still be called as they
e336be
have to be registered as syscore operations. This applies as well when
e336be
no probe was called while the driver has been built in the kernel.
e336be
e336be
Nicolas tracked this in :
e336be
https://bugzilla.kernel.org/show_bug.cgi?id=200905
e336be
e336be
Therefore, add a failsafe in these function, and test if a proper probe
e336be
succeeded and the driver is functional.
e336be
e336be
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
e336be
Reported-by: Nicolas Chauvet <kwizart@gmail.com>
e336be
---
e336be
 drivers/gpio/gpio-pxa.c | 6 ++++++
e336be
 1 file changed, 6 insertions(+)
e336be
e336be
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
e336be
index c18712dabf93..bfe4c5c9f41c 100644
e336be
--- a/drivers/gpio/gpio-pxa.c
e336be
+++ b/drivers/gpio/gpio-pxa.c
e336be
@@ -776,6 +776,9 @@ static int pxa_gpio_suspend(void)
e336be
 	struct pxa_gpio_bank *c;
e336be
 	int gpio;
e336be
 
e336be
+	if (!pchip)
e336be
+		return 0;
e336be
+
e336be
 	for_each_gpio_bank(gpio, c, pchip) {
e336be
 		c->saved_gplr = readl_relaxed(c->regbase + GPLR_OFFSET);
e336be
 		c->saved_gpdr = readl_relaxed(c->regbase + GPDR_OFFSET);
e336be
@@ -794,6 +797,9 @@ static void pxa_gpio_resume(void)
e336be
 	struct pxa_gpio_bank *c;
e336be
 	int gpio;
e336be
 
e336be
+	if (!pchip)
e336be
+		return;
e336be
+
e336be
 	for_each_gpio_bank(gpio, c, pchip) {
e336be
 		/* restore level with set/clear */
e336be
 		writel_relaxed(c->saved_gplr, c->regbase + GPSR_OFFSET);