All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: pxa: fix legacy non pinctrl aware builds
@ 2016-03-29  8:04 Robert Jarzmik
  2016-03-31 13:18 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Jarzmik @ 2016-03-29  8:04 UTC (permalink / raw)
  To: Robert Jarzmik, Linus Walleij, Alexandre Courbot; +Cc: linux-gpio, linux-kernel

In legacy pxa builds, ie. non device-tree and platform-data only builds,
pinctrl is not yet available. As a consequence, the pinctrl gpio
direction change function is a stub, returning always success.

In the current state, the gpio driver direction function believes the
pinctrl direction change was successful, and exits without actually
changing the gpio direction.

This patch changes the logic :
 - if the pinctrl direction function fails, gpio direction will report
   that failure
 - if the pinctrl direction function succeeds, gpio direction is changed
   by the gpio driver anyway.
   This is sub optimal in the pinctrl aware case, as the gpio direction
   will be changed twice: once by pinctrl function and another time by
   the gpio direction function.

Yet it should be acceptable in this form, as this is functional for all
pxa platforms (device-tree and platform-data), and moreover changing a
gpio direction is very very seldom, usually in machine initialization,
seldom in drivers probe, and an exception for ac97 reset bug.

Fixes: a770d946371e ("gpio: pxa: add pin control gpio direction and request")
Reported-by: Guenter Roeck <guenter@roeck-us.net>
Tested-by: Guenter Roeck <guenter@roeck-us.net>
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 drivers/gpio/gpio-pxa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 20267d8ff858..4d54e56fbb6a 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -283,8 +283,8 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip,
 	writel_relaxed(mask, base + (value ? GPSR_OFFSET : GPCR_OFFSET));
 
 	ret = pinctrl_gpio_direction_output(chip->base + offset);
-	if (!ret)
-		return 0;
+	if (ret)
+		return ret;
 
 	spin_lock_irqsave(&gpio_lock, flags);
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: pxa: fix legacy non pinctrl aware builds
  2016-03-29  8:04 [PATCH] gpio: pxa: fix legacy non pinctrl aware builds Robert Jarzmik
@ 2016-03-31 13:18 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2016-03-31 13:18 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: Alexandre Courbot, linux-gpio, linux-kernel

On Tue, Mar 29, 2016 at 10:04 AM, Robert Jarzmik <robert.jarzmik@free.fr> wrote:

> In legacy pxa builds, ie. non device-tree and platform-data only builds,
> pinctrl is not yet available. As a consequence, the pinctrl gpio
> direction change function is a stub, returning always success.
>
> In the current state, the gpio driver direction function believes the
> pinctrl direction change was successful, and exits without actually
> changing the gpio direction.
>
> This patch changes the logic :
>  - if the pinctrl direction function fails, gpio direction will report
>    that failure
>  - if the pinctrl direction function succeeds, gpio direction is changed
>    by the gpio driver anyway.
>    This is sub optimal in the pinctrl aware case, as the gpio direction
>    will be changed twice: once by pinctrl function and another time by
>    the gpio direction function.
>
> Yet it should be acceptable in this form, as this is functional for all
> pxa platforms (device-tree and platform-data), and moreover changing a
> gpio direction is very very seldom, usually in machine initialization,
> seldom in drivers probe, and an exception for ac97 reset bug.
>
> Fixes: a770d946371e ("gpio: pxa: add pin control gpio direction and request")
> Reported-by: Guenter Roeck <guenter@roeck-us.net>
> Tested-by: Guenter Roeck <guenter@roeck-us.net>
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Patch applied for fixes.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-31 13:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29  8:04 [PATCH] gpio: pxa: fix legacy non pinctrl aware builds Robert Jarzmik
2016-03-31 13:18 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.