linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gpio: gpio-mockup: Fix usage of new GPIO_LINE_DIRECTION
@ 2019-12-11  0:46 Kent Gibson
  2019-12-11  9:00 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Kent Gibson @ 2019-12-11  0:46 UTC (permalink / raw)
  To: linux-kernel, linux-gpio, bgolaszewski, linus.walleij, bamv2005
  Cc: Kent Gibson

Restore the external behavior of gpio-mockup to what it was prior to the
change to using GPIO_LINE_DIRECTION.

Fixes: e42615ec233b ("gpio: Use new GPIO_LINE_DIRECTION")
Signed-off-by: Kent Gibson <warthog618@gmail.com>
---

Changes v1 -> v2:
 - add Fixes tag.
 
Fix a regression introduced in v5.5-rc1.

The change to GPIO_LINE_DIRECTION reversed the polarity of the
dir field within gpio-mockup.c, but overlooked inverting the value on
initialization and when returned by gpio_mockup_get_direction.
The latter is a bug.
The former is a problem for tests which assume initial conditions,
specifically the mockup used to initialize chips with all lines as inputs.
That superficially appeared to be the case after the previous patch due
to the bug in gpio_mockup_get_direction.

 drivers/gpio/gpio-mockup.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 56d647a30e3e..c4fdc192ea4e 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -226,7 +226,7 @@ static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset)
 	int direction;
 
 	mutex_lock(&chip->lock);
-	direction = !chip->lines[offset].dir;
+	direction = chip->lines[offset].dir;
 	mutex_unlock(&chip->lock);
 
 	return direction;
@@ -395,7 +395,7 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 	struct gpio_chip *gc;
 	struct device *dev;
 	const char *name;
-	int rv, base;
+	int rv, base, i;
 	u16 ngpio;
 
 	dev = &pdev->dev;
@@ -447,6 +447,9 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 	if (!chip->lines)
 		return -ENOMEM;
 
+	for (i = 0; i < gc->ngpio; i++)
+		chip->lines[i].dir = GPIO_LINE_DIRECTION_IN;
+
 	if (device_property_read_bool(dev, "named-gpio-lines")) {
 		rv = gpio_mockup_name_lines(dev, chip);
 		if (rv)
-- 
2.24.0


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

* Re: [PATCH v2] gpio: gpio-mockup: Fix usage of new GPIO_LINE_DIRECTION
  2019-12-11  0:46 [PATCH v2] gpio: gpio-mockup: Fix usage of new GPIO_LINE_DIRECTION Kent Gibson
@ 2019-12-11  9:00 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2019-12-11  9:00 UTC (permalink / raw)
  To: Kent Gibson
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Bartosz Golaszewski, Linus Walleij, Bamvor Jian Zhang

śr., 11 gru 2019 o 01:46 Kent Gibson <warthog618@gmail.com> napisał(a):
>
> Restore the external behavior of gpio-mockup to what it was prior to the
> change to using GPIO_LINE_DIRECTION.
>
> Fixes: e42615ec233b ("gpio: Use new GPIO_LINE_DIRECTION")
> Signed-off-by: Kent Gibson <warthog618@gmail.com>
> ---
>
> Changes v1 -> v2:
>  - add Fixes tag.
>
> Fix a regression introduced in v5.5-rc1.
>
> The change to GPIO_LINE_DIRECTION reversed the polarity of the
> dir field within gpio-mockup.c, but overlooked inverting the value on
> initialization and when returned by gpio_mockup_get_direction.
> The latter is a bug.
> The former is a problem for tests which assume initial conditions,
> specifically the mockup used to initialize chips with all lines as inputs.
> That superficially appeared to be the case after the previous patch due
> to the bug in gpio_mockup_get_direction.
>
>  drivers/gpio/gpio-mockup.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>

Applied for fixes.

Thanks!
Bartosz

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

end of thread, other threads:[~2019-12-11  9:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11  0:46 [PATCH v2] gpio: gpio-mockup: Fix usage of new GPIO_LINE_DIRECTION Kent Gibson
2019-12-11  9:00 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).