All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06  8:51 ` Matti Vaittinen
  0 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:51 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang

The patch series adds definitions for GPIO line directions.

For occasional GPIO contributor like me it is always a pain to remember
whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
fact that I removed few comments like:

/* Return 0 if output, 1 if input */
/* This means "out" */
return 1; /* input */
return 0; /* output */

it seems at least some others may find it hard to remember too. Adding
defines for these values helps us who really have good - but short
duration - memory :]

This idea comes from RFC series for ROHM BD71828 PMIC and was initially
discussed with Linus Walleij here:
https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
but as this has no dependencies to BD71828 work (which probably takes a
while) I decided to make it independent series.

Patches are compile-tested only. I have no HW to really test them. Thus I'd
appreciate carefull review. This work is mainly about converting zeros
and ones to the new defines but it wouldn't be first time I get it
wrong.

Changelog v2:
 - squashed patches 2-61 into patch 2.
 - dropped patch 62 (can be applied later)
 - rebased (cherry-picked) changes on top of GPIO devel branch.

Patch 1:
 - adds the defines
Patch 2:
 - convert drivers to use new defines

This patch series is based on GPIO tree devel branch.

---

Matti Vaittinen (2):
  gpio: Add definition for GPIO direction
  gpio: Use new GPIO_LINE_DIRECTION

 drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
 drivers/gpio/gpio-104-idi-48.c      |  2 +-
 drivers/gpio/gpio-104-idio-16.c     |  4 ++--
 drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
 drivers/gpio/gpio-amd-fch.c         |  2 +-
 drivers/gpio/gpio-aspeed.c          |  7 +++----
 drivers/gpio/gpio-bcm-kona.c        |  6 +++---
 drivers/gpio/gpio-bd70528.c         |  8 +++++---
 drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
 drivers/gpio/gpio-dln2.c            |  6 +++---
 drivers/gpio/gpio-exar.c            |  5 ++++-
 drivers/gpio/gpio-f7188x.c          |  5 ++++-
 drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
 drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
 drivers/gpio/gpio-ich.c             |  5 ++++-
 drivers/gpio/gpio-kempld.c          |  5 ++++-
 drivers/gpio/gpio-lp873x.c          |  2 +-
 drivers/gpio/gpio-lp87565.c         |  5 ++++-
 drivers/gpio/gpio-madera.c          |  5 ++++-
 drivers/gpio/gpio-max3191x.c        |  2 +-
 drivers/gpio/gpio-merrifield.c      |  5 ++++-
 drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
 drivers/gpio/gpio-mockup.c          | 11 +++--------
 drivers/gpio/gpio-moxtet.c          |  4 ++--
 drivers/gpio/gpio-mvebu.c           |  5 ++++-
 drivers/gpio/gpio-mxs.c             |  5 ++++-
 drivers/gpio/gpio-omap.c            |  6 ++++--
 drivers/gpio/gpio-pca953x.c         |  5 ++++-
 drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
 drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
 drivers/gpio/gpio-pisosr.c          |  2 +-
 drivers/gpio/gpio-pl061.c           |  5 ++++-
 drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
 drivers/gpio/gpio-rcar.c            |  5 ++++-
 drivers/gpio/gpio-reg.c             |  3 ++-
 drivers/gpio/gpio-sa1100.c          |  5 ++++-
 drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
 drivers/gpio/gpio-sch.c             |  5 ++++-
 drivers/gpio/gpio-sch311x.c         |  5 ++++-
 drivers/gpio/gpio-siox.c            |  4 ++--
 drivers/gpio/gpio-stmpe.c           |  5 ++++-
 drivers/gpio/gpio-tc3589x.c         |  5 ++++-
 drivers/gpio/gpio-tegra.c           |  5 ++++-
 drivers/gpio/gpio-tegra186.c        |  4 ++--
 drivers/gpio/gpio-thunderx.c        |  5 ++++-
 drivers/gpio/gpio-tpic2810.c        |  2 +-
 drivers/gpio/gpio-tps65086.c        |  2 +-
 drivers/gpio/gpio-tps65912.c        |  4 ++--
 drivers/gpio/gpio-tps68470.c        |  6 +++---
 drivers/gpio/gpio-tqmx86.c          |  5 ++++-
 drivers/gpio/gpio-ts4900.c          |  5 ++++-
 drivers/gpio/gpio-twl4030.c         | 10 +++++-----
 drivers/gpio/gpio-twl6040.c         |  3 +--
 drivers/gpio/gpio-uniphier.c        |  5 ++++-
 drivers/gpio/gpio-wcove.c           |  7 +++++--
 drivers/gpio/gpio-ws16c48.c         |  5 ++++-
 drivers/gpio/gpio-xgene.c           |  5 ++++-
 drivers/gpio/gpio-xra1403.c         |  5 ++++-
 drivers/gpio/gpio-xtensa.c          |  4 ++--
 drivers/gpio/gpio-zynq.c            |  7 +++++--
 include/linux/gpio/driver.h         |  3 +++
 61 files changed, 214 insertions(+), 102 deletions(-)

-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

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

* [alsa-devel] [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06  8:51 ` Matti Vaittinen
  0 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:51 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang,
	NXP Linux Team, linux-pwm, Grygorii Strashko, Charles Keepax,
	Maxime Coquelin, linux-omap, Alexandre Torgue, Ray Jui,
	Sascha Hauer, William Breathitt Gray, linux-gpio,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	Andy Shevchenko, linux-arm-kernel, Scott Branden,
	Masahiro Yamada, Andrew Jeffery, Enrico Weigelt,
	metux IT consult, linux-kernel, linux-renesas-soc,
	Thorsten Scherer, Pengutronix Kernel Team, patches, Shawn Guo

The patch series adds definitions for GPIO line directions.

For occasional GPIO contributor like me it is always a pain to remember
whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
fact that I removed few comments like:

/* Return 0 if output, 1 if input */
/* This means "out" */
return 1; /* input */
return 0; /* output */

it seems at least some others may find it hard to remember too. Adding
defines for these values helps us who really have good - but short
duration - memory :]

This idea comes from RFC series for ROHM BD71828 PMIC and was initially
discussed with Linus Walleij here:
https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
but as this has no dependencies to BD71828 work (which probably takes a
while) I decided to make it independent series.

Patches are compile-tested only. I have no HW to really test them. Thus I'd
appreciate carefull review. This work is mainly about converting zeros
and ones to the new defines but it wouldn't be first time I get it
wrong.

Changelog v2:
 - squashed patches 2-61 into patch 2.
 - dropped patch 62 (can be applied later)
 - rebased (cherry-picked) changes on top of GPIO devel branch.

Patch 1:
 - adds the defines
Patch 2:
 - convert drivers to use new defines

This patch series is based on GPIO tree devel branch.

---

Matti Vaittinen (2):
  gpio: Add definition for GPIO direction
  gpio: Use new GPIO_LINE_DIRECTION

 drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
 drivers/gpio/gpio-104-idi-48.c      |  2 +-
 drivers/gpio/gpio-104-idio-16.c     |  4 ++--
 drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
 drivers/gpio/gpio-amd-fch.c         |  2 +-
 drivers/gpio/gpio-aspeed.c          |  7 +++----
 drivers/gpio/gpio-bcm-kona.c        |  6 +++---
 drivers/gpio/gpio-bd70528.c         |  8 +++++---
 drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
 drivers/gpio/gpio-dln2.c            |  6 +++---
 drivers/gpio/gpio-exar.c            |  5 ++++-
 drivers/gpio/gpio-f7188x.c          |  5 ++++-
 drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
 drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
 drivers/gpio/gpio-ich.c             |  5 ++++-
 drivers/gpio/gpio-kempld.c          |  5 ++++-
 drivers/gpio/gpio-lp873x.c          |  2 +-
 drivers/gpio/gpio-lp87565.c         |  5 ++++-
 drivers/gpio/gpio-madera.c          |  5 ++++-
 drivers/gpio/gpio-max3191x.c        |  2 +-
 drivers/gpio/gpio-merrifield.c      |  5 ++++-
 drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
 drivers/gpio/gpio-mockup.c          | 11 +++--------
 drivers/gpio/gpio-moxtet.c          |  4 ++--
 drivers/gpio/gpio-mvebu.c           |  5 ++++-
 drivers/gpio/gpio-mxs.c             |  5 ++++-
 drivers/gpio/gpio-omap.c            |  6 ++++--
 drivers/gpio/gpio-pca953x.c         |  5 ++++-
 drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
 drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
 drivers/gpio/gpio-pisosr.c          |  2 +-
 drivers/gpio/gpio-pl061.c           |  5 ++++-
 drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
 drivers/gpio/gpio-rcar.c            |  5 ++++-
 drivers/gpio/gpio-reg.c             |  3 ++-
 drivers/gpio/gpio-sa1100.c          |  5 ++++-
 drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
 drivers/gpio/gpio-sch.c             |  5 ++++-
 drivers/gpio/gpio-sch311x.c         |  5 ++++-
 drivers/gpio/gpio-siox.c            |  4 ++--
 drivers/gpio/gpio-stmpe.c           |  5 ++++-
 drivers/gpio/gpio-tc3589x.c         |  5 ++++-
 drivers/gpio/gpio-tegra.c           |  5 ++++-
 drivers/gpio/gpio-tegra186.c        |  4 ++--
 drivers/gpio/gpio-thunderx.c        |  5 ++++-
 drivers/gpio/gpio-tpic2810.c        |  2 +-
 drivers/gpio/gpio-tps65086.c        |  2 +-
 drivers/gpio/gpio-tps65912.c        |  4 ++--
 drivers/gpio/gpio-tps68470.c        |  6 +++---
 drivers/gpio/gpio-tqmx86.c          |  5 ++++-
 drivers/gpio/gpio-ts4900.c          |  5 ++++-
 drivers/gpio/gpio-twl4030.c         | 10 +++++-----
 drivers/gpio/gpio-twl6040.c         |  3 +--
 drivers/gpio/gpio-uniphier.c        |  5 ++++-
 drivers/gpio/gpio-wcove.c           |  7 +++++--
 drivers/gpio/gpio-ws16c48.c         |  5 ++++-
 drivers/gpio/gpio-xgene.c           |  5 ++++-
 drivers/gpio/gpio-xra1403.c         |  5 ++++-
 drivers/gpio/gpio-xtensa.c          |  4 ++--
 drivers/gpio/gpio-zynq.c            |  7 +++++--
 include/linux/gpio/driver.h         |  3 +++
 61 files changed, 214 insertions(+), 102 deletions(-)

-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06  8:51 ` Matti Vaittinen
  0 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:51 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang,
	NXP Linux Team, linux-pwm, Grygorii Strashko, Charles Keepax,
	Maxime Coquelin, linux-omap, Alexandre Torgue, Ray Jui,
	Sascha Hauer, William Breathitt Gray, linux-gpio,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	Andy Shevchenko, linux-arm-kernel, Scott Branden,
	Masahiro Yamada, Andrew Jeffery, Enrico Weigelt,
	metux IT consult, linux-kernel, linux-renesas-soc,
	Thorsten Scherer, Pengutronix Kernel Team, patches, Shawn Guo

The patch series adds definitions for GPIO line directions.

For occasional GPIO contributor like me it is always a pain to remember
whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
fact that I removed few comments like:

/* Return 0 if output, 1 if input */
/* This means "out" */
return 1; /* input */
return 0; /* output */

it seems at least some others may find it hard to remember too. Adding
defines for these values helps us who really have good - but short
duration - memory :]

This idea comes from RFC series for ROHM BD71828 PMIC and was initially
discussed with Linus Walleij here:
https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
but as this has no dependencies to BD71828 work (which probably takes a
while) I decided to make it independent series.

Patches are compile-tested only. I have no HW to really test them. Thus I'd
appreciate carefull review. This work is mainly about converting zeros
and ones to the new defines but it wouldn't be first time I get it
wrong.

Changelog v2:
 - squashed patches 2-61 into patch 2.
 - dropped patch 62 (can be applied later)
 - rebased (cherry-picked) changes on top of GPIO devel branch.

Patch 1:
 - adds the defines
Patch 2:
 - convert drivers to use new defines

This patch series is based on GPIO tree devel branch.

---

Matti Vaittinen (2):
  gpio: Add definition for GPIO direction
  gpio: Use new GPIO_LINE_DIRECTION

 drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
 drivers/gpio/gpio-104-idi-48.c      |  2 +-
 drivers/gpio/gpio-104-idio-16.c     |  4 ++--
 drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
 drivers/gpio/gpio-amd-fch.c         |  2 +-
 drivers/gpio/gpio-aspeed.c          |  7 +++----
 drivers/gpio/gpio-bcm-kona.c        |  6 +++---
 drivers/gpio/gpio-bd70528.c         |  8 +++++---
 drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
 drivers/gpio/gpio-dln2.c            |  6 +++---
 drivers/gpio/gpio-exar.c            |  5 ++++-
 drivers/gpio/gpio-f7188x.c          |  5 ++++-
 drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
 drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
 drivers/gpio/gpio-ich.c             |  5 ++++-
 drivers/gpio/gpio-kempld.c          |  5 ++++-
 drivers/gpio/gpio-lp873x.c          |  2 +-
 drivers/gpio/gpio-lp87565.c         |  5 ++++-
 drivers/gpio/gpio-madera.c          |  5 ++++-
 drivers/gpio/gpio-max3191x.c        |  2 +-
 drivers/gpio/gpio-merrifield.c      |  5 ++++-
 drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
 drivers/gpio/gpio-mockup.c          | 11 +++--------
 drivers/gpio/gpio-moxtet.c          |  4 ++--
 drivers/gpio/gpio-mvebu.c           |  5 ++++-
 drivers/gpio/gpio-mxs.c             |  5 ++++-
 drivers/gpio/gpio-omap.c            |  6 ++++--
 drivers/gpio/gpio-pca953x.c         |  5 ++++-
 drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
 drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
 drivers/gpio/gpio-pisosr.c          |  2 +-
 drivers/gpio/gpio-pl061.c           |  5 ++++-
 drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
 drivers/gpio/gpio-rcar.c            |  5 ++++-
 drivers/gpio/gpio-reg.c             |  3 ++-
 drivers/gpio/gpio-sa1100.c          |  5 ++++-
 drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
 drivers/gpio/gpio-sch.c             |  5 ++++-
 drivers/gpio/gpio-sch311x.c         |  5 ++++-
 drivers/gpio/gpio-siox.c            |  4 ++--
 drivers/gpio/gpio-stmpe.c           |  5 ++++-
 drivers/gpio/gpio-tc3589x.c         |  5 ++++-
 drivers/gpio/gpio-tegra.c           |  5 ++++-
 drivers/gpio/gpio-tegra186.c        |  4 ++--
 drivers/gpio/gpio-thunderx.c        |  5 ++++-
 drivers/gpio/gpio-tpic2810.c        |  2 +-
 drivers/gpio/gpio-tps65086.c        |  2 +-
 drivers/gpio/gpio-tps65912.c        |  4 ++--
 drivers/gpio/gpio-tps68470.c        |  6 +++---
 drivers/gpio/gpio-tqmx86.c          |  5 ++++-
 drivers/gpio/gpio-ts4900.c          |  5 ++++-
 drivers/gpio/gpio-twl4030.c         | 10 +++++-----
 drivers/gpio/gpio-twl6040.c         |  3 +--
 drivers/gpio/gpio-uniphier.c        |  5 ++++-
 drivers/gpio/gpio-wcove.c           |  7 +++++--
 drivers/gpio/gpio-ws16c48.c         |  5 ++++-
 drivers/gpio/gpio-xgene.c           |  5 ++++-
 drivers/gpio/gpio-xra1403.c         |  5 ++++-
 drivers/gpio/gpio-xtensa.c          |  4 ++--
 drivers/gpio/gpio-zynq.c            |  7 +++++--
 include/linux/gpio/driver.h         |  3 +++
 61 files changed, 214 insertions(+), 102 deletions(-)

-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 1/2] gpio: Add definition for GPIO direction
  2019-11-06  8:51 ` [alsa-devel] " Matti Vaittinen
  (?)
@ 2019-11-06  8:51   ` Matti Vaittinen
  -1 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:51 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang

At least for me it is difficult to remember the meaning of GPIO
direction values. Define GPIO_LINE_DIRECTION_IN and
GPIO_LINE_DIRECTION_OUT so that occasional GPIO contributors would
not need to always check the meaning of hard coded values 1 and 0.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---

Changes from v1: No changes.

 include/linux/gpio/driver.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 5dd9c982e2cb..cc9ade4552d9 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -22,6 +22,9 @@ enum gpio_lookup_flags;
 
 struct gpio_chip;
 
+#define GPIO_LINE_DIRECTION_IN	1
+#define GPIO_LINE_DIRECTION_OUT	0
+
 /**
  * struct gpio_irq_chip - GPIO interrupt controller
  */
-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

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

* [alsa-devel] [PATCH v2 1/2] gpio: Add definition for GPIO direction
@ 2019-11-06  8:51   ` Matti Vaittinen
  0 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:51 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang,
	NXP Linux Team, linux-pwm, Grygorii Strashko, Charles Keepax,
	Maxime Coquelin, linux-omap, Alexandre Torgue, Ray Jui,
	Sascha Hauer, William Breathitt Gray, linux-gpio,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	Andy Shevchenko, linux-arm-kernel, Scott Branden,
	Masahiro Yamada, Andrew Jeffery, Enrico Weigelt,
	metux IT consult, linux-kernel, linux-renesas-soc,
	Thorsten Scherer, Pengutronix Kernel Team, patches, Shawn Guo

At least for me it is difficult to remember the meaning of GPIO
direction values. Define GPIO_LINE_DIRECTION_IN and
GPIO_LINE_DIRECTION_OUT so that occasional GPIO contributors would
not need to always check the meaning of hard coded values 1 and 0.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---

Changes from v1: No changes.

 include/linux/gpio/driver.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 5dd9c982e2cb..cc9ade4552d9 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -22,6 +22,9 @@ enum gpio_lookup_flags;
 
 struct gpio_chip;
 
+#define GPIO_LINE_DIRECTION_IN	1
+#define GPIO_LINE_DIRECTION_OUT	0
+
 /**
  * struct gpio_irq_chip - GPIO interrupt controller
  */
-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH v2 1/2] gpio: Add definition for GPIO direction
@ 2019-11-06  8:51   ` Matti Vaittinen
  0 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:51 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang,
	NXP Linux Team, linux-pwm, Grygorii Strashko, Charles Keepax,
	Maxime Coquelin, linux-omap, Alexandre Torgue, Ray Jui,
	Sascha Hauer, William Breathitt Gray, linux-gpio,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	Andy Shevchenko, linux-arm-kernel, Scott Branden,
	Masahiro Yamada, Andrew Jeffery, Enrico Weigelt,
	metux IT consult, linux-kernel, linux-renesas-soc,
	Thorsten Scherer, Pengutronix Kernel Team, patches, Shawn Guo

At least for me it is difficult to remember the meaning of GPIO
direction values. Define GPIO_LINE_DIRECTION_IN and
GPIO_LINE_DIRECTION_OUT so that occasional GPIO contributors would
not need to always check the meaning of hard coded values 1 and 0.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---

Changes from v1: No changes.

 include/linux/gpio/driver.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 5dd9c982e2cb..cc9ade4552d9 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -22,6 +22,9 @@ enum gpio_lookup_flags;
 
 struct gpio_chip;
 
+#define GPIO_LINE_DIRECTION_IN	1
+#define GPIO_LINE_DIRECTION_OUT	0
+
 /**
  * struct gpio_irq_chip - GPIO interrupt controller
  */
-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
  2019-11-06  8:51 ` [alsa-devel] " Matti Vaittinen
  (?)
@ 2019-11-06  8:54   ` Matti Vaittinen
  -1 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:54 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang

It's hard for occasional GPIO code reader/writer to know if values 0/1
equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
GPIO_LINE_DIRECTION_OUT to help them out.

NOTE - for gpio-amd-fch and gpio-bd9571mwv:
This commit also changes the return value for direction get to equal 1
for direction INPUT. Prior this commit these drivers might have
returned some other positive value but 1 for INPUT.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

---

This patch contains same changes as v1 patches 2-61 did. v1 was splitted
into small patches in order to help reviewing but squashing was
requested by Linus Walleij. I maintained all acks/reviewed-by tags from
v1 series - so acks/review-by tags in this patch mean that specific
portion of changes have been acked/reviewed by tagger. Eg, whole patch
has not been reviewed/acked by persons mentioned. Please let me know if
this is not Ok to you.

 drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
 drivers/gpio/gpio-104-idi-48.c      |  2 +-
 drivers/gpio/gpio-104-idio-16.c     |  4 ++--
 drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
 drivers/gpio/gpio-amd-fch.c         |  2 +-
 drivers/gpio/gpio-aspeed.c          |  7 +++----
 drivers/gpio/gpio-bcm-kona.c        |  6 +++---
 drivers/gpio/gpio-bd70528.c         |  8 +++++---
 drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
 drivers/gpio/gpio-dln2.c            |  6 +++---
 drivers/gpio/gpio-exar.c            |  5 ++++-
 drivers/gpio/gpio-f7188x.c          |  5 ++++-
 drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
 drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
 drivers/gpio/gpio-ich.c             |  5 ++++-
 drivers/gpio/gpio-kempld.c          |  5 ++++-
 drivers/gpio/gpio-lp873x.c          |  2 +-
 drivers/gpio/gpio-lp87565.c         |  5 ++++-
 drivers/gpio/gpio-madera.c          |  5 ++++-
 drivers/gpio/gpio-max3191x.c        |  2 +-
 drivers/gpio/gpio-merrifield.c      |  5 ++++-
 drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
 drivers/gpio/gpio-mockup.c          | 11 +++--------
 drivers/gpio/gpio-moxtet.c          |  4 ++--
 drivers/gpio/gpio-mvebu.c           |  5 ++++-
 drivers/gpio/gpio-mxs.c             |  5 ++++-
 drivers/gpio/gpio-omap.c            |  6 ++++--
 drivers/gpio/gpio-pca953x.c         |  5 ++++-
 drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
 drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
 drivers/gpio/gpio-pisosr.c          |  2 +-
 drivers/gpio/gpio-pl061.c           |  5 ++++-
 drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
 drivers/gpio/gpio-rcar.c            |  5 ++++-
 drivers/gpio/gpio-reg.c             |  3 ++-
 drivers/gpio/gpio-sa1100.c          |  5 ++++-
 drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
 drivers/gpio/gpio-sch.c             |  5 ++++-
 drivers/gpio/gpio-sch311x.c         |  5 ++++-
 drivers/gpio/gpio-siox.c            |  4 ++--
 drivers/gpio/gpio-stmpe.c           |  5 ++++-
 drivers/gpio/gpio-tc3589x.c         |  5 ++++-
 drivers/gpio/gpio-tegra.c           |  5 ++++-
 drivers/gpio/gpio-tegra186.c        |  4 ++--
 drivers/gpio/gpio-thunderx.c        |  5 ++++-
 drivers/gpio/gpio-tpic2810.c        |  2 +-
 drivers/gpio/gpio-tps65086.c        |  2 +-
 drivers/gpio/gpio-tps65912.c        |  4 ++--
 drivers/gpio/gpio-tps68470.c        |  6 +++---
 drivers/gpio/gpio-tqmx86.c          |  5 ++++-
 drivers/gpio/gpio-ts4900.c          |  5 ++++-
 drivers/gpio/gpio-twl4030.c         | 10 +++++-----
 drivers/gpio/gpio-twl6040.c         |  3 +--
 drivers/gpio/gpio-uniphier.c        |  5 ++++-
 drivers/gpio/gpio-wcove.c           |  7 +++++--
 drivers/gpio/gpio-ws16c48.c         |  5 ++++-
 drivers/gpio/gpio-xgene.c           |  5 ++++-
 drivers/gpio/gpio-xra1403.c         |  5 ++++-
 drivers/gpio/gpio-xtensa.c          |  4 ++--
 drivers/gpio/gpio-zynq.c            |  7 +++++--
 60 files changed, 211 insertions(+), 102 deletions(-)

diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index a44fa8af5b0d..400c09b905f8 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	const unsigned port = offset / 8;
 	const unsigned mask = BIT(offset % 8);
 
-	return !!(dio48egpio->io_state[port] & mask);
+	if (dio48egpio->io_state[port] & mask)
+		return  GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index 79dead61e776..c50329ab493a 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -53,7 +53,7 @@ struct idi_48_gpio {
 
 static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
index 8d2f51cd9d91..5752d9dab148 100644
--- a/drivers/gpio/gpio-104-idio-16.c
+++ b/drivers/gpio/gpio-104-idio-16.c
@@ -51,9 +51,9 @@ struct idio_16_gpio {
 static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	if (offset > 15)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
index 83a2286d93f6..173e06758e6c 100644
--- a/drivers/gpio/gpio-74xx-mmio.c
+++ b/drivers/gpio/gpio-74xx-mmio.c
@@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
 
-	return !(priv->flags & MMIO_74XX_DIR_OUT);
+	if (priv->flags & MMIO_74XX_DIR_OUT)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return  GPIO_LINE_DIRECTION_IN;
 }
 
 static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
index 181df1581df5..4e44ba4d7423 100644
--- a/drivers/gpio/gpio-amd-fch.c
+++ b/drivers/gpio/gpio-amd-fch.c
@@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
 	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
 	spin_unlock_irqrestore(&priv->lock, flags);
 
-	return ret;
+	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
 }
 
 static void amd_fch_gpio_set(struct gpio_chip *gc,
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
index 09e53c5f3b0a..f1037b61f763 100644
--- a/drivers/gpio/gpio-aspeed.c
+++ b/drivers/gpio/gpio-aspeed.c
@@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 	u32 val;
 
 	if (!have_input(gpio, offset))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	if (!have_output(gpio, offset))
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
 	spin_lock_irqsave(&gpio->lock, flags);
 
@@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 
 	spin_unlock_irqrestore(&gpio->lock, flags);
 
-	return !val;
-
+	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
 }
 
 static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index 9fa6d3a967d2..4122683eb1f9 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
@@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
 	u32 val;
 
 	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
-	return !!val;
+	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
 }
 
 static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
@@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
 	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
 
 	/* this function only applies to output pin */
-	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
+	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
 		goto out;
 
 	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
@@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
 	reg_base = kona_gpio->reg_base;
 	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
 
-	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
+	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
 		reg_offset = GPIO_IN_STATUS(bank_id);
 	else
 		reg_offset = GPIO_OUT_STATUS(bank_id);
diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
index 0c1ead12d883..734be6b752d0 100644
--- a/drivers/gpio/gpio-bd70528.c
+++ b/drivers/gpio/gpio-bd70528.c
@@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
 		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
 		return ret;
 	}
+	if (val & BD70528_GPIO_OUT_EN_MASK)
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return !(val & BD70528_GPIO_OUT_EN_MASK);
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
@@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	 * locking would make no sense.
 	 */
 	ret = bd70528_get_direction(chip, offset);
-	if (ret == 0)
+	if (ret == GPIO_LINE_DIRECTION_OUT)
 		ret = bd70528_gpio_get_o(bdgpio, offset);
-	else if (ret == 1)
+	else if (ret == GPIO_LINE_DIRECTION_IN)
 		ret = bd70528_gpio_get_i(bdgpio, offset);
 	else
 		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
index 5224a946e8ab..c0abc9c6851b 100644
--- a/drivers/gpio/gpio-bd9571mwv.c
+++ b/drivers/gpio/gpio-bd9571mwv.c
@@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
 	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
 	if (ret < 0)
 		return ret;
+	if (val & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
 
-	return val & BIT(offset);
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
index 8a33c2fc174d..26b40c8b8a12 100644
--- a/drivers/gpio/gpio-dln2.c
+++ b/drivers/gpio/gpio-dln2.c
@@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
 
 	if (test_bit(offset, dln2->output_enabled))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
@@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	if (dir < 0)
 		return dir;
 
-	if (dir == 1)
+	if (dir == GPIO_LINE_DIRECTION_IN)
 		return dln2_gpio_pin_get_in_val(dln2, offset);
 
 	return dln2_gpio_pin_get_out_val(dln2, offset);
diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index fae327d5b06e..da1ef0b1c291 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
 		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
 	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
 
-	return !!(exar_get(chip, addr) & BIT(bit));
+	if (exar_get(chip, addr) & BIT(bit))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
index fdc639f856f1..cadd02993539 100644
--- a/drivers/gpio/gpio-f7188x.c
+++ b/drivers/gpio/gpio-f7188x.c
@@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 
 	superio_exit(sio->addr);
 
-	return !(dir & 1 << offset);
+	if (dir & 1 << offset)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
index 78a1db24e931..c22d6f94129c 100644
--- a/drivers/gpio/gpio-gpio-mm.c
+++ b/drivers/gpio/gpio-gpio-mm.c
@@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
 	const unsigned int port = offset / 8;
 	const unsigned int mask = BIT(offset % 8);
 
-	return !!(gpiommgpio->io_state[port] & mask);
+	if (gpiommgpio->io_state[port] & mask)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
index 8aa23d70b1e6..a40bd56673fe 100644
--- a/drivers/gpio/gpio-htc-egpio.c
+++ b/drivers/gpio/gpio-htc-egpio.c
@@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
 
 	egpio = gpiochip_get_data(chip);
 
-	return !test_bit(offset, &egpio->is_out);
+	if (test_bit(offset, &egpio->is_out))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static void egpio_write_cache(struct egpio_info *ei)
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index 90bf7742f9b0..2f086d0aa1f4 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
 
 static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
 {
-	return ichx_read_bit(GPIO_IO_SEL, nr);
+	if (ichx_read_bit(GPIO_IO_SEL, nr))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index ef51638f3f75..4ea15f08e0f4 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
 	struct kempld_device_data *pld = gpio->pld;
 
-	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
+	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int kempld_gpio_pincount(struct kempld_device_data *pld)
diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
index 801995dd9b26..70fad87ff2db 100644
--- a/drivers/gpio/gpio-lp873x.c
+++ b/drivers/gpio/gpio-lp873x.c
@@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned int offset)
 {
 	/* This device is output only */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int lp873x_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
index a121c8f10610..e1244520cf7d 100644
--- a/drivers/gpio/gpio-lp87565.c
+++ b/drivers/gpio/gpio-lp87565.c
@@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(val & BIT(offset));
+	if (val & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int lp87565_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
index 7086f8b5388f..8f38303fcbc4 100644
--- a/drivers/gpio/gpio-madera.c
+++ b/drivers/gpio/gpio-madera.c
@@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !!(val & MADERA_GP1_DIR_MASK);
+	if (val & MADERA_GP1_DIR_MASK)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
index 4b4b2ceb82fc..0696d5a21431 100644
--- a/drivers/gpio/gpio-max3191x.c
+++ b/drivers/gpio/gpio-max3191x.c
@@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
 
 static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
 {
-	return 1; /* always in */
+	return GPIO_LINE_DIRECTION_IN; /* always in */
 }
 
 static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
index 2f1e9da81c1e..d4fa6e9560f3 100644
--- a/drivers/gpio/gpio-merrifield.c
+++ b/drivers/gpio/gpio-merrifield.c
@@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
 
-	return !(readl(gpdr) & BIT(offset % 32));
+	if (readl(gpdr) & BIT(offset % 32))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index 6f904c874678..cd07c948649f 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
 {
 	/* Return 0 if output, 1 if input */
-	if (gc->bgpio_dir_unreadable)
-		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
-	if (gc->reg_dir_out)
-		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
+	if (gc->bgpio_dir_unreadable) {
+		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
+			return GPIO_LINE_DIRECTION_OUT;
+		return GPIO_LINE_DIRECTION_IN;
+	}
+
+	if (gc->reg_dir_out) {
+		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
+			return GPIO_LINE_DIRECTION_OUT;
+		return GPIO_LINE_DIRECTION_IN;
+	}
+
 	if (gc->reg_dir_in)
-		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
+		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
+			return GPIO_LINE_DIRECTION_OUT;
 
 	/* This should not happen */
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 213aedc97dc2..47c172b2f5ad 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -34,14 +34,9 @@
 
 #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
 
-enum {
-	GPIO_MOCKUP_DIR_IN = 0,
-	GPIO_MOCKUP_DIR_OUT = 1,
-};
-
 /*
  * struct gpio_pin_status - structure describing a GPIO status
- * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
+ * @dir:       Configures direction of gpio as "in" or "out"
  * @value:     Configures status of the gpio as 0(low) or 1(high)
  */
 struct gpio_mockup_line_status {
@@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
 	mutex_lock(&chip->lock);
-	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
+	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
 	__gpio_mockup_set(chip, offset, value);
 	mutex_unlock(&chip->lock);
 
@@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
 	mutex_lock(&chip->lock);
-	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
+	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
 	mutex_unlock(&chip->lock);
 
 	return 0;
diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
index 3fd729994a38..8299909318f4 100644
--- a/drivers/gpio/gpio-moxtet.c
+++ b/drivers/gpio/gpio-moxtet.c
@@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 
 	/* All lines are hard wired to be either input or output, not both. */
 	if (chip->desc->in_mask & BIT(offset))
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 	else if (chip->desc->out_mask & BIT(offset))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 	else
 		return -EINVAL;
 }
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 6c0687694341..9b2adf0ef880 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 
 	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
 
-	return !!(u & BIT(pin));
+	if (u & BIT(pin))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 5e5437a2c607..c4a314c68555 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
 	u32 dir;
 
 	dir = readl(port->base + PINCTRL_DOE(port));
-	return !(dir & mask);
+	if (dir & mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static const struct platform_device_id mxs_gpio_ids[] = {
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index d0f27084a942..3bd8adaeed9e 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_bank *bank = gpiochip_get_data(chip);
 
-	return !!(readl_relaxed(bank->base + bank->regs->direction) &
-		  BIT(offset));
+	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index de5d1383f28d..82122c3c688a 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
 	if (ret < 0)
 		return ret;
 
-	return !!(reg_val & bit);
+	if (reg_val & bit)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
index 5aa136a6a3e0..df51dd08bdfe 100644
--- a/drivers/gpio/gpio-pci-idio-16.c
+++ b/drivers/gpio/gpio-pci-idio-16.c
@@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
 	unsigned int offset)
 {
 	if (offset > 15)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int idio_16_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
index 52f1647a46fd..44c1e4fc489f 100644
--- a/drivers/gpio/gpio-pcie-idio-24.c
+++ b/drivers/gpio/gpio-pcie-idio-24.c
@@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
 
 	/* FET Outputs */
 	if (offset < 24)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	/* Isolated Inputs */
 	if (offset < 48)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
 	/* TTL/CMOS I/O */
 	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
-	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
+	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int idio_24_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
index f809a5a8e9eb..1331b2a94679 100644
--- a/drivers/gpio/gpio-pisosr.c
+++ b/drivers/gpio/gpio-pisosr.c
@@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned offset)
 {
 	/* This device always input */
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int pisosr_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 722ce5cf861e..5df7782e348f 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct pl061 *pl061 = gpiochip_get_data(gc);
 
-	return !(readb(pl061->base + GPIODIR) & BIT(offset));
+	if (readb(pl061->base + GPIODIR) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
index b77ea16ffa03..bb100e0124e6 100644
--- a/drivers/gpio/gpio-raspberrypi-exp.c
+++ b/drivers/gpio/gpio-raspberrypi-exp.c
@@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
 			get.gpio);
 		return ret ? ret : -EIO;
 	}
-	return !get.direction;
+	if (get.direction)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 187984d26f47..d7e6e68c25af 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
 
-	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
+	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
index fdc7a9d5b382..d35169bde25a 100644
--- a/drivers/gpio/gpio-reg.c
+++ b/drivers/gpio/gpio-reg.c
@@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct gpio_reg *r = to_gpio_reg(gc);
 
-	return r->direction & BIT(offset) ? 1 : 0;
+	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
+					    GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
index 46b7cf23fb0f..edff5e81489f 100644
--- a/drivers/gpio/gpio-sa1100.c
+++ b/drivers/gpio/gpio-sa1100.c
@@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
 
-	return !(readl_relaxed(gpdr) & BIT(offset));
+	if (readl_relaxed(gpdr) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
index 7d718557092e..b04c561f3280 100644
--- a/drivers/gpio/gpio-sama5d2-piobu.c
+++ b/drivers/gpio/gpio-sama5d2-piobu.c
@@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return (ret == PIOBU_IN) ? 1 : 0;
+	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
+				   GPIO_LINE_DIRECTION_OUT;
 }
 
 /**
@@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
 	/* if pin is input, read value from PDS else read from SOD */
 	int ret = sama5d2_piobu_get_direction(chip, pin);
 
-	if (ret == 1)
+	if (ret == GPIO_LINE_DIRECTION_IN)
 		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
-	else if (!ret)
+	else if (ret == GPIO_LINE_DIRECTION_OUT)
 		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
 
 	if (ret < 0)
diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
index fb143f28c386..c65f35b68202 100644
--- a/drivers/gpio/gpio-sch.c
+++ b/drivers/gpio/gpio-sch.c
@@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
 {
 	struct sch_gpio *sch = gpiochip_get_data(gc);
 
-	return sch_gpio_reg_get(sch, gpio_num, GIO);
+	if (sch_gpio_reg_get(sch, gpio_num, GIO))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static const struct gpio_chip sch_gpio_chip = {
diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
index 8ecf336c9af4..da01e1cad7cb 100644
--- a/drivers/gpio/gpio-sch311x.c
+++ b/drivers/gpio/gpio-sch311x.c
@@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	data = inb(block->runtime_reg + block->config_regs[offset]);
 	spin_unlock(&block->lock);
 
-	return !!(data & SCH311X_GPIO_CONF_DIR);
+	if (data & SCH311X_GPIO_CONF_DIR)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
index 006a7e6a75f2..311f66757b92 100644
--- a/drivers/gpio/gpio-siox.c
+++ b/drivers/gpio/gpio-siox.c
@@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
 static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	if (offset < 12)
-		return 1; /* input */
+		return GPIO_LINE_DIRECTION_IN;
 	else
-		return 0; /* output */
+		return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpio_siox_probe(struct siox_device *sdevice)
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 994d542daf53..542706a852e6 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(ret & mask);
+	if (ret & mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int stmpe_gpio_direction_output(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
index 75b1135b383a..6be0684cfa49 100644
--- a/drivers/gpio/gpio-tc3589x.c
+++ b/drivers/gpio/gpio-tc3589x.c
@@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(ret & BIT(pos));
+	if (ret & BIT(pos))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 8a01d3694b28..6fdfe4c5303e 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
 
 	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
 
-	return !(oe & pin_mask);
+	if (oe & pin_mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index 8a2a69178925..57185b96c110 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
 
 	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
 	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tegra186_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
index ddad5c7ea617..d08d86a22b1f 100644
--- a/drivers/gpio/gpio-thunderx.c
+++ b/drivers/gpio/gpio-thunderx.c
@@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
 
 	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
 
-	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
+	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int thunderx_gpio_set_config(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
index c8b34d787eed..99d5a84a9129 100644
--- a/drivers/gpio/gpio-tpic2810.c
+++ b/drivers/gpio/gpio-tpic2810.c
@@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
 				  unsigned offset)
 {
 	/* This device always output */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int tpic2810_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
index 2eea98ff4ea3..1e9d8262d0ff 100644
--- a/drivers/gpio/gpio-tps65086.c
+++ b/drivers/gpio/gpio-tps65086.c
@@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
 				       unsigned offset)
 {
 	/* This device is output only */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int tps65086_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
index 3ad68bd78282..510d9ed9fd2a 100644
--- a/drivers/gpio/gpio-tps65912.c
+++ b/drivers/gpio/gpio-tps65912.c
@@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
 		return ret;
 
 	if (val & GPIO_CFG_MASK)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 	else
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
index aff6e504c666..f7f5f770e0fb 100644
--- a/drivers/gpio/gpio-tps68470.c
+++ b/drivers/gpio/gpio-tps68470.c
@@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
 	return !!(val & BIT(offset));
 }
 
-/* Return 0 if output, 1 if input */
 static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 				       unsigned int offset)
 {
@@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 
 	/* rest are always outputs */
 	if (offset >= TPS68470_N_REGULAR_GPIO)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
 	if (ret) {
@@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 	}
 
 	val &= TPS68470_GPIO_MODE_MASK;
-	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
+	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
+						    GPIO_LINE_DIRECTION_IN;
 }
 
 static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
index a3109bcaa0ac..5022e0ad0fae 100644
--- a/drivers/gpio/gpio-tqmx86.c
+++ b/drivers/gpio/gpio-tqmx86.c
@@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
 static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned int offset)
 {
-	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
+	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static void tqmx86_gpio_irq_mask(struct irq_data *data)
diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
index 1da8d0586329..d885032cf814 100644
--- a/drivers/gpio/gpio-ts4900.c
+++ b/drivers/gpio/gpio-ts4900.c
@@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
 
 	regmap_read(priv->regmap, offset, &reg);
 
-	return !(reg & TS4900_GPIO_OE);
+	if (reg & TS4900_GPIO_OE)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int ts4900_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index fbfb648d3502..de249726230e 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
 	if (ret < 0)
 		return ret;
 
-	/* 1 = output, but gpiolib semantics are inverse so invert */
-	ret = !(ret & d_msk);
+	if (ret & d_msk)
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return ret;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int twl4030_set_gpio_dataout(int gpio, int enable)
@@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
 	/*
-	 * Default 0 = output
+	 * Default GPIO_LINE_DIRECTION_OUT
 	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
 	 */
-	int ret = 0;
+	int ret = GPIO_LINE_DIRECTION_OUT;
 
 	mutex_lock(&priv->mutex);
 	if (offset < TWL4030_GPIO_MAX) {
diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
index c845b2ff1f43..648fb418d775 100644
--- a/drivers/gpio/gpio-twl6040.c
+++ b/drivers/gpio/gpio-twl6040.c
@@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
 
 static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	/* This means "out" */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
index 93cdcc41e9fb..bd203e8fa58e 100644
--- a/drivers/gpio/gpio-uniphier.c
+++ b/drivers/gpio/gpio-uniphier.c
@@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
 static int uniphier_gpio_get_direction(struct gpio_chip *chip,
 				       unsigned int offset)
 {
-	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
+	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int uniphier_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index 444fe9e7f04a..8b481b3c1ebe 100644
--- a/drivers/gpio/gpio-wcove.c
+++ b/drivers/gpio/gpio-wcove.c
@@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
 	int ret, reg = to_reg(gpio, CTRL_OUT);
 
 	if (reg < 0)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	ret = regmap_read(wg->regmap, reg, &val);
 	if (ret)
 		return ret;
 
-	return !(val & CTLO_DIR_OUT);
+	if (val & CTLO_DIR_OUT)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index e0ef66b6a237..fe456bea81f6 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	const unsigned port = offset / 8;
 	const unsigned mask = BIT(offset % 8);
 
-	return !!(ws16c48gpio->io_state[port] & mask);
+	if (ws16c48gpio->io_state[port] & mask)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
index a6e66ac18e1f..532b0df8a1f2 100644
--- a/drivers/gpio/gpio-xgene.c
+++ b/drivers/gpio/gpio-xgene.c
@@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
 	bit_offset = GPIO_BIT_OFFSET(offset);
 
-	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
+	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
index 05f1998c11a4..31b5072b2df0 100644
--- a/drivers/gpio/gpio-xra1403.c
+++ b/drivers/gpio/gpio-xra1403.c
@@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
 	if (ret)
 		return ret;
 
-	return !!(val & BIT(offset % 8));
+	if (val & BIT(offset % 8))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
index 43d3fa5f511a..08d7c3b32038 100644
--- a/drivers/gpio/gpio-xtensa.c
+++ b/drivers/gpio/gpio-xtensa.c
@@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
 
 static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
 {
-	return 1; /* input only */
+	return GPIO_LINE_DIRECTION_IN; /* input only */
 }
 
 static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
@@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
 
 static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
 {
-	return 0; /* output only */
+	return GPIO_LINE_DIRECTION_OUT; /* output only */
 }
 
 static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index cd475ff4bcad..4c3f6370eab4 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
  *
  * This function returns the direction of the specified GPIO.
  *
- * Return: 0 for output, 1 for input
+ * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
  */
 static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 {
@@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 
 	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
 
-	return !(reg & BIT(bank_pin_num));
+	if (reg & BIT(bank_pin_num))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 /**
-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

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

* [alsa-devel] [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
@ 2019-11-06  8:54   ` Matti Vaittinen
  0 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:54 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang,
	NXP Linux Team, linux-pwm, Grygorii Strashko, Charles Keepax,
	Maxime Coquelin, linux-omap, Alexandre Torgue, Ray Jui,
	Sascha Hauer, William Breathitt Gray, linux-gpio,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	Andy Shevchenko, linux-arm-kernel, Scott Branden,
	Masahiro Yamada, Andrew Jeffery, Enrico Weigelt,
	metux IT consult, linux-kernel, linux-renesas-soc,
	Thorsten Scherer, Pengutronix Kernel Team, patches, Shawn Guo

It's hard for occasional GPIO code reader/writer to know if values 0/1
equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
GPIO_LINE_DIRECTION_OUT to help them out.

NOTE - for gpio-amd-fch and gpio-bd9571mwv:
This commit also changes the return value for direction get to equal 1
for direction INPUT. Prior this commit these drivers might have
returned some other positive value but 1 for INPUT.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

---

This patch contains same changes as v1 patches 2-61 did. v1 was splitted
into small patches in order to help reviewing but squashing was
requested by Linus Walleij. I maintained all acks/reviewed-by tags from
v1 series - so acks/review-by tags in this patch mean that specific
portion of changes have been acked/reviewed by tagger. Eg, whole patch
has not been reviewed/acked by persons mentioned. Please let me know if
this is not Ok to you.

 drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
 drivers/gpio/gpio-104-idi-48.c      |  2 +-
 drivers/gpio/gpio-104-idio-16.c     |  4 ++--
 drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
 drivers/gpio/gpio-amd-fch.c         |  2 +-
 drivers/gpio/gpio-aspeed.c          |  7 +++----
 drivers/gpio/gpio-bcm-kona.c        |  6 +++---
 drivers/gpio/gpio-bd70528.c         |  8 +++++---
 drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
 drivers/gpio/gpio-dln2.c            |  6 +++---
 drivers/gpio/gpio-exar.c            |  5 ++++-
 drivers/gpio/gpio-f7188x.c          |  5 ++++-
 drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
 drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
 drivers/gpio/gpio-ich.c             |  5 ++++-
 drivers/gpio/gpio-kempld.c          |  5 ++++-
 drivers/gpio/gpio-lp873x.c          |  2 +-
 drivers/gpio/gpio-lp87565.c         |  5 ++++-
 drivers/gpio/gpio-madera.c          |  5 ++++-
 drivers/gpio/gpio-max3191x.c        |  2 +-
 drivers/gpio/gpio-merrifield.c      |  5 ++++-
 drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
 drivers/gpio/gpio-mockup.c          | 11 +++--------
 drivers/gpio/gpio-moxtet.c          |  4 ++--
 drivers/gpio/gpio-mvebu.c           |  5 ++++-
 drivers/gpio/gpio-mxs.c             |  5 ++++-
 drivers/gpio/gpio-omap.c            |  6 ++++--
 drivers/gpio/gpio-pca953x.c         |  5 ++++-
 drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
 drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
 drivers/gpio/gpio-pisosr.c          |  2 +-
 drivers/gpio/gpio-pl061.c           |  5 ++++-
 drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
 drivers/gpio/gpio-rcar.c            |  5 ++++-
 drivers/gpio/gpio-reg.c             |  3 ++-
 drivers/gpio/gpio-sa1100.c          |  5 ++++-
 drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
 drivers/gpio/gpio-sch.c             |  5 ++++-
 drivers/gpio/gpio-sch311x.c         |  5 ++++-
 drivers/gpio/gpio-siox.c            |  4 ++--
 drivers/gpio/gpio-stmpe.c           |  5 ++++-
 drivers/gpio/gpio-tc3589x.c         |  5 ++++-
 drivers/gpio/gpio-tegra.c           |  5 ++++-
 drivers/gpio/gpio-tegra186.c        |  4 ++--
 drivers/gpio/gpio-thunderx.c        |  5 ++++-
 drivers/gpio/gpio-tpic2810.c        |  2 +-
 drivers/gpio/gpio-tps65086.c        |  2 +-
 drivers/gpio/gpio-tps65912.c        |  4 ++--
 drivers/gpio/gpio-tps68470.c        |  6 +++---
 drivers/gpio/gpio-tqmx86.c          |  5 ++++-
 drivers/gpio/gpio-ts4900.c          |  5 ++++-
 drivers/gpio/gpio-twl4030.c         | 10 +++++-----
 drivers/gpio/gpio-twl6040.c         |  3 +--
 drivers/gpio/gpio-uniphier.c        |  5 ++++-
 drivers/gpio/gpio-wcove.c           |  7 +++++--
 drivers/gpio/gpio-ws16c48.c         |  5 ++++-
 drivers/gpio/gpio-xgene.c           |  5 ++++-
 drivers/gpio/gpio-xra1403.c         |  5 ++++-
 drivers/gpio/gpio-xtensa.c          |  4 ++--
 drivers/gpio/gpio-zynq.c            |  7 +++++--
 60 files changed, 211 insertions(+), 102 deletions(-)

diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index a44fa8af5b0d..400c09b905f8 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	const unsigned port = offset / 8;
 	const unsigned mask = BIT(offset % 8);
 
-	return !!(dio48egpio->io_state[port] & mask);
+	if (dio48egpio->io_state[port] & mask)
+		return  GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index 79dead61e776..c50329ab493a 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -53,7 +53,7 @@ struct idi_48_gpio {
 
 static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
index 8d2f51cd9d91..5752d9dab148 100644
--- a/drivers/gpio/gpio-104-idio-16.c
+++ b/drivers/gpio/gpio-104-idio-16.c
@@ -51,9 +51,9 @@ struct idio_16_gpio {
 static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	if (offset > 15)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
index 83a2286d93f6..173e06758e6c 100644
--- a/drivers/gpio/gpio-74xx-mmio.c
+++ b/drivers/gpio/gpio-74xx-mmio.c
@@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
 
-	return !(priv->flags & MMIO_74XX_DIR_OUT);
+	if (priv->flags & MMIO_74XX_DIR_OUT)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return  GPIO_LINE_DIRECTION_IN;
 }
 
 static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
index 181df1581df5..4e44ba4d7423 100644
--- a/drivers/gpio/gpio-amd-fch.c
+++ b/drivers/gpio/gpio-amd-fch.c
@@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
 	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
 	spin_unlock_irqrestore(&priv->lock, flags);
 
-	return ret;
+	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
 }
 
 static void amd_fch_gpio_set(struct gpio_chip *gc,
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
index 09e53c5f3b0a..f1037b61f763 100644
--- a/drivers/gpio/gpio-aspeed.c
+++ b/drivers/gpio/gpio-aspeed.c
@@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 	u32 val;
 
 	if (!have_input(gpio, offset))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	if (!have_output(gpio, offset))
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
 	spin_lock_irqsave(&gpio->lock, flags);
 
@@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 
 	spin_unlock_irqrestore(&gpio->lock, flags);
 
-	return !val;
-
+	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
 }
 
 static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index 9fa6d3a967d2..4122683eb1f9 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
@@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
 	u32 val;
 
 	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
-	return !!val;
+	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
 }
 
 static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
@@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
 	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
 
 	/* this function only applies to output pin */
-	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
+	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
 		goto out;
 
 	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
@@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
 	reg_base = kona_gpio->reg_base;
 	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
 
-	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
+	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
 		reg_offset = GPIO_IN_STATUS(bank_id);
 	else
 		reg_offset = GPIO_OUT_STATUS(bank_id);
diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
index 0c1ead12d883..734be6b752d0 100644
--- a/drivers/gpio/gpio-bd70528.c
+++ b/drivers/gpio/gpio-bd70528.c
@@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
 		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
 		return ret;
 	}
+	if (val & BD70528_GPIO_OUT_EN_MASK)
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return !(val & BD70528_GPIO_OUT_EN_MASK);
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
@@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	 * locking would make no sense.
 	 */
 	ret = bd70528_get_direction(chip, offset);
-	if (ret == 0)
+	if (ret == GPIO_LINE_DIRECTION_OUT)
 		ret = bd70528_gpio_get_o(bdgpio, offset);
-	else if (ret == 1)
+	else if (ret == GPIO_LINE_DIRECTION_IN)
 		ret = bd70528_gpio_get_i(bdgpio, offset);
 	else
 		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
index 5224a946e8ab..c0abc9c6851b 100644
--- a/drivers/gpio/gpio-bd9571mwv.c
+++ b/drivers/gpio/gpio-bd9571mwv.c
@@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
 	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
 	if (ret < 0)
 		return ret;
+	if (val & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
 
-	return val & BIT(offset);
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
index 8a33c2fc174d..26b40c8b8a12 100644
--- a/drivers/gpio/gpio-dln2.c
+++ b/drivers/gpio/gpio-dln2.c
@@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
 
 	if (test_bit(offset, dln2->output_enabled))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
@@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	if (dir < 0)
 		return dir;
 
-	if (dir == 1)
+	if (dir == GPIO_LINE_DIRECTION_IN)
 		return dln2_gpio_pin_get_in_val(dln2, offset);
 
 	return dln2_gpio_pin_get_out_val(dln2, offset);
diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index fae327d5b06e..da1ef0b1c291 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
 		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
 	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
 
-	return !!(exar_get(chip, addr) & BIT(bit));
+	if (exar_get(chip, addr) & BIT(bit))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
index fdc639f856f1..cadd02993539 100644
--- a/drivers/gpio/gpio-f7188x.c
+++ b/drivers/gpio/gpio-f7188x.c
@@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 
 	superio_exit(sio->addr);
 
-	return !(dir & 1 << offset);
+	if (dir & 1 << offset)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
index 78a1db24e931..c22d6f94129c 100644
--- a/drivers/gpio/gpio-gpio-mm.c
+++ b/drivers/gpio/gpio-gpio-mm.c
@@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
 	const unsigned int port = offset / 8;
 	const unsigned int mask = BIT(offset % 8);
 
-	return !!(gpiommgpio->io_state[port] & mask);
+	if (gpiommgpio->io_state[port] & mask)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
index 8aa23d70b1e6..a40bd56673fe 100644
--- a/drivers/gpio/gpio-htc-egpio.c
+++ b/drivers/gpio/gpio-htc-egpio.c
@@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
 
 	egpio = gpiochip_get_data(chip);
 
-	return !test_bit(offset, &egpio->is_out);
+	if (test_bit(offset, &egpio->is_out))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static void egpio_write_cache(struct egpio_info *ei)
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index 90bf7742f9b0..2f086d0aa1f4 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
 
 static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
 {
-	return ichx_read_bit(GPIO_IO_SEL, nr);
+	if (ichx_read_bit(GPIO_IO_SEL, nr))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index ef51638f3f75..4ea15f08e0f4 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
 	struct kempld_device_data *pld = gpio->pld;
 
-	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
+	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int kempld_gpio_pincount(struct kempld_device_data *pld)
diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
index 801995dd9b26..70fad87ff2db 100644
--- a/drivers/gpio/gpio-lp873x.c
+++ b/drivers/gpio/gpio-lp873x.c
@@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned int offset)
 {
 	/* This device is output only */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int lp873x_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
index a121c8f10610..e1244520cf7d 100644
--- a/drivers/gpio/gpio-lp87565.c
+++ b/drivers/gpio/gpio-lp87565.c
@@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(val & BIT(offset));
+	if (val & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int lp87565_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
index 7086f8b5388f..8f38303fcbc4 100644
--- a/drivers/gpio/gpio-madera.c
+++ b/drivers/gpio/gpio-madera.c
@@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !!(val & MADERA_GP1_DIR_MASK);
+	if (val & MADERA_GP1_DIR_MASK)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
index 4b4b2ceb82fc..0696d5a21431 100644
--- a/drivers/gpio/gpio-max3191x.c
+++ b/drivers/gpio/gpio-max3191x.c
@@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
 
 static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
 {
-	return 1; /* always in */
+	return GPIO_LINE_DIRECTION_IN; /* always in */
 }
 
 static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
index 2f1e9da81c1e..d4fa6e9560f3 100644
--- a/drivers/gpio/gpio-merrifield.c
+++ b/drivers/gpio/gpio-merrifield.c
@@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
 
-	return !(readl(gpdr) & BIT(offset % 32));
+	if (readl(gpdr) & BIT(offset % 32))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index 6f904c874678..cd07c948649f 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
 {
 	/* Return 0 if output, 1 if input */
-	if (gc->bgpio_dir_unreadable)
-		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
-	if (gc->reg_dir_out)
-		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
+	if (gc->bgpio_dir_unreadable) {
+		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
+			return GPIO_LINE_DIRECTION_OUT;
+		return GPIO_LINE_DIRECTION_IN;
+	}
+
+	if (gc->reg_dir_out) {
+		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
+			return GPIO_LINE_DIRECTION_OUT;
+		return GPIO_LINE_DIRECTION_IN;
+	}
+
 	if (gc->reg_dir_in)
-		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
+		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
+			return GPIO_LINE_DIRECTION_OUT;
 
 	/* This should not happen */
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 213aedc97dc2..47c172b2f5ad 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -34,14 +34,9 @@
 
 #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
 
-enum {
-	GPIO_MOCKUP_DIR_IN = 0,
-	GPIO_MOCKUP_DIR_OUT = 1,
-};
-
 /*
  * struct gpio_pin_status - structure describing a GPIO status
- * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
+ * @dir:       Configures direction of gpio as "in" or "out"
  * @value:     Configures status of the gpio as 0(low) or 1(high)
  */
 struct gpio_mockup_line_status {
@@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
 	mutex_lock(&chip->lock);
-	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
+	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
 	__gpio_mockup_set(chip, offset, value);
 	mutex_unlock(&chip->lock);
 
@@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
 	mutex_lock(&chip->lock);
-	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
+	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
 	mutex_unlock(&chip->lock);
 
 	return 0;
diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
index 3fd729994a38..8299909318f4 100644
--- a/drivers/gpio/gpio-moxtet.c
+++ b/drivers/gpio/gpio-moxtet.c
@@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 
 	/* All lines are hard wired to be either input or output, not both. */
 	if (chip->desc->in_mask & BIT(offset))
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 	else if (chip->desc->out_mask & BIT(offset))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 	else
 		return -EINVAL;
 }
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 6c0687694341..9b2adf0ef880 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 
 	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
 
-	return !!(u & BIT(pin));
+	if (u & BIT(pin))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 5e5437a2c607..c4a314c68555 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
 	u32 dir;
 
 	dir = readl(port->base + PINCTRL_DOE(port));
-	return !(dir & mask);
+	if (dir & mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static const struct platform_device_id mxs_gpio_ids[] = {
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index d0f27084a942..3bd8adaeed9e 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_bank *bank = gpiochip_get_data(chip);
 
-	return !!(readl_relaxed(bank->base + bank->regs->direction) &
-		  BIT(offset));
+	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index de5d1383f28d..82122c3c688a 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
 	if (ret < 0)
 		return ret;
 
-	return !!(reg_val & bit);
+	if (reg_val & bit)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
index 5aa136a6a3e0..df51dd08bdfe 100644
--- a/drivers/gpio/gpio-pci-idio-16.c
+++ b/drivers/gpio/gpio-pci-idio-16.c
@@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
 	unsigned int offset)
 {
 	if (offset > 15)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int idio_16_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
index 52f1647a46fd..44c1e4fc489f 100644
--- a/drivers/gpio/gpio-pcie-idio-24.c
+++ b/drivers/gpio/gpio-pcie-idio-24.c
@@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
 
 	/* FET Outputs */
 	if (offset < 24)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	/* Isolated Inputs */
 	if (offset < 48)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
 	/* TTL/CMOS I/O */
 	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
-	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
+	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int idio_24_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
index f809a5a8e9eb..1331b2a94679 100644
--- a/drivers/gpio/gpio-pisosr.c
+++ b/drivers/gpio/gpio-pisosr.c
@@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned offset)
 {
 	/* This device always input */
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int pisosr_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 722ce5cf861e..5df7782e348f 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct pl061 *pl061 = gpiochip_get_data(gc);
 
-	return !(readb(pl061->base + GPIODIR) & BIT(offset));
+	if (readb(pl061->base + GPIODIR) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
index b77ea16ffa03..bb100e0124e6 100644
--- a/drivers/gpio/gpio-raspberrypi-exp.c
+++ b/drivers/gpio/gpio-raspberrypi-exp.c
@@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
 			get.gpio);
 		return ret ? ret : -EIO;
 	}
-	return !get.direction;
+	if (get.direction)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 187984d26f47..d7e6e68c25af 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
 
-	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
+	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
index fdc7a9d5b382..d35169bde25a 100644
--- a/drivers/gpio/gpio-reg.c
+++ b/drivers/gpio/gpio-reg.c
@@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct gpio_reg *r = to_gpio_reg(gc);
 
-	return r->direction & BIT(offset) ? 1 : 0;
+	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
+					    GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
index 46b7cf23fb0f..edff5e81489f 100644
--- a/drivers/gpio/gpio-sa1100.c
+++ b/drivers/gpio/gpio-sa1100.c
@@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
 
-	return !(readl_relaxed(gpdr) & BIT(offset));
+	if (readl_relaxed(gpdr) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
index 7d718557092e..b04c561f3280 100644
--- a/drivers/gpio/gpio-sama5d2-piobu.c
+++ b/drivers/gpio/gpio-sama5d2-piobu.c
@@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return (ret == PIOBU_IN) ? 1 : 0;
+	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
+				   GPIO_LINE_DIRECTION_OUT;
 }
 
 /**
@@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
 	/* if pin is input, read value from PDS else read from SOD */
 	int ret = sama5d2_piobu_get_direction(chip, pin);
 
-	if (ret == 1)
+	if (ret == GPIO_LINE_DIRECTION_IN)
 		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
-	else if (!ret)
+	else if (ret == GPIO_LINE_DIRECTION_OUT)
 		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
 
 	if (ret < 0)
diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
index fb143f28c386..c65f35b68202 100644
--- a/drivers/gpio/gpio-sch.c
+++ b/drivers/gpio/gpio-sch.c
@@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
 {
 	struct sch_gpio *sch = gpiochip_get_data(gc);
 
-	return sch_gpio_reg_get(sch, gpio_num, GIO);
+	if (sch_gpio_reg_get(sch, gpio_num, GIO))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static const struct gpio_chip sch_gpio_chip = {
diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
index 8ecf336c9af4..da01e1cad7cb 100644
--- a/drivers/gpio/gpio-sch311x.c
+++ b/drivers/gpio/gpio-sch311x.c
@@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	data = inb(block->runtime_reg + block->config_regs[offset]);
 	spin_unlock(&block->lock);
 
-	return !!(data & SCH311X_GPIO_CONF_DIR);
+	if (data & SCH311X_GPIO_CONF_DIR)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
index 006a7e6a75f2..311f66757b92 100644
--- a/drivers/gpio/gpio-siox.c
+++ b/drivers/gpio/gpio-siox.c
@@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
 static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	if (offset < 12)
-		return 1; /* input */
+		return GPIO_LINE_DIRECTION_IN;
 	else
-		return 0; /* output */
+		return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpio_siox_probe(struct siox_device *sdevice)
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 994d542daf53..542706a852e6 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(ret & mask);
+	if (ret & mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int stmpe_gpio_direction_output(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
index 75b1135b383a..6be0684cfa49 100644
--- a/drivers/gpio/gpio-tc3589x.c
+++ b/drivers/gpio/gpio-tc3589x.c
@@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(ret & BIT(pos));
+	if (ret & BIT(pos))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 8a01d3694b28..6fdfe4c5303e 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
 
 	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
 
-	return !(oe & pin_mask);
+	if (oe & pin_mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index 8a2a69178925..57185b96c110 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
 
 	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
 	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tegra186_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
index ddad5c7ea617..d08d86a22b1f 100644
--- a/drivers/gpio/gpio-thunderx.c
+++ b/drivers/gpio/gpio-thunderx.c
@@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
 
 	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
 
-	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
+	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int thunderx_gpio_set_config(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
index c8b34d787eed..99d5a84a9129 100644
--- a/drivers/gpio/gpio-tpic2810.c
+++ b/drivers/gpio/gpio-tpic2810.c
@@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
 				  unsigned offset)
 {
 	/* This device always output */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int tpic2810_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
index 2eea98ff4ea3..1e9d8262d0ff 100644
--- a/drivers/gpio/gpio-tps65086.c
+++ b/drivers/gpio/gpio-tps65086.c
@@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
 				       unsigned offset)
 {
 	/* This device is output only */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int tps65086_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
index 3ad68bd78282..510d9ed9fd2a 100644
--- a/drivers/gpio/gpio-tps65912.c
+++ b/drivers/gpio/gpio-tps65912.c
@@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
 		return ret;
 
 	if (val & GPIO_CFG_MASK)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 	else
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
index aff6e504c666..f7f5f770e0fb 100644
--- a/drivers/gpio/gpio-tps68470.c
+++ b/drivers/gpio/gpio-tps68470.c
@@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
 	return !!(val & BIT(offset));
 }
 
-/* Return 0 if output, 1 if input */
 static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 				       unsigned int offset)
 {
@@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 
 	/* rest are always outputs */
 	if (offset >= TPS68470_N_REGULAR_GPIO)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
 	if (ret) {
@@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 	}
 
 	val &= TPS68470_GPIO_MODE_MASK;
-	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
+	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
+						    GPIO_LINE_DIRECTION_IN;
 }
 
 static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
index a3109bcaa0ac..5022e0ad0fae 100644
--- a/drivers/gpio/gpio-tqmx86.c
+++ b/drivers/gpio/gpio-tqmx86.c
@@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
 static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned int offset)
 {
-	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
+	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static void tqmx86_gpio_irq_mask(struct irq_data *data)
diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
index 1da8d0586329..d885032cf814 100644
--- a/drivers/gpio/gpio-ts4900.c
+++ b/drivers/gpio/gpio-ts4900.c
@@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
 
 	regmap_read(priv->regmap, offset, &reg);
 
-	return !(reg & TS4900_GPIO_OE);
+	if (reg & TS4900_GPIO_OE)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int ts4900_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index fbfb648d3502..de249726230e 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
 	if (ret < 0)
 		return ret;
 
-	/* 1 = output, but gpiolib semantics are inverse so invert */
-	ret = !(ret & d_msk);
+	if (ret & d_msk)
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return ret;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int twl4030_set_gpio_dataout(int gpio, int enable)
@@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
 	/*
-	 * Default 0 = output
+	 * Default GPIO_LINE_DIRECTION_OUT
 	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
 	 */
-	int ret = 0;
+	int ret = GPIO_LINE_DIRECTION_OUT;
 
 	mutex_lock(&priv->mutex);
 	if (offset < TWL4030_GPIO_MAX) {
diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
index c845b2ff1f43..648fb418d775 100644
--- a/drivers/gpio/gpio-twl6040.c
+++ b/drivers/gpio/gpio-twl6040.c
@@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
 
 static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	/* This means "out" */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
index 93cdcc41e9fb..bd203e8fa58e 100644
--- a/drivers/gpio/gpio-uniphier.c
+++ b/drivers/gpio/gpio-uniphier.c
@@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
 static int uniphier_gpio_get_direction(struct gpio_chip *chip,
 				       unsigned int offset)
 {
-	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
+	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int uniphier_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index 444fe9e7f04a..8b481b3c1ebe 100644
--- a/drivers/gpio/gpio-wcove.c
+++ b/drivers/gpio/gpio-wcove.c
@@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
 	int ret, reg = to_reg(gpio, CTRL_OUT);
 
 	if (reg < 0)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	ret = regmap_read(wg->regmap, reg, &val);
 	if (ret)
 		return ret;
 
-	return !(val & CTLO_DIR_OUT);
+	if (val & CTLO_DIR_OUT)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index e0ef66b6a237..fe456bea81f6 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	const unsigned port = offset / 8;
 	const unsigned mask = BIT(offset % 8);
 
-	return !!(ws16c48gpio->io_state[port] & mask);
+	if (ws16c48gpio->io_state[port] & mask)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
index a6e66ac18e1f..532b0df8a1f2 100644
--- a/drivers/gpio/gpio-xgene.c
+++ b/drivers/gpio/gpio-xgene.c
@@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
 	bit_offset = GPIO_BIT_OFFSET(offset);
 
-	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
+	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
index 05f1998c11a4..31b5072b2df0 100644
--- a/drivers/gpio/gpio-xra1403.c
+++ b/drivers/gpio/gpio-xra1403.c
@@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
 	if (ret)
 		return ret;
 
-	return !!(val & BIT(offset % 8));
+	if (val & BIT(offset % 8))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
index 43d3fa5f511a..08d7c3b32038 100644
--- a/drivers/gpio/gpio-xtensa.c
+++ b/drivers/gpio/gpio-xtensa.c
@@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
 
 static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
 {
-	return 1; /* input only */
+	return GPIO_LINE_DIRECTION_IN; /* input only */
 }
 
 static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
@@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
 
 static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
 {
-	return 0; /* output only */
+	return GPIO_LINE_DIRECTION_OUT; /* output only */
 }
 
 static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index cd475ff4bcad..4c3f6370eab4 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
  *
  * This function returns the direction of the specified GPIO.
  *
- * Return: 0 for output, 1 for input
+ * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
  */
 static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 {
@@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 
 	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
 
-	return !(reg & BIT(bank_pin_num));
+	if (reg & BIT(bank_pin_num))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 /**
-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
@ 2019-11-06  8:54   ` Matti Vaittinen
  0 siblings, 0 replies; 52+ messages in thread
From: Matti Vaittinen @ 2019-11-06  8:54 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Jonathan Hunter, Fabio Estevam, linux-stm32, Marek Vasut,
	Florian Fainelli, Kevin Hilman, Michal Simek, Marek Behun,
	Bartosz Golaszewski, Ludovic Desroches, bcm-kernel-feedback-list,
	Joel Stanley, Uwe Kleine-König, Bamvor Jian Zhang,
	NXP Linux Team, linux-pwm, Grygorii Strashko, Charles Keepax,
	Maxime Coquelin, linux-omap, Alexandre Torgue, Ray Jui,
	Sascha Hauer, William Breathitt Gray, linux-gpio,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	Andy Shevchenko, linux-arm-kernel, Scott Branden,
	Masahiro Yamada, Andrew Jeffery, Enrico Weigelt,
	metux IT consult, linux-kernel, linux-renesas-soc,
	Thorsten Scherer, Pengutronix Kernel Team, patches, Shawn Guo

It's hard for occasional GPIO code reader/writer to know if values 0/1
equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
GPIO_LINE_DIRECTION_OUT to help them out.

NOTE - for gpio-amd-fch and gpio-bd9571mwv:
This commit also changes the return value for direction get to equal 1
for direction INPUT. Prior this commit these drivers might have
returned some other positive value but 1 for INPUT.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Scott Branden <scott.branden@broadcom.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

---

This patch contains same changes as v1 patches 2-61 did. v1 was splitted
into small patches in order to help reviewing but squashing was
requested by Linus Walleij. I maintained all acks/reviewed-by tags from
v1 series - so acks/review-by tags in this patch mean that specific
portion of changes have been acked/reviewed by tagger. Eg, whole patch
has not been reviewed/acked by persons mentioned. Please let me know if
this is not Ok to you.

 drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
 drivers/gpio/gpio-104-idi-48.c      |  2 +-
 drivers/gpio/gpio-104-idio-16.c     |  4 ++--
 drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
 drivers/gpio/gpio-amd-fch.c         |  2 +-
 drivers/gpio/gpio-aspeed.c          |  7 +++----
 drivers/gpio/gpio-bcm-kona.c        |  6 +++---
 drivers/gpio/gpio-bd70528.c         |  8 +++++---
 drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
 drivers/gpio/gpio-dln2.c            |  6 +++---
 drivers/gpio/gpio-exar.c            |  5 ++++-
 drivers/gpio/gpio-f7188x.c          |  5 ++++-
 drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
 drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
 drivers/gpio/gpio-ich.c             |  5 ++++-
 drivers/gpio/gpio-kempld.c          |  5 ++++-
 drivers/gpio/gpio-lp873x.c          |  2 +-
 drivers/gpio/gpio-lp87565.c         |  5 ++++-
 drivers/gpio/gpio-madera.c          |  5 ++++-
 drivers/gpio/gpio-max3191x.c        |  2 +-
 drivers/gpio/gpio-merrifield.c      |  5 ++++-
 drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
 drivers/gpio/gpio-mockup.c          | 11 +++--------
 drivers/gpio/gpio-moxtet.c          |  4 ++--
 drivers/gpio/gpio-mvebu.c           |  5 ++++-
 drivers/gpio/gpio-mxs.c             |  5 ++++-
 drivers/gpio/gpio-omap.c            |  6 ++++--
 drivers/gpio/gpio-pca953x.c         |  5 ++++-
 drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
 drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
 drivers/gpio/gpio-pisosr.c          |  2 +-
 drivers/gpio/gpio-pl061.c           |  5 ++++-
 drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
 drivers/gpio/gpio-rcar.c            |  5 ++++-
 drivers/gpio/gpio-reg.c             |  3 ++-
 drivers/gpio/gpio-sa1100.c          |  5 ++++-
 drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
 drivers/gpio/gpio-sch.c             |  5 ++++-
 drivers/gpio/gpio-sch311x.c         |  5 ++++-
 drivers/gpio/gpio-siox.c            |  4 ++--
 drivers/gpio/gpio-stmpe.c           |  5 ++++-
 drivers/gpio/gpio-tc3589x.c         |  5 ++++-
 drivers/gpio/gpio-tegra.c           |  5 ++++-
 drivers/gpio/gpio-tegra186.c        |  4 ++--
 drivers/gpio/gpio-thunderx.c        |  5 ++++-
 drivers/gpio/gpio-tpic2810.c        |  2 +-
 drivers/gpio/gpio-tps65086.c        |  2 +-
 drivers/gpio/gpio-tps65912.c        |  4 ++--
 drivers/gpio/gpio-tps68470.c        |  6 +++---
 drivers/gpio/gpio-tqmx86.c          |  5 ++++-
 drivers/gpio/gpio-ts4900.c          |  5 ++++-
 drivers/gpio/gpio-twl4030.c         | 10 +++++-----
 drivers/gpio/gpio-twl6040.c         |  3 +--
 drivers/gpio/gpio-uniphier.c        |  5 ++++-
 drivers/gpio/gpio-wcove.c           |  7 +++++--
 drivers/gpio/gpio-ws16c48.c         |  5 ++++-
 drivers/gpio/gpio-xgene.c           |  5 ++++-
 drivers/gpio/gpio-xra1403.c         |  5 ++++-
 drivers/gpio/gpio-xtensa.c          |  4 ++--
 drivers/gpio/gpio-zynq.c            |  7 +++++--
 60 files changed, 211 insertions(+), 102 deletions(-)

diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index a44fa8af5b0d..400c09b905f8 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	const unsigned port = offset / 8;
 	const unsigned mask = BIT(offset % 8);
 
-	return !!(dio48egpio->io_state[port] & mask);
+	if (dio48egpio->io_state[port] & mask)
+		return  GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index 79dead61e776..c50329ab493a 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -53,7 +53,7 @@ struct idi_48_gpio {
 
 static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
index 8d2f51cd9d91..5752d9dab148 100644
--- a/drivers/gpio/gpio-104-idio-16.c
+++ b/drivers/gpio/gpio-104-idio-16.c
@@ -51,9 +51,9 @@ struct idio_16_gpio {
 static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	if (offset > 15)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
index 83a2286d93f6..173e06758e6c 100644
--- a/drivers/gpio/gpio-74xx-mmio.c
+++ b/drivers/gpio/gpio-74xx-mmio.c
@@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
 
-	return !(priv->flags & MMIO_74XX_DIR_OUT);
+	if (priv->flags & MMIO_74XX_DIR_OUT)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return  GPIO_LINE_DIRECTION_IN;
 }
 
 static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
index 181df1581df5..4e44ba4d7423 100644
--- a/drivers/gpio/gpio-amd-fch.c
+++ b/drivers/gpio/gpio-amd-fch.c
@@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
 	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
 	spin_unlock_irqrestore(&priv->lock, flags);
 
-	return ret;
+	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
 }
 
 static void amd_fch_gpio_set(struct gpio_chip *gc,
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
index 09e53c5f3b0a..f1037b61f763 100644
--- a/drivers/gpio/gpio-aspeed.c
+++ b/drivers/gpio/gpio-aspeed.c
@@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 	u32 val;
 
 	if (!have_input(gpio, offset))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	if (!have_output(gpio, offset))
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
 	spin_lock_irqsave(&gpio->lock, flags);
 
@@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 
 	spin_unlock_irqrestore(&gpio->lock, flags);
 
-	return !val;
-
+	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
 }
 
 static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index 9fa6d3a967d2..4122683eb1f9 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
@@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
 	u32 val;
 
 	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
-	return !!val;
+	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
 }
 
 static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
@@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
 	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
 
 	/* this function only applies to output pin */
-	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
+	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
 		goto out;
 
 	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
@@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
 	reg_base = kona_gpio->reg_base;
 	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
 
-	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
+	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
 		reg_offset = GPIO_IN_STATUS(bank_id);
 	else
 		reg_offset = GPIO_OUT_STATUS(bank_id);
diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
index 0c1ead12d883..734be6b752d0 100644
--- a/drivers/gpio/gpio-bd70528.c
+++ b/drivers/gpio/gpio-bd70528.c
@@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
 		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
 		return ret;
 	}
+	if (val & BD70528_GPIO_OUT_EN_MASK)
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return !(val & BD70528_GPIO_OUT_EN_MASK);
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
@@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	 * locking would make no sense.
 	 */
 	ret = bd70528_get_direction(chip, offset);
-	if (ret == 0)
+	if (ret == GPIO_LINE_DIRECTION_OUT)
 		ret = bd70528_gpio_get_o(bdgpio, offset);
-	else if (ret == 1)
+	else if (ret == GPIO_LINE_DIRECTION_IN)
 		ret = bd70528_gpio_get_i(bdgpio, offset);
 	else
 		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
index 5224a946e8ab..c0abc9c6851b 100644
--- a/drivers/gpio/gpio-bd9571mwv.c
+++ b/drivers/gpio/gpio-bd9571mwv.c
@@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
 	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
 	if (ret < 0)
 		return ret;
+	if (val & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
 
-	return val & BIT(offset);
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
index 8a33c2fc174d..26b40c8b8a12 100644
--- a/drivers/gpio/gpio-dln2.c
+++ b/drivers/gpio/gpio-dln2.c
@@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
 
 	if (test_bit(offset, dln2->output_enabled))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
@@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	if (dir < 0)
 		return dir;
 
-	if (dir == 1)
+	if (dir == GPIO_LINE_DIRECTION_IN)
 		return dln2_gpio_pin_get_in_val(dln2, offset);
 
 	return dln2_gpio_pin_get_out_val(dln2, offset);
diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index fae327d5b06e..da1ef0b1c291 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
 		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
 	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
 
-	return !!(exar_get(chip, addr) & BIT(bit));
+	if (exar_get(chip, addr) & BIT(bit))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
index fdc639f856f1..cadd02993539 100644
--- a/drivers/gpio/gpio-f7188x.c
+++ b/drivers/gpio/gpio-f7188x.c
@@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 
 	superio_exit(sio->addr);
 
-	return !(dir & 1 << offset);
+	if (dir & 1 << offset)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
index 78a1db24e931..c22d6f94129c 100644
--- a/drivers/gpio/gpio-gpio-mm.c
+++ b/drivers/gpio/gpio-gpio-mm.c
@@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
 	const unsigned int port = offset / 8;
 	const unsigned int mask = BIT(offset % 8);
 
-	return !!(gpiommgpio->io_state[port] & mask);
+	if (gpiommgpio->io_state[port] & mask)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
index 8aa23d70b1e6..a40bd56673fe 100644
--- a/drivers/gpio/gpio-htc-egpio.c
+++ b/drivers/gpio/gpio-htc-egpio.c
@@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
 
 	egpio = gpiochip_get_data(chip);
 
-	return !test_bit(offset, &egpio->is_out);
+	if (test_bit(offset, &egpio->is_out))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static void egpio_write_cache(struct egpio_info *ei)
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index 90bf7742f9b0..2f086d0aa1f4 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
 
 static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
 {
-	return ichx_read_bit(GPIO_IO_SEL, nr);
+	if (ichx_read_bit(GPIO_IO_SEL, nr))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index ef51638f3f75..4ea15f08e0f4 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
 	struct kempld_device_data *pld = gpio->pld;
 
-	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
+	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int kempld_gpio_pincount(struct kempld_device_data *pld)
diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
index 801995dd9b26..70fad87ff2db 100644
--- a/drivers/gpio/gpio-lp873x.c
+++ b/drivers/gpio/gpio-lp873x.c
@@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned int offset)
 {
 	/* This device is output only */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int lp873x_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
index a121c8f10610..e1244520cf7d 100644
--- a/drivers/gpio/gpio-lp87565.c
+++ b/drivers/gpio/gpio-lp87565.c
@@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(val & BIT(offset));
+	if (val & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int lp87565_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
index 7086f8b5388f..8f38303fcbc4 100644
--- a/drivers/gpio/gpio-madera.c
+++ b/drivers/gpio/gpio-madera.c
@@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !!(val & MADERA_GP1_DIR_MASK);
+	if (val & MADERA_GP1_DIR_MASK)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
index 4b4b2ceb82fc..0696d5a21431 100644
--- a/drivers/gpio/gpio-max3191x.c
+++ b/drivers/gpio/gpio-max3191x.c
@@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
 
 static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
 {
-	return 1; /* always in */
+	return GPIO_LINE_DIRECTION_IN; /* always in */
 }
 
 static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
index 2f1e9da81c1e..d4fa6e9560f3 100644
--- a/drivers/gpio/gpio-merrifield.c
+++ b/drivers/gpio/gpio-merrifield.c
@@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
 
-	return !(readl(gpdr) & BIT(offset % 32));
+	if (readl(gpdr) & BIT(offset % 32))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index 6f904c874678..cd07c948649f 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
 {
 	/* Return 0 if output, 1 if input */
-	if (gc->bgpio_dir_unreadable)
-		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
-	if (gc->reg_dir_out)
-		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
+	if (gc->bgpio_dir_unreadable) {
+		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
+			return GPIO_LINE_DIRECTION_OUT;
+		return GPIO_LINE_DIRECTION_IN;
+	}
+
+	if (gc->reg_dir_out) {
+		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
+			return GPIO_LINE_DIRECTION_OUT;
+		return GPIO_LINE_DIRECTION_IN;
+	}
+
 	if (gc->reg_dir_in)
-		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
+		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
+			return GPIO_LINE_DIRECTION_OUT;
 
 	/* This should not happen */
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 213aedc97dc2..47c172b2f5ad 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -34,14 +34,9 @@
 
 #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
 
-enum {
-	GPIO_MOCKUP_DIR_IN = 0,
-	GPIO_MOCKUP_DIR_OUT = 1,
-};
-
 /*
  * struct gpio_pin_status - structure describing a GPIO status
- * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
+ * @dir:       Configures direction of gpio as "in" or "out"
  * @value:     Configures status of the gpio as 0(low) or 1(high)
  */
 struct gpio_mockup_line_status {
@@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
 	mutex_lock(&chip->lock);
-	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
+	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
 	__gpio_mockup_set(chip, offset, value);
 	mutex_unlock(&chip->lock);
 
@@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
 	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
 
 	mutex_lock(&chip->lock);
-	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
+	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
 	mutex_unlock(&chip->lock);
 
 	return 0;
diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
index 3fd729994a38..8299909318f4 100644
--- a/drivers/gpio/gpio-moxtet.c
+++ b/drivers/gpio/gpio-moxtet.c
@@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 
 	/* All lines are hard wired to be either input or output, not both. */
 	if (chip->desc->in_mask & BIT(offset))
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 	else if (chip->desc->out_mask & BIT(offset))
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 	else
 		return -EINVAL;
 }
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 6c0687694341..9b2adf0ef880 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 
 	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
 
-	return !!(u & BIT(pin));
+	if (u & BIT(pin))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 5e5437a2c607..c4a314c68555 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
 	u32 dir;
 
 	dir = readl(port->base + PINCTRL_DOE(port));
-	return !(dir & mask);
+	if (dir & mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static const struct platform_device_id mxs_gpio_ids[] = {
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index d0f27084a942..3bd8adaeed9e 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_bank *bank = gpiochip_get_data(chip);
 
-	return !!(readl_relaxed(bank->base + bank->regs->direction) &
-		  BIT(offset));
+	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index de5d1383f28d..82122c3c688a 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
 	if (ret < 0)
 		return ret;
 
-	return !!(reg_val & bit);
+	if (reg_val & bit)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
index 5aa136a6a3e0..df51dd08bdfe 100644
--- a/drivers/gpio/gpio-pci-idio-16.c
+++ b/drivers/gpio/gpio-pci-idio-16.c
@@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
 	unsigned int offset)
 {
 	if (offset > 15)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int idio_16_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
index 52f1647a46fd..44c1e4fc489f 100644
--- a/drivers/gpio/gpio-pcie-idio-24.c
+++ b/drivers/gpio/gpio-pcie-idio-24.c
@@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
 
 	/* FET Outputs */
 	if (offset < 24)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	/* Isolated Inputs */
 	if (offset < 48)
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 
 	/* TTL/CMOS I/O */
 	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
-	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
+	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int idio_24_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
index f809a5a8e9eb..1331b2a94679 100644
--- a/drivers/gpio/gpio-pisosr.c
+++ b/drivers/gpio/gpio-pisosr.c
@@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned offset)
 {
 	/* This device always input */
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int pisosr_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 722ce5cf861e..5df7782e348f 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct pl061 *pl061 = gpiochip_get_data(gc);
 
-	return !(readb(pl061->base + GPIODIR) & BIT(offset));
+	if (readb(pl061->base + GPIODIR) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
index b77ea16ffa03..bb100e0124e6 100644
--- a/drivers/gpio/gpio-raspberrypi-exp.c
+++ b/drivers/gpio/gpio-raspberrypi-exp.c
@@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
 			get.gpio);
 		return ret ? ret : -EIO;
 	}
-	return !get.direction;
+	if (get.direction)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 187984d26f47..d7e6e68c25af 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
 
-	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
+	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
index fdc7a9d5b382..d35169bde25a 100644
--- a/drivers/gpio/gpio-reg.c
+++ b/drivers/gpio/gpio-reg.c
@@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	struct gpio_reg *r = to_gpio_reg(gc);
 
-	return r->direction & BIT(offset) ? 1 : 0;
+	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
+					    GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
index 46b7cf23fb0f..edff5e81489f 100644
--- a/drivers/gpio/gpio-sa1100.c
+++ b/drivers/gpio/gpio-sa1100.c
@@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
 
-	return !(readl_relaxed(gpdr) & BIT(offset));
+	if (readl_relaxed(gpdr) & BIT(offset))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
index 7d718557092e..b04c561f3280 100644
--- a/drivers/gpio/gpio-sama5d2-piobu.c
+++ b/drivers/gpio/gpio-sama5d2-piobu.c
@@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return (ret == PIOBU_IN) ? 1 : 0;
+	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
+				   GPIO_LINE_DIRECTION_OUT;
 }
 
 /**
@@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
 	/* if pin is input, read value from PDS else read from SOD */
 	int ret = sama5d2_piobu_get_direction(chip, pin);
 
-	if (ret == 1)
+	if (ret == GPIO_LINE_DIRECTION_IN)
 		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
-	else if (!ret)
+	else if (ret == GPIO_LINE_DIRECTION_OUT)
 		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
 
 	if (ret < 0)
diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
index fb143f28c386..c65f35b68202 100644
--- a/drivers/gpio/gpio-sch.c
+++ b/drivers/gpio/gpio-sch.c
@@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
 {
 	struct sch_gpio *sch = gpiochip_get_data(gc);
 
-	return sch_gpio_reg_get(sch, gpio_num, GIO);
+	if (sch_gpio_reg_get(sch, gpio_num, GIO))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static const struct gpio_chip sch_gpio_chip = {
diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
index 8ecf336c9af4..da01e1cad7cb 100644
--- a/drivers/gpio/gpio-sch311x.c
+++ b/drivers/gpio/gpio-sch311x.c
@@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	data = inb(block->runtime_reg + block->config_regs[offset]);
 	spin_unlock(&block->lock);
 
-	return !!(data & SCH311X_GPIO_CONF_DIR);
+	if (data & SCH311X_GPIO_CONF_DIR)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
index 006a7e6a75f2..311f66757b92 100644
--- a/drivers/gpio/gpio-siox.c
+++ b/drivers/gpio/gpio-siox.c
@@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
 static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
 {
 	if (offset < 12)
-		return 1; /* input */
+		return GPIO_LINE_DIRECTION_IN;
 	else
-		return 0; /* output */
+		return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int gpio_siox_probe(struct siox_device *sdevice)
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 994d542daf53..542706a852e6 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(ret & mask);
+	if (ret & mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int stmpe_gpio_direction_output(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
index 75b1135b383a..6be0684cfa49 100644
--- a/drivers/gpio/gpio-tc3589x.c
+++ b/drivers/gpio/gpio-tc3589x.c
@@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
 	if (ret < 0)
 		return ret;
 
-	return !(ret & BIT(pos));
+	if (ret & BIT(pos))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 8a01d3694b28..6fdfe4c5303e 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
 
 	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
 
-	return !(oe & pin_mask);
+	if (oe & pin_mask)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index 8a2a69178925..57185b96c110 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
 
 	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
 	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return 1;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tegra186_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
index ddad5c7ea617..d08d86a22b1f 100644
--- a/drivers/gpio/gpio-thunderx.c
+++ b/drivers/gpio/gpio-thunderx.c
@@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
 
 	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
 
-	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
+	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int thunderx_gpio_set_config(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
index c8b34d787eed..99d5a84a9129 100644
--- a/drivers/gpio/gpio-tpic2810.c
+++ b/drivers/gpio/gpio-tpic2810.c
@@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
 				  unsigned offset)
 {
 	/* This device always output */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int tpic2810_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
index 2eea98ff4ea3..1e9d8262d0ff 100644
--- a/drivers/gpio/gpio-tps65086.c
+++ b/drivers/gpio/gpio-tps65086.c
@@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
 				       unsigned offset)
 {
 	/* This device is output only */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int tps65086_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
index 3ad68bd78282..510d9ed9fd2a 100644
--- a/drivers/gpio/gpio-tps65912.c
+++ b/drivers/gpio/gpio-tps65912.c
@@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
 		return ret;
 
 	if (val & GPIO_CFG_MASK)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 	else
-		return 1;
+		return GPIO_LINE_DIRECTION_IN;
 }
 
 static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
index aff6e504c666..f7f5f770e0fb 100644
--- a/drivers/gpio/gpio-tps68470.c
+++ b/drivers/gpio/gpio-tps68470.c
@@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
 	return !!(val & BIT(offset));
 }
 
-/* Return 0 if output, 1 if input */
 static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 				       unsigned int offset)
 {
@@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 
 	/* rest are always outputs */
 	if (offset >= TPS68470_N_REGULAR_GPIO)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
 	if (ret) {
@@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
 	}
 
 	val &= TPS68470_GPIO_MODE_MASK;
-	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
+	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
+						    GPIO_LINE_DIRECTION_IN;
 }
 
 static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
index a3109bcaa0ac..5022e0ad0fae 100644
--- a/drivers/gpio/gpio-tqmx86.c
+++ b/drivers/gpio/gpio-tqmx86.c
@@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
 static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
 				     unsigned int offset)
 {
-	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
+	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static void tqmx86_gpio_irq_mask(struct irq_data *data)
diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
index 1da8d0586329..d885032cf814 100644
--- a/drivers/gpio/gpio-ts4900.c
+++ b/drivers/gpio/gpio-ts4900.c
@@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
 
 	regmap_read(priv->regmap, offset, &reg);
 
-	return !(reg & TS4900_GPIO_OE);
+	if (reg & TS4900_GPIO_OE)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int ts4900_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index fbfb648d3502..de249726230e 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
 	if (ret < 0)
 		return ret;
 
-	/* 1 = output, but gpiolib semantics are inverse so invert */
-	ret = !(ret & d_msk);
+	if (ret & d_msk)
+		return GPIO_LINE_DIRECTION_OUT;
 
-	return ret;
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int twl4030_set_gpio_dataout(int gpio, int enable)
@@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
 {
 	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
 	/*
-	 * Default 0 = output
+	 * Default GPIO_LINE_DIRECTION_OUT
 	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
 	 */
-	int ret = 0;
+	int ret = GPIO_LINE_DIRECTION_OUT;
 
 	mutex_lock(&priv->mutex);
 	if (offset < TWL4030_GPIO_MAX) {
diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
index c845b2ff1f43..648fb418d775 100644
--- a/drivers/gpio/gpio-twl6040.c
+++ b/drivers/gpio/gpio-twl6040.c
@@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
 
 static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-	/* This means "out" */
-	return 0;
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
index 93cdcc41e9fb..bd203e8fa58e 100644
--- a/drivers/gpio/gpio-uniphier.c
+++ b/drivers/gpio/gpio-uniphier.c
@@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
 static int uniphier_gpio_get_direction(struct gpio_chip *chip,
 				       unsigned int offset)
 {
-	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
+	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int uniphier_gpio_direction_input(struct gpio_chip *chip,
diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index 444fe9e7f04a..8b481b3c1ebe 100644
--- a/drivers/gpio/gpio-wcove.c
+++ b/drivers/gpio/gpio-wcove.c
@@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
 	int ret, reg = to_reg(gpio, CTRL_OUT);
 
 	if (reg < 0)
-		return 0;
+		return GPIO_LINE_DIRECTION_OUT;
 
 	ret = regmap_read(wg->regmap, reg, &val);
 	if (ret)
 		return ret;
 
-	return !(val & CTLO_DIR_OUT);
+	if (val & CTLO_DIR_OUT)
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index e0ef66b6a237..fe456bea81f6 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 	const unsigned port = offset / 8;
 	const unsigned mask = BIT(offset % 8);
 
-	return !!(ws16c48gpio->io_state[port] & mask);
+	if (ws16c48gpio->io_state[port] & mask)
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
index a6e66ac18e1f..532b0df8a1f2 100644
--- a/drivers/gpio/gpio-xgene.c
+++ b/drivers/gpio/gpio-xgene.c
@@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
 	bit_offset = GPIO_BIT_OFFSET(offset);
 
-	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
+	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
index 05f1998c11a4..31b5072b2df0 100644
--- a/drivers/gpio/gpio-xra1403.c
+++ b/drivers/gpio/gpio-xra1403.c
@@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
 	if (ret)
 		return ret;
 
-	return !!(val & BIT(offset % 8));
+	if (val & BIT(offset % 8))
+		return GPIO_LINE_DIRECTION_IN;
+
+	return GPIO_LINE_DIRECTION_OUT;
 }
 
 static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
index 43d3fa5f511a..08d7c3b32038 100644
--- a/drivers/gpio/gpio-xtensa.c
+++ b/drivers/gpio/gpio-xtensa.c
@@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
 
 static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
 {
-	return 1; /* input only */
+	return GPIO_LINE_DIRECTION_IN; /* input only */
 }
 
 static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
@@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
 
 static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
 {
-	return 0; /* output only */
+	return GPIO_LINE_DIRECTION_OUT; /* output only */
 }
 
 static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index cd475ff4bcad..4c3f6370eab4 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
  *
  * This function returns the direction of the specified GPIO.
  *
- * Return: 0 for output, 1 for input
+ * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
  */
 static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 {
@@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
 
 	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
 
-	return !(reg & BIT(bank_pin_num));
+	if (reg & BIT(bank_pin_num))
+		return GPIO_LINE_DIRECTION_OUT;
+
+	return GPIO_LINE_DIRECTION_IN;
 }
 
 /**
-- 
2.21.0


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-06  8:51 ` [alsa-devel] " Matti Vaittinen
  (?)
@ 2019-11-06 12:08   ` Sebastian Reichel
  -1 siblings, 0 replies; 52+ messages in thread
From: Sebastian Reichel @ 2019-11-06 12:08 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: alsa-devel, linux-aspeed, David Daney, Linus Walleij,
	Kuppuswamy Sathyanarayanan, Andy Shevchenko, Peter Tyser,
	Thierry Reding, Shawn Guo, Marek Behun, Fabio Estevam,
	linux-stm32, Marek Vasut, Florian Fainelli, Kevin Hilman,
	Michal Simek, Jonathan Hunter, Bartosz Golaszewski,
	Ludovic Desroches, Bamvor Jian Zhang, Joel Stanley, Uwe


[-- Attachment #1.1: Type: text/plain, Size: 2820 bytes --]

Hi,

On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> The patch series adds definitions for GPIO line directions.
> 
> For occasional GPIO contributor like me it is always a pain to remember
> whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
> fact that I removed few comments like:
> 
> /* Return 0 if output, 1 if input */
> /* This means "out" */
> return 1; /* input */
> return 0; /* output */
> 
> it seems at least some others may find it hard to remember too. Adding
> defines for these values helps us who really have good - but short
> duration - memory :]
> 
> This idea comes from RFC series for ROHM BD71828 PMIC and was initially
> discussed with Linus Walleij here:
> https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
> but as this has no dependencies to BD71828 work (which probably takes a
> while) I decided to make it independent series.
> 
> Patches are compile-tested only. I have no HW to really test them. Thus I'd
> appreciate carefull review. This work is mainly about converting zeros
> and ones to the new defines but it wouldn't be first time I get it
> wrong.
> 
> Changelog v2:
>  - squashed patches 2-61 into patch 2.
>  - dropped patch 62 (can be applied later)
>  - rebased (cherry-picked) changes on top of GPIO devel branch.
> 
> Patch 1:
>  - adds the defines
> Patch 2:
>  - convert drivers to use new defines
> 
> This patch series is based on GPIO tree devel branch.
> 
> ---
> 
> Matti Vaittinen (2):
>   gpio: Add definition for GPIO direction
>   gpio: Use new GPIO_LINE_DIRECTION
> 
>  drivers/gpio/*
>  include/linux/gpio/driver.h         |  3 +++
>  61 files changed, 214 insertions(+), 102 deletions(-)

Maybe also update the GPIO drivers in pinctrl?

$ git grep -l gpio_get_direction drivers/pinctrl
drivers/pinctrl/bcm/pinctrl-bcm2835.c
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
drivers/pinctrl/intel/pinctrl-baytrail.c
drivers/pinctrl/intel/pinctrl-cherryview.c
drivers/pinctrl/intel/pinctrl-intel.c
drivers/pinctrl/mediatek/pinctrl-mtk-common.c
drivers/pinctrl/mediatek/pinctrl-paris.c
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
drivers/pinctrl/pinctrl-amd.c
drivers/pinctrl/pinctrl-at91.c
drivers/pinctrl/pinctrl-axp209.c
drivers/pinctrl/pinctrl-ingenic.c
drivers/pinctrl/pinctrl-ocelot.c
drivers/pinctrl/pinctrl-oxnas.c
drivers/pinctrl/pinctrl-pic32.c
drivers/pinctrl/pinctrl-pistachio.c
drivers/pinctrl/pinctrl-rk805.c
drivers/pinctrl/pinctrl-rockchip.c
drivers/pinctrl/pinctrl-rza1.c
drivers/pinctrl/pinctrl-st.c
drivers/pinctrl/pinctrl-stmfx.c
drivers/pinctrl/pinctrl-sx150x.c
drivers/pinctrl/qcom/pinctrl-msm.c
drivers/pinctrl/stm32/pinctrl-stm32.c
drivers/pinctrl/vt8500/pinctrl-wmt.c

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [alsa-devel] [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 12:08   ` Sebastian Reichel
  0 siblings, 0 replies; 52+ messages in thread
From: Sebastian Reichel @ 2019-11-06 12:08 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: alsa-devel, linux-aspeed, David Daney, Linus Walleij,
	Kuppuswamy Sathyanarayanan, Andy Shevchenko, Peter Tyser,
	Thierry Reding, Shawn Guo, Marek Behun, Fabio Estevam,
	linux-stm32, Marek Vasut, Florian Fainelli, Kevin Hilman,
	Michal Simek, Jonathan Hunter, Bartosz Golaszewski,
	Ludovic Desroches, Bamvor Jian Zhang, Joel Stanley,
	Uwe Kleine-König, bcm-kernel-feedback-list, NXP Linux Team,
	linux-pwm, Grygorii Strashko, Charles Keepax, Alexandre Torgue,
	mazziesaccount, Ray Jui, Sascha Hauer, William Breathitt Gray,
	linux-gpio, Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	linux-omap, Pengutronix Kernel Team, linux-arm-kernel,
	Scott Branden, Masahiro Yamada, Andrew Jeffery, patches,
	linux-kernel, linux-renesas-soc, Thorsten Scherer,
	Maxime Coquelin, Enrico Weigelt, metux IT consult


[-- Attachment #1.1: Type: text/plain, Size: 2820 bytes --]

Hi,

On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> The patch series adds definitions for GPIO line directions.
> 
> For occasional GPIO contributor like me it is always a pain to remember
> whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
> fact that I removed few comments like:
> 
> /* Return 0 if output, 1 if input */
> /* This means "out" */
> return 1; /* input */
> return 0; /* output */
> 
> it seems at least some others may find it hard to remember too. Adding
> defines for these values helps us who really have good - but short
> duration - memory :]
> 
> This idea comes from RFC series for ROHM BD71828 PMIC and was initially
> discussed with Linus Walleij here:
> https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
> but as this has no dependencies to BD71828 work (which probably takes a
> while) I decided to make it independent series.
> 
> Patches are compile-tested only. I have no HW to really test them. Thus I'd
> appreciate carefull review. This work is mainly about converting zeros
> and ones to the new defines but it wouldn't be first time I get it
> wrong.
> 
> Changelog v2:
>  - squashed patches 2-61 into patch 2.
>  - dropped patch 62 (can be applied later)
>  - rebased (cherry-picked) changes on top of GPIO devel branch.
> 
> Patch 1:
>  - adds the defines
> Patch 2:
>  - convert drivers to use new defines
> 
> This patch series is based on GPIO tree devel branch.
> 
> ---
> 
> Matti Vaittinen (2):
>   gpio: Add definition for GPIO direction
>   gpio: Use new GPIO_LINE_DIRECTION
> 
>  drivers/gpio/*
>  include/linux/gpio/driver.h         |  3 +++
>  61 files changed, 214 insertions(+), 102 deletions(-)

Maybe also update the GPIO drivers in pinctrl?

$ git grep -l gpio_get_direction drivers/pinctrl
drivers/pinctrl/bcm/pinctrl-bcm2835.c
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
drivers/pinctrl/intel/pinctrl-baytrail.c
drivers/pinctrl/intel/pinctrl-cherryview.c
drivers/pinctrl/intel/pinctrl-intel.c
drivers/pinctrl/mediatek/pinctrl-mtk-common.c
drivers/pinctrl/mediatek/pinctrl-paris.c
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
drivers/pinctrl/pinctrl-amd.c
drivers/pinctrl/pinctrl-at91.c
drivers/pinctrl/pinctrl-axp209.c
drivers/pinctrl/pinctrl-ingenic.c
drivers/pinctrl/pinctrl-ocelot.c
drivers/pinctrl/pinctrl-oxnas.c
drivers/pinctrl/pinctrl-pic32.c
drivers/pinctrl/pinctrl-pistachio.c
drivers/pinctrl/pinctrl-rk805.c
drivers/pinctrl/pinctrl-rockchip.c
drivers/pinctrl/pinctrl-rza1.c
drivers/pinctrl/pinctrl-st.c
drivers/pinctrl/pinctrl-stmfx.c
drivers/pinctrl/pinctrl-sx150x.c
drivers/pinctrl/qcom/pinctrl-msm.c
drivers/pinctrl/stm32/pinctrl-stm32.c
drivers/pinctrl/vt8500/pinctrl-wmt.c

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 12:08   ` Sebastian Reichel
  0 siblings, 0 replies; 52+ messages in thread
From: Sebastian Reichel @ 2019-11-06 12:08 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: alsa-devel, linux-aspeed, David Daney, Linus Walleij,
	Kuppuswamy Sathyanarayanan, Andy Shevchenko, Peter Tyser,
	Thierry Reding, Shawn Guo, Marek Behun, Fabio Estevam,
	linux-stm32, Marek Vasut, Florian Fainelli, Kevin Hilman,
	Michal Simek, Jonathan Hunter, Bartosz Golaszewski,
	Ludovic Desroches, Bamvor Jian Zhang, Joel Stanley,
	Uwe Kleine-König, bcm-kernel-feedback-list, NXP Linux Team,
	linux-pwm, Grygorii Strashko, Charles Keepax, Alexandre Torgue,
	mazziesaccount, Ray Jui, Sascha Hauer, William Breathitt Gray,
	linux-gpio, Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	linux-omap, Pengutronix Kernel Team, linux-arm-kernel,
	Scott Branden, Masahiro Yamada, Andrew Jeffery, patches,
	linux-kernel, linux-renesas-soc, Thorsten Scherer,
	Maxime Coquelin, Enrico Weigelt, metux IT consult


[-- Attachment #1.1: Type: text/plain, Size: 2820 bytes --]

Hi,

On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> The patch series adds definitions for GPIO line directions.
> 
> For occasional GPIO contributor like me it is always a pain to remember
> whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
> fact that I removed few comments like:
> 
> /* Return 0 if output, 1 if input */
> /* This means "out" */
> return 1; /* input */
> return 0; /* output */
> 
> it seems at least some others may find it hard to remember too. Adding
> defines for these values helps us who really have good - but short
> duration - memory :]
> 
> This idea comes from RFC series for ROHM BD71828 PMIC and was initially
> discussed with Linus Walleij here:
> https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
> but as this has no dependencies to BD71828 work (which probably takes a
> while) I decided to make it independent series.
> 
> Patches are compile-tested only. I have no HW to really test them. Thus I'd
> appreciate carefull review. This work is mainly about converting zeros
> and ones to the new defines but it wouldn't be first time I get it
> wrong.
> 
> Changelog v2:
>  - squashed patches 2-61 into patch 2.
>  - dropped patch 62 (can be applied later)
>  - rebased (cherry-picked) changes on top of GPIO devel branch.
> 
> Patch 1:
>  - adds the defines
> Patch 2:
>  - convert drivers to use new defines
> 
> This patch series is based on GPIO tree devel branch.
> 
> ---
> 
> Matti Vaittinen (2):
>   gpio: Add definition for GPIO direction
>   gpio: Use new GPIO_LINE_DIRECTION
> 
>  drivers/gpio/*
>  include/linux/gpio/driver.h         |  3 +++
>  61 files changed, 214 insertions(+), 102 deletions(-)

Maybe also update the GPIO drivers in pinctrl?

$ git grep -l gpio_get_direction drivers/pinctrl
drivers/pinctrl/bcm/pinctrl-bcm2835.c
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
drivers/pinctrl/intel/pinctrl-baytrail.c
drivers/pinctrl/intel/pinctrl-cherryview.c
drivers/pinctrl/intel/pinctrl-intel.c
drivers/pinctrl/mediatek/pinctrl-mtk-common.c
drivers/pinctrl/mediatek/pinctrl-paris.c
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
drivers/pinctrl/pinctrl-amd.c
drivers/pinctrl/pinctrl-at91.c
drivers/pinctrl/pinctrl-axp209.c
drivers/pinctrl/pinctrl-ingenic.c
drivers/pinctrl/pinctrl-ocelot.c
drivers/pinctrl/pinctrl-oxnas.c
drivers/pinctrl/pinctrl-pic32.c
drivers/pinctrl/pinctrl-pistachio.c
drivers/pinctrl/pinctrl-rk805.c
drivers/pinctrl/pinctrl-rockchip.c
drivers/pinctrl/pinctrl-rza1.c
drivers/pinctrl/pinctrl-st.c
drivers/pinctrl/pinctrl-stmfx.c
drivers/pinctrl/pinctrl-sx150x.c
drivers/pinctrl/qcom/pinctrl-msm.c
drivers/pinctrl/stm32/pinctrl-stm32.c
drivers/pinctrl/vt8500/pinctrl-wmt.c

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-06 12:08   ` [alsa-devel] " Sebastian Reichel
  (?)
@ 2019-11-06 12:25     ` Vaittinen, Matti
  -1 siblings, 0 replies; 52+ messages in thread
From: Vaittinen, Matti @ 2019-11-06 12:25 UTC (permalink / raw)
  To: sre
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, ptyser, thierry.reding, marek.behun,
	festevam, linux-stm32, marek.vasut+renesas, f.fainelli, khilman,
	michal.simek, jonathanh


On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> Hi,
> 
> On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > The patch series adds definitions for GPIO line directions.
> > 
> > For occasional GPIO contributor like me it is always a pain to
> > remember
> > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> 
> Maybe also update the GPIO drivers in pinctrl?
> 
> $ git grep -l gpio_get_direction drivers/pinctrl
> drivers/pinctrl/bcm/pinctrl-bcm2835.c
> drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> drivers/pinctrl/intel/pinctrl-baytrail.c
> drivers/pinctrl/intel/pinctrl-cherryview.c
> drivers/pinctrl/intel/pinctrl-intel.c
> drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> drivers/pinctrl/mediatek/pinctrl-paris.c
> drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> drivers/pinctrl/pinctrl-amd.c
> drivers/pinctrl/pinctrl-at91.c
> drivers/pinctrl/pinctrl-axp209.c
> drivers/pinctrl/pinctrl-ingenic.c
> drivers/pinctrl/pinctrl-ocelot.c
> drivers/pinctrl/pinctrl-oxnas.c
> drivers/pinctrl/pinctrl-pic32.c
> drivers/pinctrl/pinctrl-pistachio.c
> drivers/pinctrl/pinctrl-rk805.c
> drivers/pinctrl/pinctrl-rockchip.c
> drivers/pinctrl/pinctrl-rza1.c
> drivers/pinctrl/pinctrl-st.c
> drivers/pinctrl/pinctrl-stmfx.c
> drivers/pinctrl/pinctrl-sx150x.c
> drivers/pinctrl/qcom/pinctrl-msm.c
> drivers/pinctrl/stm32/pinctrl-stm32.c
> drivers/pinctrl/vt8500/pinctrl-wmt.c

Ouch. I didn't check from pinctrl but I see those should be converted
as well. I'm a bit short on time right now so if anyone else is
interested I won't mind :)

Luckily the value for IN and OUT is not changed - only the defines were
added - so all of the drivers do not need to be done at once. If no one
else will take the pinctrl part then I can probably do pinctrl patches
for v5.6 cycle.

Br,
	Matti Vaittinen

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

* Re: [alsa-devel] [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 12:25     ` Vaittinen, Matti
  0 siblings, 0 replies; 52+ messages in thread
From: Vaittinen, Matti @ 2019-11-06 12:25 UTC (permalink / raw)
  To: sre
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, ptyser, thierry.reding, marek.behun,
	festevam, linux-stm32, marek.vasut+renesas, f.fainelli, khilman,
	michal.simek, jonathanh, bgolaszewski, linux-omap, bamv2005,
	joel, u.kleine-koenig, bcm-kernel-feedback-list, linux-imx,
	linux-pwm, grygorii.strashko, ckeepax, alexandre.torgue,
	mazziesaccount, rjui, s.hauer, vilhelm.gray, linux-gpio, rf,
	ssantosh, linux-tegra, andriy.shevchenko, kernel,
	linux-arm-kernel, sbranden, yamada.masahiro, andrew, info,
	linux-kernel, linux-renesas-soc, t.scherer, ludovic.desroches,
	mcoquelin.stm32, patches, shawnguo


On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> Hi,
> 
> On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > The patch series adds definitions for GPIO line directions.
> > 
> > For occasional GPIO contributor like me it is always a pain to
> > remember
> > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> 
> Maybe also update the GPIO drivers in pinctrl?
> 
> $ git grep -l gpio_get_direction drivers/pinctrl
> drivers/pinctrl/bcm/pinctrl-bcm2835.c
> drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> drivers/pinctrl/intel/pinctrl-baytrail.c
> drivers/pinctrl/intel/pinctrl-cherryview.c
> drivers/pinctrl/intel/pinctrl-intel.c
> drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> drivers/pinctrl/mediatek/pinctrl-paris.c
> drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> drivers/pinctrl/pinctrl-amd.c
> drivers/pinctrl/pinctrl-at91.c
> drivers/pinctrl/pinctrl-axp209.c
> drivers/pinctrl/pinctrl-ingenic.c
> drivers/pinctrl/pinctrl-ocelot.c
> drivers/pinctrl/pinctrl-oxnas.c
> drivers/pinctrl/pinctrl-pic32.c
> drivers/pinctrl/pinctrl-pistachio.c
> drivers/pinctrl/pinctrl-rk805.c
> drivers/pinctrl/pinctrl-rockchip.c
> drivers/pinctrl/pinctrl-rza1.c
> drivers/pinctrl/pinctrl-st.c
> drivers/pinctrl/pinctrl-stmfx.c
> drivers/pinctrl/pinctrl-sx150x.c
> drivers/pinctrl/qcom/pinctrl-msm.c
> drivers/pinctrl/stm32/pinctrl-stm32.c
> drivers/pinctrl/vt8500/pinctrl-wmt.c

Ouch. I didn't check from pinctrl but I see those should be converted
as well. I'm a bit short on time right now so if anyone else is
interested I won't mind :)

Luckily the value for IN and OUT is not changed - only the defines were
added - so all of the drivers do not need to be done at once. If no one
else will take the pinctrl part then I can probably do pinctrl patches
for v5.6 cycle.

Br,
	Matti Vaittinen
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 12:25     ` Vaittinen, Matti
  0 siblings, 0 replies; 52+ messages in thread
From: Vaittinen, Matti @ 2019-11-06 12:25 UTC (permalink / raw)
  To: sre
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, ptyser, thierry.reding, marek.behun,
	festevam, linux-stm32, marek.vasut+renesas, f.fainelli, khilman,
	michal.simek, jonathanh, bgolaszewski, linux-omap, bamv2005,
	joel, u.kleine-koenig, bcm-kernel-feedback-list, linux-imx,
	linux-pwm, grygorii.strashko, ckeepax, alexandre.torgue,
	mazziesaccount, rjui, s.hauer, vilhelm.gray, linux-gpio, rf,
	ssantosh, linux-tegra, andriy.shevchenko, kernel,
	linux-arm-kernel, sbranden, yamada.masahiro, andrew, info,
	linux-kernel, linux-renesas-soc, t.scherer, ludovic.desroches,
	mcoquelin.stm32, patches, shawnguo


On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> Hi,
> 
> On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > The patch series adds definitions for GPIO line directions.
> > 
> > For occasional GPIO contributor like me it is always a pain to
> > remember
> > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> 
> Maybe also update the GPIO drivers in pinctrl?
> 
> $ git grep -l gpio_get_direction drivers/pinctrl
> drivers/pinctrl/bcm/pinctrl-bcm2835.c
> drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> drivers/pinctrl/intel/pinctrl-baytrail.c
> drivers/pinctrl/intel/pinctrl-cherryview.c
> drivers/pinctrl/intel/pinctrl-intel.c
> drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> drivers/pinctrl/mediatek/pinctrl-paris.c
> drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> drivers/pinctrl/pinctrl-amd.c
> drivers/pinctrl/pinctrl-at91.c
> drivers/pinctrl/pinctrl-axp209.c
> drivers/pinctrl/pinctrl-ingenic.c
> drivers/pinctrl/pinctrl-ocelot.c
> drivers/pinctrl/pinctrl-oxnas.c
> drivers/pinctrl/pinctrl-pic32.c
> drivers/pinctrl/pinctrl-pistachio.c
> drivers/pinctrl/pinctrl-rk805.c
> drivers/pinctrl/pinctrl-rockchip.c
> drivers/pinctrl/pinctrl-rza1.c
> drivers/pinctrl/pinctrl-st.c
> drivers/pinctrl/pinctrl-stmfx.c
> drivers/pinctrl/pinctrl-sx150x.c
> drivers/pinctrl/qcom/pinctrl-msm.c
> drivers/pinctrl/stm32/pinctrl-stm32.c
> drivers/pinctrl/vt8500/pinctrl-wmt.c

Ouch. I didn't check from pinctrl but I see those should be converted
as well. I'm a bit short on time right now so if anyone else is
interested I won't mind :)

Luckily the value for IN and OUT is not changed - only the defines were
added - so all of the drivers do not need to be done at once. If no one
else will take the pinctrl part then I can probably do pinctrl patches
for v5.6 cycle.

Br,
	Matti Vaittinen
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
  2019-11-06  8:54   ` [alsa-devel] " Matti Vaittinen
  (?)
@ 2019-11-06 14:22     ` Andy Shevchenko
  -1 siblings, 0 replies; 52+ messages in thread
From: Andy Shevchenko @ 2019-11-06 14:22 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König

On Wed, Nov 06, 2019 at 10:54:12AM +0200, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
> 
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.

>  drivers/gpio/gpio-ich.c             |  5 ++++-

>  drivers/gpio/gpio-merrifield.c      |  5 ++++-

>  drivers/gpio/gpio-pca953x.c         |  5 ++++-

>  drivers/gpio/gpio-sch.c             |  5 ++++-

>  drivers/gpio/gpio-wcove.c           |  7 +++++--

Since maintainers seems in favour of this and bloat-o-meter shows no difference
on selected module,

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

for the stuff I'm involved in.

Thanks!

> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>  
>  static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>  {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)

> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>  
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,

> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void pca953x_gpio_set_multiple(struct gpio_chip *gc,

> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>  {
>  	struct sch_gpio *sch = gpiochip_get_data(gc);
>  
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static const struct gpio_chip sch_gpio_chip = {

> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>  	int ret, reg = to_reg(gpio, CTRL_OUT);
>  
>  	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(wg->regmap, reg, &val);
>  	if (ret)
>  		return ret;
>  
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [alsa-devel] [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
@ 2019-11-06 14:22     ` Andy Shevchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Andy Shevchenko @ 2019-11-06 14:22 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König,
	Bamvor Jian Zhang, NXP Linux Team, linux-pwm, Grygorii Strashko,
	Charles Keepax, Maxime Coquelin, mazziesaccount, Ray Jui,
	Sascha Hauer, William Breathitt Gray, linux-gpio,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra, linux-omap,
	linux-arm-kernel, Scott Branden, Masahiro Yamada, Andrew Jeffery,
	Enrico Weigelt, metux IT consult, linux-kernel,
	linux-renesas-soc, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo

On Wed, Nov 06, 2019 at 10:54:12AM +0200, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
> 
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.

>  drivers/gpio/gpio-ich.c             |  5 ++++-

>  drivers/gpio/gpio-merrifield.c      |  5 ++++-

>  drivers/gpio/gpio-pca953x.c         |  5 ++++-

>  drivers/gpio/gpio-sch.c             |  5 ++++-

>  drivers/gpio/gpio-wcove.c           |  7 +++++--

Since maintainers seems in favour of this and bloat-o-meter shows no difference
on selected module,

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

for the stuff I'm involved in.

Thanks!

> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>  
>  static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>  {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)

> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>  
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,

> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void pca953x_gpio_set_multiple(struct gpio_chip *gc,

> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>  {
>  	struct sch_gpio *sch = gpiochip_get_data(gc);
>  
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static const struct gpio_chip sch_gpio_chip = {

> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>  	int ret, reg = to_reg(gpio, CTRL_OUT);
>  
>  	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(wg->regmap, reg, &val);
>  	if (ret)
>  		return ret;
>  
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)


-- 
With Best Regards,
Andy Shevchenko


_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
@ 2019-11-06 14:22     ` Andy Shevchenko
  0 siblings, 0 replies; 52+ messages in thread
From: Andy Shevchenko @ 2019-11-06 14:22 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König,
	Bamvor Jian Zhang, NXP Linux Team, linux-pwm, Grygorii Strashko,
	Charles Keepax, Maxime Coquelin, mazziesaccount, Ray Jui,
	Sascha Hauer, William Breathitt Gray, linux-gpio,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra, linux-omap,
	linux-arm-kernel, Scott Branden, Masahiro Yamada, Andrew Jeffery,
	Enrico Weigelt, metux IT consult, linux-kernel,
	linux-renesas-soc, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo

On Wed, Nov 06, 2019 at 10:54:12AM +0200, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
> 
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.

>  drivers/gpio/gpio-ich.c             |  5 ++++-

>  drivers/gpio/gpio-merrifield.c      |  5 ++++-

>  drivers/gpio/gpio-pca953x.c         |  5 ++++-

>  drivers/gpio/gpio-sch.c             |  5 ++++-

>  drivers/gpio/gpio-wcove.c           |  7 +++++--

Since maintainers seems in favour of this and bloat-o-meter shows no difference
on selected module,

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

for the stuff I'm involved in.

Thanks!

> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>  
>  static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>  {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)

> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>  
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,

> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void pca953x_gpio_set_multiple(struct gpio_chip *gc,

> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>  {
>  	struct sch_gpio *sch = gpiochip_get_data(gc);
>  
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static const struct gpio_chip sch_gpio_chip = {

> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>  	int ret, reg = to_reg(gpio, CTRL_OUT);
>  
>  	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(wg->regmap, reg, &val);
>  	if (ret)
>  		return ret;
>  
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)


-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-06 12:25     ` [alsa-devel] " Vaittinen, Matti
  (?)
@ 2019-11-06 14:24       ` andriy.shevchenko
  -1 siblings, 0 replies; 52+ messages in thread
From: andriy.shevchenko @ 2019-11-06 14:24 UTC (permalink / raw)
  To: Vaittinen, Matti
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, sre, ptyser, thierry.reding,
	marek.behun, festevam, linux-stm32, marek.vasut+renesas,
	f.fainelli, khilman, michal.simek, jonathanh@nvidia.com

On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:
> 
> On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> > Hi,
> > 
> > On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > > The patch series adds definitions for GPIO line directions.
> > > 
> > > For occasional GPIO contributor like me it is always a pain to
> > > remember
> > > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> > 
> > Maybe also update the GPIO drivers in pinctrl?
> > 
> > $ git grep -l gpio_get_direction drivers/pinctrl
> > drivers/pinctrl/bcm/pinctrl-bcm2835.c
> > drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> > drivers/pinctrl/intel/pinctrl-baytrail.c
> > drivers/pinctrl/intel/pinctrl-cherryview.c
> > drivers/pinctrl/intel/pinctrl-intel.c
> > drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> > drivers/pinctrl/mediatek/pinctrl-paris.c
> > drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> > drivers/pinctrl/pinctrl-amd.c
> > drivers/pinctrl/pinctrl-at91.c
> > drivers/pinctrl/pinctrl-axp209.c
> > drivers/pinctrl/pinctrl-ingenic.c
> > drivers/pinctrl/pinctrl-ocelot.c
> > drivers/pinctrl/pinctrl-oxnas.c
> > drivers/pinctrl/pinctrl-pic32.c
> > drivers/pinctrl/pinctrl-pistachio.c
> > drivers/pinctrl/pinctrl-rk805.c
> > drivers/pinctrl/pinctrl-rockchip.c
> > drivers/pinctrl/pinctrl-rza1.c
> > drivers/pinctrl/pinctrl-st.c
> > drivers/pinctrl/pinctrl-stmfx.c
> > drivers/pinctrl/pinctrl-sx150x.c
> > drivers/pinctrl/qcom/pinctrl-msm.c
> > drivers/pinctrl/stm32/pinctrl-stm32.c
> > drivers/pinctrl/vt8500/pinctrl-wmt.c
> 
> Ouch. I didn't check from pinctrl but I see those should be converted
> as well. I'm a bit short on time right now so if anyone else is
> interested I won't mind :)
> 
> Luckily the value for IN and OUT is not changed - only the defines were
> added - so all of the drivers do not need to be done at once.

Agree.

> If no one
> else will take the pinctrl part then I can probably do pinctrl patches
> for v5.6 cycle.

For pin control Intel, since we send PR to Linus and it won't be different to
him, we would like to see patch per driver.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [alsa-devel] [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 14:24       ` andriy.shevchenko
  0 siblings, 0 replies; 52+ messages in thread
From: andriy.shevchenko @ 2019-11-06 14:24 UTC (permalink / raw)
  To: Vaittinen, Matti
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, sre, ptyser, thierry.reding,
	marek.behun, festevam, linux-stm32, marek.vasut+renesas,
	f.fainelli, khilman, michal.simek, jonathanh, bgolaszewski,
	ludovic.desroches, bamv2005, joel, u.kleine-koenig,
	bcm-kernel-feedback-list, linux-imx, linux-pwm,
	grygorii.strashko, ckeepax, alexandre.torgue, mazziesaccount,
	rjui, s.hauer, vilhelm.gray, linux-gpio, rf, ssantosh,
	linux-tegra, linux-omap, kernel, linux-arm-kernel, sbranden,
	yamada.masahiro, andrew, shawnguo, linux-kernel,
	linux-renesas-soc, t.scherer, mcoquelin.stm32, patches, info

On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:
> 
> On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> > Hi,
> > 
> > On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > > The patch series adds definitions for GPIO line directions.
> > > 
> > > For occasional GPIO contributor like me it is always a pain to
> > > remember
> > > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> > 
> > Maybe also update the GPIO drivers in pinctrl?
> > 
> > $ git grep -l gpio_get_direction drivers/pinctrl
> > drivers/pinctrl/bcm/pinctrl-bcm2835.c
> > drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> > drivers/pinctrl/intel/pinctrl-baytrail.c
> > drivers/pinctrl/intel/pinctrl-cherryview.c
> > drivers/pinctrl/intel/pinctrl-intel.c
> > drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> > drivers/pinctrl/mediatek/pinctrl-paris.c
> > drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> > drivers/pinctrl/pinctrl-amd.c
> > drivers/pinctrl/pinctrl-at91.c
> > drivers/pinctrl/pinctrl-axp209.c
> > drivers/pinctrl/pinctrl-ingenic.c
> > drivers/pinctrl/pinctrl-ocelot.c
> > drivers/pinctrl/pinctrl-oxnas.c
> > drivers/pinctrl/pinctrl-pic32.c
> > drivers/pinctrl/pinctrl-pistachio.c
> > drivers/pinctrl/pinctrl-rk805.c
> > drivers/pinctrl/pinctrl-rockchip.c
> > drivers/pinctrl/pinctrl-rza1.c
> > drivers/pinctrl/pinctrl-st.c
> > drivers/pinctrl/pinctrl-stmfx.c
> > drivers/pinctrl/pinctrl-sx150x.c
> > drivers/pinctrl/qcom/pinctrl-msm.c
> > drivers/pinctrl/stm32/pinctrl-stm32.c
> > drivers/pinctrl/vt8500/pinctrl-wmt.c
> 
> Ouch. I didn't check from pinctrl but I see those should be converted
> as well. I'm a bit short on time right now so if anyone else is
> interested I won't mind :)
> 
> Luckily the value for IN and OUT is not changed - only the defines were
> added - so all of the drivers do not need to be done at once.

Agree.

> If no one
> else will take the pinctrl part then I can probably do pinctrl patches
> for v5.6 cycle.

For pin control Intel, since we send PR to Linus and it won't be different to
him, we would like to see patch per driver.

-- 
With Best Regards,
Andy Shevchenko


_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 14:24       ` andriy.shevchenko
  0 siblings, 0 replies; 52+ messages in thread
From: andriy.shevchenko @ 2019-11-06 14:24 UTC (permalink / raw)
  To: Vaittinen, Matti
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, sre, ptyser, thierry.reding,
	marek.behun, festevam, linux-stm32, marek.vasut+renesas,
	f.fainelli, khilman, michal.simek, jonathanh, bgolaszewski,
	ludovic.desroches, bamv2005, joel, u.kleine-koenig,
	bcm-kernel-feedback-list, linux-imx, linux-pwm,
	grygorii.strashko, ckeepax, alexandre.torgue, mazziesaccount,
	rjui, s.hauer, vilhelm.gray, linux-gpio, rf, ssantosh,
	linux-tegra, linux-omap, kernel, linux-arm-kernel, sbranden,
	yamada.masahiro, andrew, shawnguo, linux-kernel,
	linux-renesas-soc, t.scherer, mcoquelin.stm32, patches, info

On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:
> 
> On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> > Hi,
> > 
> > On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > > The patch series adds definitions for GPIO line directions.
> > > 
> > > For occasional GPIO contributor like me it is always a pain to
> > > remember
> > > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> > 
> > Maybe also update the GPIO drivers in pinctrl?
> > 
> > $ git grep -l gpio_get_direction drivers/pinctrl
> > drivers/pinctrl/bcm/pinctrl-bcm2835.c
> > drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
> > drivers/pinctrl/intel/pinctrl-baytrail.c
> > drivers/pinctrl/intel/pinctrl-cherryview.c
> > drivers/pinctrl/intel/pinctrl-intel.c
> > drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> > drivers/pinctrl/mediatek/pinctrl-paris.c
> > drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> > drivers/pinctrl/pinctrl-amd.c
> > drivers/pinctrl/pinctrl-at91.c
> > drivers/pinctrl/pinctrl-axp209.c
> > drivers/pinctrl/pinctrl-ingenic.c
> > drivers/pinctrl/pinctrl-ocelot.c
> > drivers/pinctrl/pinctrl-oxnas.c
> > drivers/pinctrl/pinctrl-pic32.c
> > drivers/pinctrl/pinctrl-pistachio.c
> > drivers/pinctrl/pinctrl-rk805.c
> > drivers/pinctrl/pinctrl-rockchip.c
> > drivers/pinctrl/pinctrl-rza1.c
> > drivers/pinctrl/pinctrl-st.c
> > drivers/pinctrl/pinctrl-stmfx.c
> > drivers/pinctrl/pinctrl-sx150x.c
> > drivers/pinctrl/qcom/pinctrl-msm.c
> > drivers/pinctrl/stm32/pinctrl-stm32.c
> > drivers/pinctrl/vt8500/pinctrl-wmt.c
> 
> Ouch. I didn't check from pinctrl but I see those should be converted
> as well. I'm a bit short on time right now so if anyone else is
> interested I won't mind :)
> 
> Luckily the value for IN and OUT is not changed - only the defines were
> added - so all of the drivers do not need to be done at once.

Agree.

> If no one
> else will take the pinctrl part then I can probably do pinctrl patches
> for v5.6 cycle.

For pin control Intel, since we send PR to Linus and it won't be different to
him, we would like to see patch per driver.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-06  8:51 ` [alsa-devel] " Matti Vaittinen
  (?)
@ 2019-11-06 14:39   ` William Breathitt Gray
  -1 siblings, 0 replies; 52+ messages in thread
From: William Breathitt Gray @ 2019-11-06 14:39 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König

On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> The patch series adds definitions for GPIO line directions.
> 
> For occasional GPIO contributor like me it is always a pain to remember
> whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
> fact that I removed few comments like:
> 
> /* Return 0 if output, 1 if input */
> /* This means "out" */
> return 1; /* input */
> return 0; /* output */
> 
> it seems at least some others may find it hard to remember too. Adding
> defines for these values helps us who really have good - but short
> duration - memory :]
> 
> This idea comes from RFC series for ROHM BD71828 PMIC and was initially
> discussed with Linus Walleij here:
> https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
> but as this has no dependencies to BD71828 work (which probably takes a
> while) I decided to make it independent series.
> 
> Patches are compile-tested only. I have no HW to really test them. Thus I'd
> appreciate carefull review. This work is mainly about converting zeros
> and ones to the new defines but it wouldn't be first time I get it
> wrong.
> 
> Changelog v2:
>  - squashed patches 2-61 into patch 2.
>  - dropped patch 62 (can be applied later)
>  - rebased (cherry-picked) changes on top of GPIO devel branch.
> 
> Patch 1:
>  - adds the defines
> Patch 2:
>  - convert drivers to use new defines
> 
> This patch series is based on GPIO tree devel branch.

Just a tip for future patchsets in case you didn't know, you case
specify the base of your patchset by using the "--base" option:
https://git-scm.com/docs/git-format-patch#_base_tree_information

This will append a "base-commit" line with the commit hash at the end of
the first message so that it's unabiguous which base you're using
(useful in case the branch changes before your patch is reviewed).

William Breathitt Gray

> 
> ---
> 
> Matti Vaittinen (2):
>   gpio: Add definition for GPIO direction
>   gpio: Use new GPIO_LINE_DIRECTION
> 
>  drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>  drivers/gpio/gpio-104-idi-48.c      |  2 +-
>  drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>  drivers/gpio/gpio-amd-fch.c         |  2 +-
>  drivers/gpio/gpio-aspeed.c          |  7 +++----
>  drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>  drivers/gpio/gpio-bd70528.c         |  8 +++++---
>  drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>  drivers/gpio/gpio-dln2.c            |  6 +++---
>  drivers/gpio/gpio-exar.c            |  5 ++++-
>  drivers/gpio/gpio-f7188x.c          |  5 ++++-
>  drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>  drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>  drivers/gpio/gpio-ich.c             |  5 ++++-
>  drivers/gpio/gpio-kempld.c          |  5 ++++-
>  drivers/gpio/gpio-lp873x.c          |  2 +-
>  drivers/gpio/gpio-lp87565.c         |  5 ++++-
>  drivers/gpio/gpio-madera.c          |  5 ++++-
>  drivers/gpio/gpio-max3191x.c        |  2 +-
>  drivers/gpio/gpio-merrifield.c      |  5 ++++-
>  drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>  drivers/gpio/gpio-mockup.c          | 11 +++--------
>  drivers/gpio/gpio-moxtet.c          |  4 ++--
>  drivers/gpio/gpio-mvebu.c           |  5 ++++-
>  drivers/gpio/gpio-mxs.c             |  5 ++++-
>  drivers/gpio/gpio-omap.c            |  6 ++++--
>  drivers/gpio/gpio-pca953x.c         |  5 ++++-
>  drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>  drivers/gpio/gpio-pisosr.c          |  2 +-
>  drivers/gpio/gpio-pl061.c           |  5 ++++-
>  drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>  drivers/gpio/gpio-rcar.c            |  5 ++++-
>  drivers/gpio/gpio-reg.c             |  3 ++-
>  drivers/gpio/gpio-sa1100.c          |  5 ++++-
>  drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>  drivers/gpio/gpio-sch.c             |  5 ++++-
>  drivers/gpio/gpio-sch311x.c         |  5 ++++-
>  drivers/gpio/gpio-siox.c            |  4 ++--
>  drivers/gpio/gpio-stmpe.c           |  5 ++++-
>  drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>  drivers/gpio/gpio-tegra.c           |  5 ++++-
>  drivers/gpio/gpio-tegra186.c        |  4 ++--
>  drivers/gpio/gpio-thunderx.c        |  5 ++++-
>  drivers/gpio/gpio-tpic2810.c        |  2 +-
>  drivers/gpio/gpio-tps65086.c        |  2 +-
>  drivers/gpio/gpio-tps65912.c        |  4 ++--
>  drivers/gpio/gpio-tps68470.c        |  6 +++---
>  drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>  drivers/gpio/gpio-ts4900.c          |  5 ++++-
>  drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>  drivers/gpio/gpio-twl6040.c         |  3 +--
>  drivers/gpio/gpio-uniphier.c        |  5 ++++-
>  drivers/gpio/gpio-wcove.c           |  7 +++++--
>  drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>  drivers/gpio/gpio-xgene.c           |  5 ++++-
>  drivers/gpio/gpio-xra1403.c         |  5 ++++-
>  drivers/gpio/gpio-xtensa.c          |  4 ++--
>  drivers/gpio/gpio-zynq.c            |  7 +++++--
>  include/linux/gpio/driver.h         |  3 +++
>  61 files changed, 214 insertions(+), 102 deletions(-)
> 
> -- 
> 2.21.0
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 

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

* Re: [alsa-devel] [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 14:39   ` William Breathitt Gray
  0 siblings, 0 replies; 52+ messages in thread
From: William Breathitt Gray @ 2019-11-06 14:39 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König,
	Bamvor Jian Zhang, NXP Linux Team, linux-pwm, Grygorii Strashko,
	Charles Keepax, Maxime Coquelin, linux-omap, mazziesaccount,
	Ray Jui, Sascha Hauer, linux-gpio, Richard Fitzgerald,
	Santosh Shilimkar, linux-tegra, Andy Shevchenko,
	linux-arm-kernel, Scott Branden, Masahiro Yamada, Andrew Jeffery,
	Enrico Weigelt, metux IT consult, linux-kernel,
	linux-renesas-soc, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo

On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> The patch series adds definitions for GPIO line directions.
> 
> For occasional GPIO contributor like me it is always a pain to remember
> whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
> fact that I removed few comments like:
> 
> /* Return 0 if output, 1 if input */
> /* This means "out" */
> return 1; /* input */
> return 0; /* output */
> 
> it seems at least some others may find it hard to remember too. Adding
> defines for these values helps us who really have good - but short
> duration - memory :]
> 
> This idea comes from RFC series for ROHM BD71828 PMIC and was initially
> discussed with Linus Walleij here:
> https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
> but as this has no dependencies to BD71828 work (which probably takes a
> while) I decided to make it independent series.
> 
> Patches are compile-tested only. I have no HW to really test them. Thus I'd
> appreciate carefull review. This work is mainly about converting zeros
> and ones to the new defines but it wouldn't be first time I get it
> wrong.
> 
> Changelog v2:
>  - squashed patches 2-61 into patch 2.
>  - dropped patch 62 (can be applied later)
>  - rebased (cherry-picked) changes on top of GPIO devel branch.
> 
> Patch 1:
>  - adds the defines
> Patch 2:
>  - convert drivers to use new defines
> 
> This patch series is based on GPIO tree devel branch.

Just a tip for future patchsets in case you didn't know, you case
specify the base of your patchset by using the "--base" option:
https://git-scm.com/docs/git-format-patch#_base_tree_information

This will append a "base-commit" line with the commit hash at the end of
the first message so that it's unabiguous which base you're using
(useful in case the branch changes before your patch is reviewed).

William Breathitt Gray

> 
> ---
> 
> Matti Vaittinen (2):
>   gpio: Add definition for GPIO direction
>   gpio: Use new GPIO_LINE_DIRECTION
> 
>  drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>  drivers/gpio/gpio-104-idi-48.c      |  2 +-
>  drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>  drivers/gpio/gpio-amd-fch.c         |  2 +-
>  drivers/gpio/gpio-aspeed.c          |  7 +++----
>  drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>  drivers/gpio/gpio-bd70528.c         |  8 +++++---
>  drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>  drivers/gpio/gpio-dln2.c            |  6 +++---
>  drivers/gpio/gpio-exar.c            |  5 ++++-
>  drivers/gpio/gpio-f7188x.c          |  5 ++++-
>  drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>  drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>  drivers/gpio/gpio-ich.c             |  5 ++++-
>  drivers/gpio/gpio-kempld.c          |  5 ++++-
>  drivers/gpio/gpio-lp873x.c          |  2 +-
>  drivers/gpio/gpio-lp87565.c         |  5 ++++-
>  drivers/gpio/gpio-madera.c          |  5 ++++-
>  drivers/gpio/gpio-max3191x.c        |  2 +-
>  drivers/gpio/gpio-merrifield.c      |  5 ++++-
>  drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>  drivers/gpio/gpio-mockup.c          | 11 +++--------
>  drivers/gpio/gpio-moxtet.c          |  4 ++--
>  drivers/gpio/gpio-mvebu.c           |  5 ++++-
>  drivers/gpio/gpio-mxs.c             |  5 ++++-
>  drivers/gpio/gpio-omap.c            |  6 ++++--
>  drivers/gpio/gpio-pca953x.c         |  5 ++++-
>  drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>  drivers/gpio/gpio-pisosr.c          |  2 +-
>  drivers/gpio/gpio-pl061.c           |  5 ++++-
>  drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>  drivers/gpio/gpio-rcar.c            |  5 ++++-
>  drivers/gpio/gpio-reg.c             |  3 ++-
>  drivers/gpio/gpio-sa1100.c          |  5 ++++-
>  drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>  drivers/gpio/gpio-sch.c             |  5 ++++-
>  drivers/gpio/gpio-sch311x.c         |  5 ++++-
>  drivers/gpio/gpio-siox.c            |  4 ++--
>  drivers/gpio/gpio-stmpe.c           |  5 ++++-
>  drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>  drivers/gpio/gpio-tegra.c           |  5 ++++-
>  drivers/gpio/gpio-tegra186.c        |  4 ++--
>  drivers/gpio/gpio-thunderx.c        |  5 ++++-
>  drivers/gpio/gpio-tpic2810.c        |  2 +-
>  drivers/gpio/gpio-tps65086.c        |  2 +-
>  drivers/gpio/gpio-tps65912.c        |  4 ++--
>  drivers/gpio/gpio-tps68470.c        |  6 +++---
>  drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>  drivers/gpio/gpio-ts4900.c          |  5 ++++-
>  drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>  drivers/gpio/gpio-twl6040.c         |  3 +--
>  drivers/gpio/gpio-uniphier.c        |  5 ++++-
>  drivers/gpio/gpio-wcove.c           |  7 +++++--
>  drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>  drivers/gpio/gpio-xgene.c           |  5 ++++-
>  drivers/gpio/gpio-xra1403.c         |  5 ++++-
>  drivers/gpio/gpio-xtensa.c          |  4 ++--
>  drivers/gpio/gpio-zynq.c            |  7 +++++--
>  include/linux/gpio/driver.h         |  3 +++
>  61 files changed, 214 insertions(+), 102 deletions(-)
> 
> -- 
> 2.21.0
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 14:39   ` William Breathitt Gray
  0 siblings, 0 replies; 52+ messages in thread
From: William Breathitt Gray @ 2019-11-06 14:39 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König,
	Bamvor Jian Zhang, NXP Linux Team, linux-pwm, Grygorii Strashko,
	Charles Keepax, Maxime Coquelin, linux-omap, mazziesaccount,
	Ray Jui, Sascha Hauer, linux-gpio, Richard Fitzgerald,
	Santosh Shilimkar, linux-tegra, Andy Shevchenko,
	linux-arm-kernel, Scott Branden, Masahiro Yamada, Andrew Jeffery,
	Enrico Weigelt, metux IT consult, linux-kernel,
	linux-renesas-soc, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo

On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> The patch series adds definitions for GPIO line directions.
> 
> For occasional GPIO contributor like me it is always a pain to remember
> whether 1 or 0 was used for GPIO direction INPUT/OUTPUT. Judging the
> fact that I removed few comments like:
> 
> /* Return 0 if output, 1 if input */
> /* This means "out" */
> return 1; /* input */
> return 0; /* output */
> 
> it seems at least some others may find it hard to remember too. Adding
> defines for these values helps us who really have good - but short
> duration - memory :]
> 
> This idea comes from RFC series for ROHM BD71828 PMIC and was initially
> discussed with Linus Walleij here:
> https://lore.kernel.org/lkml/c06725c3dd34118a324907137758d8b85b3d4043.camel@fi.rohmeurope.com/
> but as this has no dependencies to BD71828 work (which probably takes a
> while) I decided to make it independent series.
> 
> Patches are compile-tested only. I have no HW to really test them. Thus I'd
> appreciate carefull review. This work is mainly about converting zeros
> and ones to the new defines but it wouldn't be first time I get it
> wrong.
> 
> Changelog v2:
>  - squashed patches 2-61 into patch 2.
>  - dropped patch 62 (can be applied later)
>  - rebased (cherry-picked) changes on top of GPIO devel branch.
> 
> Patch 1:
>  - adds the defines
> Patch 2:
>  - convert drivers to use new defines
> 
> This patch series is based on GPIO tree devel branch.

Just a tip for future patchsets in case you didn't know, you case
specify the base of your patchset by using the "--base" option:
https://git-scm.com/docs/git-format-patch#_base_tree_information

This will append a "base-commit" line with the commit hash at the end of
the first message so that it's unabiguous which base you're using
(useful in case the branch changes before your patch is reviewed).

William Breathitt Gray

> 
> ---
> 
> Matti Vaittinen (2):
>   gpio: Add definition for GPIO direction
>   gpio: Use new GPIO_LINE_DIRECTION
> 
>  drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>  drivers/gpio/gpio-104-idi-48.c      |  2 +-
>  drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>  drivers/gpio/gpio-amd-fch.c         |  2 +-
>  drivers/gpio/gpio-aspeed.c          |  7 +++----
>  drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>  drivers/gpio/gpio-bd70528.c         |  8 +++++---
>  drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>  drivers/gpio/gpio-dln2.c            |  6 +++---
>  drivers/gpio/gpio-exar.c            |  5 ++++-
>  drivers/gpio/gpio-f7188x.c          |  5 ++++-
>  drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>  drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>  drivers/gpio/gpio-ich.c             |  5 ++++-
>  drivers/gpio/gpio-kempld.c          |  5 ++++-
>  drivers/gpio/gpio-lp873x.c          |  2 +-
>  drivers/gpio/gpio-lp87565.c         |  5 ++++-
>  drivers/gpio/gpio-madera.c          |  5 ++++-
>  drivers/gpio/gpio-max3191x.c        |  2 +-
>  drivers/gpio/gpio-merrifield.c      |  5 ++++-
>  drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>  drivers/gpio/gpio-mockup.c          | 11 +++--------
>  drivers/gpio/gpio-moxtet.c          |  4 ++--
>  drivers/gpio/gpio-mvebu.c           |  5 ++++-
>  drivers/gpio/gpio-mxs.c             |  5 ++++-
>  drivers/gpio/gpio-omap.c            |  6 ++++--
>  drivers/gpio/gpio-pca953x.c         |  5 ++++-
>  drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>  drivers/gpio/gpio-pisosr.c          |  2 +-
>  drivers/gpio/gpio-pl061.c           |  5 ++++-
>  drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>  drivers/gpio/gpio-rcar.c            |  5 ++++-
>  drivers/gpio/gpio-reg.c             |  3 ++-
>  drivers/gpio/gpio-sa1100.c          |  5 ++++-
>  drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>  drivers/gpio/gpio-sch.c             |  5 ++++-
>  drivers/gpio/gpio-sch311x.c         |  5 ++++-
>  drivers/gpio/gpio-siox.c            |  4 ++--
>  drivers/gpio/gpio-stmpe.c           |  5 ++++-
>  drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>  drivers/gpio/gpio-tegra.c           |  5 ++++-
>  drivers/gpio/gpio-tegra186.c        |  4 ++--
>  drivers/gpio/gpio-thunderx.c        |  5 ++++-
>  drivers/gpio/gpio-tpic2810.c        |  2 +-
>  drivers/gpio/gpio-tps65086.c        |  2 +-
>  drivers/gpio/gpio-tps65912.c        |  4 ++--
>  drivers/gpio/gpio-tps68470.c        |  6 +++---
>  drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>  drivers/gpio/gpio-ts4900.c          |  5 ++++-
>  drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>  drivers/gpio/gpio-twl6040.c         |  3 +--
>  drivers/gpio/gpio-uniphier.c        |  5 ++++-
>  drivers/gpio/gpio-wcove.c           |  7 +++++--
>  drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>  drivers/gpio/gpio-xgene.c           |  5 ++++-
>  drivers/gpio/gpio-xra1403.c         |  5 ++++-
>  drivers/gpio/gpio-xtensa.c          |  4 ++--
>  drivers/gpio/gpio-zynq.c            |  7 +++++--
>  include/linux/gpio/driver.h         |  3 +++
>  61 files changed, 214 insertions(+), 102 deletions(-)
> 
> -- 
> 2.21.0
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
  2019-11-06  8:54   ` [alsa-devel] " Matti Vaittinen
  (?)
@ 2019-11-06 14:43     ` William Breathitt Gray
  -1 siblings, 0 replies; 52+ messages in thread
From: William Breathitt Gray @ 2019-11-06 14:43 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König

On Wed, Nov 06, 2019 at 10:54:12AM +0200, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
> 
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.
> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> Acked-by: Scott Branden <scott.branden@broadcom.com>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>

> 
> ---
> 
> This patch contains same changes as v1 patches 2-61 did. v1 was splitted
> into small patches in order to help reviewing but squashing was
> requested by Linus Walleij. I maintained all acks/reviewed-by tags from
> v1 series - so acks/review-by tags in this patch mean that specific
> portion of changes have been acked/reviewed by tagger. Eg, whole patch
> has not been reviewed/acked by persons mentioned. Please let me know if
> this is not Ok to you.
> 
>  drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>  drivers/gpio/gpio-104-idi-48.c      |  2 +-
>  drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>  drivers/gpio/gpio-amd-fch.c         |  2 +-
>  drivers/gpio/gpio-aspeed.c          |  7 +++----
>  drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>  drivers/gpio/gpio-bd70528.c         |  8 +++++---
>  drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>  drivers/gpio/gpio-dln2.c            |  6 +++---
>  drivers/gpio/gpio-exar.c            |  5 ++++-
>  drivers/gpio/gpio-f7188x.c          |  5 ++++-
>  drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>  drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>  drivers/gpio/gpio-ich.c             |  5 ++++-
>  drivers/gpio/gpio-kempld.c          |  5 ++++-
>  drivers/gpio/gpio-lp873x.c          |  2 +-
>  drivers/gpio/gpio-lp87565.c         |  5 ++++-
>  drivers/gpio/gpio-madera.c          |  5 ++++-
>  drivers/gpio/gpio-max3191x.c        |  2 +-
>  drivers/gpio/gpio-merrifield.c      |  5 ++++-
>  drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>  drivers/gpio/gpio-mockup.c          | 11 +++--------
>  drivers/gpio/gpio-moxtet.c          |  4 ++--
>  drivers/gpio/gpio-mvebu.c           |  5 ++++-
>  drivers/gpio/gpio-mxs.c             |  5 ++++-
>  drivers/gpio/gpio-omap.c            |  6 ++++--
>  drivers/gpio/gpio-pca953x.c         |  5 ++++-
>  drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>  drivers/gpio/gpio-pisosr.c          |  2 +-
>  drivers/gpio/gpio-pl061.c           |  5 ++++-
>  drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>  drivers/gpio/gpio-rcar.c            |  5 ++++-
>  drivers/gpio/gpio-reg.c             |  3 ++-
>  drivers/gpio/gpio-sa1100.c          |  5 ++++-
>  drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>  drivers/gpio/gpio-sch.c             |  5 ++++-
>  drivers/gpio/gpio-sch311x.c         |  5 ++++-
>  drivers/gpio/gpio-siox.c            |  4 ++--
>  drivers/gpio/gpio-stmpe.c           |  5 ++++-
>  drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>  drivers/gpio/gpio-tegra.c           |  5 ++++-
>  drivers/gpio/gpio-tegra186.c        |  4 ++--
>  drivers/gpio/gpio-thunderx.c        |  5 ++++-
>  drivers/gpio/gpio-tpic2810.c        |  2 +-
>  drivers/gpio/gpio-tps65086.c        |  2 +-
>  drivers/gpio/gpio-tps65912.c        |  4 ++--
>  drivers/gpio/gpio-tps68470.c        |  6 +++---
>  drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>  drivers/gpio/gpio-ts4900.c          |  5 ++++-
>  drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>  drivers/gpio/gpio-twl6040.c         |  3 +--
>  drivers/gpio/gpio-uniphier.c        |  5 ++++-
>  drivers/gpio/gpio-wcove.c           |  7 +++++--
>  drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>  drivers/gpio/gpio-xgene.c           |  5 ++++-
>  drivers/gpio/gpio-xra1403.c         |  5 ++++-
>  drivers/gpio/gpio-xtensa.c          |  4 ++--
>  drivers/gpio/gpio-zynq.c            |  7 +++++--
>  60 files changed, 211 insertions(+), 102 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
> index a44fa8af5b0d..400c09b905f8 100644
> --- a/drivers/gpio/gpio-104-dio-48e.c
> +++ b/drivers/gpio/gpio-104-dio-48e.c
> @@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	const unsigned port = offset / 8;
>  	const unsigned mask = BIT(offset % 8);
>  
> -	return !!(dio48egpio->io_state[port] & mask);
> +	if (dio48egpio->io_state[port] & mask)
> +		return  GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
> index 79dead61e776..c50329ab493a 100644
> --- a/drivers/gpio/gpio-104-idi-48.c
> +++ b/drivers/gpio/gpio-104-idi-48.c
> @@ -53,7 +53,7 @@ struct idi_48_gpio {
>  
>  static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
> index 8d2f51cd9d91..5752d9dab148 100644
> --- a/drivers/gpio/gpio-104-idio-16.c
> +++ b/drivers/gpio/gpio-104-idio-16.c
> @@ -51,9 +51,9 @@ struct idio_16_gpio {
>  static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
> index 83a2286d93f6..173e06758e6c 100644
> --- a/drivers/gpio/gpio-74xx-mmio.c
> +++ b/drivers/gpio/gpio-74xx-mmio.c
> @@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
>  
> -	return !(priv->flags & MMIO_74XX_DIR_OUT);
> +	if (priv->flags & MMIO_74XX_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return  GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
> index 181df1581df5..4e44ba4d7423 100644
> --- a/drivers/gpio/gpio-amd-fch.c
> +++ b/drivers/gpio/gpio-amd-fch.c
> @@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
>  	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
>  	spin_unlock_irqrestore(&priv->lock, flags);
>  
> -	return ret;
> +	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void amd_fch_gpio_set(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index 09e53c5f3b0a..f1037b61f763 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  	u32 val;
>  
>  	if (!have_input(gpio, offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	if (!have_output(gpio, offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
>  	spin_lock_irqsave(&gpio->lock, flags);
>  
> @@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  
>  	spin_unlock_irqrestore(&gpio->lock, flags);
>  
> -	return !val;
> -
> +	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index 9fa6d3a967d2..4122683eb1f9 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
>  	u32 val;
>  
>  	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
> -	return !!val;
> +	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
> @@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
>  	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>  
>  	/* this function only applies to output pin */
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>  		goto out;
>  
>  	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
> @@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
>  	reg_base = kona_gpio->reg_base;
>  	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>  
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>  		reg_offset = GPIO_IN_STATUS(bank_id);
>  	else
>  		reg_offset = GPIO_OUT_STATUS(bank_id);
> diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
> index 0c1ead12d883..734be6b752d0 100644
> --- a/drivers/gpio/gpio-bd70528.c
> +++ b/drivers/gpio/gpio-bd70528.c
> @@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
>  		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
>  		return ret;
>  	}
> +	if (val & BD70528_GPIO_OUT_EN_MASK)
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return !(val & BD70528_GPIO_OUT_EN_MASK);
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> @@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
>  	 * locking would make no sense.
>  	 */
>  	ret = bd70528_get_direction(chip, offset);
> -	if (ret == 0)
> +	if (ret == GPIO_LINE_DIRECTION_OUT)
>  		ret = bd70528_gpio_get_o(bdgpio, offset);
> -	else if (ret == 1)
> +	else if (ret == GPIO_LINE_DIRECTION_IN)
>  		ret = bd70528_gpio_get_i(bdgpio, offset);
>  	else
>  		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
> diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
> index 5224a946e8ab..c0abc9c6851b 100644
> --- a/drivers/gpio/gpio-bd9571mwv.c
> +++ b/drivers/gpio/gpio-bd9571mwv.c
> @@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
>  	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
>  	if (ret < 0)
>  		return ret;
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return val & BIT(offset);
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
> index 8a33c2fc174d..26b40c8b8a12 100644
> --- a/drivers/gpio/gpio-dln2.c
> +++ b/drivers/gpio/gpio-dln2.c
> @@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
>  
>  	if (test_bit(offset, dln2->output_enabled))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
> @@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
>  	if (dir < 0)
>  		return dir;
>  
> -	if (dir == 1)
> +	if (dir == GPIO_LINE_DIRECTION_IN)
>  		return dln2_gpio_pin_get_in_val(dln2, offset);
>  
>  	return dln2_gpio_pin_get_out_val(dln2, offset);
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index fae327d5b06e..da1ef0b1c291 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
>  		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
>  	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
>  
> -	return !!(exar_get(chip, addr) & BIT(bit));
> +	if (exar_get(chip, addr) & BIT(bit))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
> index fdc639f856f1..cadd02993539 100644
> --- a/drivers/gpio/gpio-f7188x.c
> +++ b/drivers/gpio/gpio-f7188x.c
> @@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  
>  	superio_exit(sio->addr);
>  
> -	return !(dir & 1 << offset);
> +	if (dir & 1 << offset)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
> index 78a1db24e931..c22d6f94129c 100644
> --- a/drivers/gpio/gpio-gpio-mm.c
> +++ b/drivers/gpio/gpio-gpio-mm.c
> @@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
>  	const unsigned int port = offset / 8;
>  	const unsigned int mask = BIT(offset % 8);
>  
> -	return !!(gpiommgpio->io_state[port] & mask);
> +	if (gpiommgpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
> index 8aa23d70b1e6..a40bd56673fe 100644
> --- a/drivers/gpio/gpio-htc-egpio.c
> +++ b/drivers/gpio/gpio-htc-egpio.c
> @@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  
>  	egpio = gpiochip_get_data(chip);
>  
> -	return !test_bit(offset, &egpio->is_out);
> +	if (test_bit(offset, &egpio->is_out))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static void egpio_write_cache(struct egpio_info *ei)
> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>  
>  static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>  {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
> diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
> index ef51638f3f75..4ea15f08e0f4 100644
> --- a/drivers/gpio/gpio-kempld.c
> +++ b/drivers/gpio/gpio-kempld.c
> @@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
>  	struct kempld_device_data *pld = gpio->pld;
>  
> -	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
> +	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int kempld_gpio_pincount(struct kempld_device_data *pld)
> diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
> index 801995dd9b26..70fad87ff2db 100644
> --- a/drivers/gpio/gpio-lp873x.c
> +++ b/drivers/gpio/gpio-lp873x.c
> @@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned int offset)
>  {
>  	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int lp873x_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
> index a121c8f10610..e1244520cf7d 100644
> --- a/drivers/gpio/gpio-lp87565.c
> +++ b/drivers/gpio/gpio-lp87565.c
> @@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(val & BIT(offset));
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int lp87565_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
> index 7086f8b5388f..8f38303fcbc4 100644
> --- a/drivers/gpio/gpio-madera.c
> +++ b/drivers/gpio/gpio-madera.c
> @@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(val & MADERA_GP1_DIR_MASK);
> +	if (val & MADERA_GP1_DIR_MASK)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
> index 4b4b2ceb82fc..0696d5a21431 100644
> --- a/drivers/gpio/gpio-max3191x.c
> +++ b/drivers/gpio/gpio-max3191x.c
> @@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
>  
>  static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
>  {
> -	return 1; /* always in */
> +	return GPIO_LINE_DIRECTION_IN; /* always in */
>  }
>  
>  static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>  
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> index 6f904c874678..cd07c948649f 100644
> --- a/drivers/gpio/gpio-mmio.c
> +++ b/drivers/gpio/gpio-mmio.c
> @@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
>  static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
>  {
>  	/* Return 0 if output, 1 if input */
> -	if (gc->bgpio_dir_unreadable)
> -		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
> -	if (gc->reg_dir_out)
> -		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
> +	if (gc->bgpio_dir_unreadable) {
> +		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
> +	if (gc->reg_dir_out) {
> +		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
>  	if (gc->reg_dir_in)
> -		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
> +		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
> +			return GPIO_LINE_DIRECTION_OUT;
>  
>  	/* This should not happen */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 213aedc97dc2..47c172b2f5ad 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -34,14 +34,9 @@
>  
>  #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
>  
> -enum {
> -	GPIO_MOCKUP_DIR_IN = 0,
> -	GPIO_MOCKUP_DIR_OUT = 1,
> -};
> -
>  /*
>   * struct gpio_pin_status - structure describing a GPIO status
> - * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
> + * @dir:       Configures direction of gpio as "in" or "out"
>   * @value:     Configures status of the gpio as 0(low) or 1(high)
>   */
>  struct gpio_mockup_line_status {
> @@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
>  	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>  
>  	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
>  	__gpio_mockup_set(chip, offset, value);
>  	mutex_unlock(&chip->lock);
>  
> @@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
>  	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>  
>  	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
>  	mutex_unlock(&chip->lock);
>  
>  	return 0;
> diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
> index 3fd729994a38..8299909318f4 100644
> --- a/drivers/gpio/gpio-moxtet.c
> +++ b/drivers/gpio/gpio-moxtet.c
> @@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  
>  	/* All lines are hard wired to be either input or output, not both. */
>  	if (chip->desc->in_mask & BIT(offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  	else if (chip->desc->out_mask & BIT(offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  	else
>  		return -EINVAL;
>  }
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 6c0687694341..9b2adf0ef880 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  
>  	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
>  
> -	return !!(u & BIT(pin));
> +	if (u & BIT(pin))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
> diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
> index 5e5437a2c607..c4a314c68555 100644
> --- a/drivers/gpio/gpio-mxs.c
> +++ b/drivers/gpio/gpio-mxs.c
> @@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
>  	u32 dir;
>  
>  	dir = readl(port->base + PINCTRL_DOE(port));
> -	return !(dir & mask);
> +	if (dir & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static const struct platform_device_id mxs_gpio_ids[] = {
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index d0f27084a942..3bd8adaeed9e 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	struct gpio_bank *bank = gpiochip_get_data(chip);
>  
> -	return !!(readl_relaxed(bank->base + bank->regs->direction) &
> -		  BIT(offset));
> +	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
> index 5aa136a6a3e0..df51dd08bdfe 100644
> --- a/drivers/gpio/gpio-pci-idio-16.c
> +++ b/drivers/gpio/gpio-pci-idio-16.c
> @@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
>  	unsigned int offset)
>  {
>  	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int idio_16_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
> index 52f1647a46fd..44c1e4fc489f 100644
> --- a/drivers/gpio/gpio-pcie-idio-24.c
> +++ b/drivers/gpio/gpio-pcie-idio-24.c
> @@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
>  
>  	/* FET Outputs */
>  	if (offset < 24)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	/* Isolated Inputs */
>  	if (offset < 48)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
>  	/* TTL/CMOS I/O */
>  	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
> -	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
> +	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int idio_24_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
> index f809a5a8e9eb..1331b2a94679 100644
> --- a/drivers/gpio/gpio-pisosr.c
> +++ b/drivers/gpio/gpio-pisosr.c
> @@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned offset)
>  {
>  	/* This device always input */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int pisosr_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 722ce5cf861e..5df7782e348f 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct pl061 *pl061 = gpiochip_get_data(gc);
>  
> -	return !(readb(pl061->base + GPIODIR) & BIT(offset));
> +	if (readb(pl061->base + GPIODIR) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
> index b77ea16ffa03..bb100e0124e6 100644
> --- a/drivers/gpio/gpio-raspberrypi-exp.c
> +++ b/drivers/gpio/gpio-raspberrypi-exp.c
> @@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
>  			get.gpio);
>  		return ret ? ret : -EIO;
>  	}
> -	return !get.direction;
> +	if (get.direction)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 187984d26f47..d7e6e68c25af 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
>  
> -	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
> +	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
> index fdc7a9d5b382..d35169bde25a 100644
> --- a/drivers/gpio/gpio-reg.c
> +++ b/drivers/gpio/gpio-reg.c
> @@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct gpio_reg *r = to_gpio_reg(gc);
>  
> -	return r->direction & BIT(offset) ? 1 : 0;
> +	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
> +					    GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
> diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
> index 46b7cf23fb0f..edff5e81489f 100644
> --- a/drivers/gpio/gpio-sa1100.c
> +++ b/drivers/gpio/gpio-sa1100.c
> @@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
>  
> -	return !(readl_relaxed(gpdr) & BIT(offset));
> +	if (readl_relaxed(gpdr) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
> index 7d718557092e..b04c561f3280 100644
> --- a/drivers/gpio/gpio-sama5d2-piobu.c
> +++ b/drivers/gpio/gpio-sama5d2-piobu.c
> @@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return (ret == PIOBU_IN) ? 1 : 0;
> +	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
> +				   GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  /**
> @@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
>  	/* if pin is input, read value from PDS else read from SOD */
>  	int ret = sama5d2_piobu_get_direction(chip, pin);
>  
> -	if (ret == 1)
> +	if (ret == GPIO_LINE_DIRECTION_IN)
>  		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
> -	else if (!ret)
> +	else if (ret == GPIO_LINE_DIRECTION_OUT)
>  		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
>  
>  	if (ret < 0)
> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>  {
>  	struct sch_gpio *sch = gpiochip_get_data(gc);
>  
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static const struct gpio_chip sch_gpio_chip = {
> diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
> index 8ecf336c9af4..da01e1cad7cb 100644
> --- a/drivers/gpio/gpio-sch311x.c
> +++ b/drivers/gpio/gpio-sch311x.c
> @@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	data = inb(block->runtime_reg + block->config_regs[offset]);
>  	spin_unlock(&block->lock);
>  
> -	return !!(data & SCH311X_GPIO_CONF_DIR);
> +	if (data & SCH311X_GPIO_CONF_DIR)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
> index 006a7e6a75f2..311f66757b92 100644
> --- a/drivers/gpio/gpio-siox.c
> +++ b/drivers/gpio/gpio-siox.c
> @@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
>  static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	if (offset < 12)
> -		return 1; /* input */
> +		return GPIO_LINE_DIRECTION_IN;
>  	else
> -		return 0; /* output */
> +		return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpio_siox_probe(struct siox_device *sdevice)
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 994d542daf53..542706a852e6 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(ret & mask);
> +	if (ret & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int stmpe_gpio_direction_output(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
> index 75b1135b383a..6be0684cfa49 100644
> --- a/drivers/gpio/gpio-tc3589x.c
> +++ b/drivers/gpio/gpio-tc3589x.c
> @@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(ret & BIT(pos));
> +	if (ret & BIT(pos))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 8a01d3694b28..6fdfe4c5303e 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
>  
>  	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
>  
> -	return !(oe & pin_mask);
> +	if (oe & pin_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 8a2a69178925..57185b96c110 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
>  
>  	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
>  	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tegra186_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
> index ddad5c7ea617..d08d86a22b1f 100644
> --- a/drivers/gpio/gpio-thunderx.c
> +++ b/drivers/gpio/gpio-thunderx.c
> @@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
>  
>  	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
>  
> -	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
> +	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int thunderx_gpio_set_config(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
> index c8b34d787eed..99d5a84a9129 100644
> --- a/drivers/gpio/gpio-tpic2810.c
> +++ b/drivers/gpio/gpio-tpic2810.c
> @@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
>  				  unsigned offset)
>  {
>  	/* This device always output */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int tpic2810_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
> index 2eea98ff4ea3..1e9d8262d0ff 100644
> --- a/drivers/gpio/gpio-tps65086.c
> +++ b/drivers/gpio/gpio-tps65086.c
> @@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
>  				       unsigned offset)
>  {
>  	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int tps65086_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
> index 3ad68bd78282..510d9ed9fd2a 100644
> --- a/drivers/gpio/gpio-tps65912.c
> +++ b/drivers/gpio/gpio-tps65912.c
> @@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
>  		return ret;
>  
>  	if (val & GPIO_CFG_MASK)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  	else
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
> index aff6e504c666..f7f5f770e0fb 100644
> --- a/drivers/gpio/gpio-tps68470.c
> +++ b/drivers/gpio/gpio-tps68470.c
> @@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
>  	return !!(val & BIT(offset));
>  }
>  
> -/* Return 0 if output, 1 if input */
>  static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  				       unsigned int offset)
>  {
> @@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  
>  	/* rest are always outputs */
>  	if (offset >= TPS68470_N_REGULAR_GPIO)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
>  	if (ret) {
> @@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  	}
>  
>  	val &= TPS68470_GPIO_MODE_MASK;
> -	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
> +	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
> +						    GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
> index a3109bcaa0ac..5022e0ad0fae 100644
> --- a/drivers/gpio/gpio-tqmx86.c
> +++ b/drivers/gpio/gpio-tqmx86.c
> @@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
>  static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned int offset)
>  {
> -	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
> +	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void tqmx86_gpio_irq_mask(struct irq_data *data)
> diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
> index 1da8d0586329..d885032cf814 100644
> --- a/drivers/gpio/gpio-ts4900.c
> +++ b/drivers/gpio/gpio-ts4900.c
> @@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
>  
>  	regmap_read(priv->regmap, offset, &reg);
>  
> -	return !(reg & TS4900_GPIO_OE);
> +	if (reg & TS4900_GPIO_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int ts4900_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index fbfb648d3502..de249726230e 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
>  	if (ret < 0)
>  		return ret;
>  
> -	/* 1 = output, but gpiolib semantics are inverse so invert */
> -	ret = !(ret & d_msk);
> +	if (ret & d_msk)
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return ret;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int twl4030_set_gpio_dataout(int gpio, int enable)
> @@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
>  	/*
> -	 * Default 0 = output
> +	 * Default GPIO_LINE_DIRECTION_OUT
>  	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
>  	 */
> -	int ret = 0;
> +	int ret = GPIO_LINE_DIRECTION_OUT;
>  
>  	mutex_lock(&priv->mutex);
>  	if (offset < TWL4030_GPIO_MAX) {
> diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
> index c845b2ff1f43..648fb418d775 100644
> --- a/drivers/gpio/gpio-twl6040.c
> +++ b/drivers/gpio/gpio-twl6040.c
> @@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
>  
>  static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
> -	/* This means "out" */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
> index 93cdcc41e9fb..bd203e8fa58e 100644
> --- a/drivers/gpio/gpio-uniphier.c
> +++ b/drivers/gpio/gpio-uniphier.c
> @@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
>  static int uniphier_gpio_get_direction(struct gpio_chip *chip,
>  				       unsigned int offset)
>  {
> -	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
> +	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int uniphier_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>  	int ret, reg = to_reg(gpio, CTRL_OUT);
>  
>  	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(wg->regmap, reg, &val);
>  	if (ret)
>  		return ret;
>  
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
> index e0ef66b6a237..fe456bea81f6 100644
> --- a/drivers/gpio/gpio-ws16c48.c
> +++ b/drivers/gpio/gpio-ws16c48.c
> @@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	const unsigned port = offset / 8;
>  	const unsigned mask = BIT(offset % 8);
>  
> -	return !!(ws16c48gpio->io_state[port] & mask);
> +	if (ws16c48gpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
> index a6e66ac18e1f..532b0df8a1f2 100644
> --- a/drivers/gpio/gpio-xgene.c
> +++ b/drivers/gpio/gpio-xgene.c
> @@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
>  	bit_offset = GPIO_BIT_OFFSET(offset);
>  
> -	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
> +	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
> index 05f1998c11a4..31b5072b2df0 100644
> --- a/drivers/gpio/gpio-xra1403.c
> +++ b/drivers/gpio/gpio-xra1403.c
> @@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
>  	if (ret)
>  		return ret;
>  
> -	return !!(val & BIT(offset % 8));
> +	if (val & BIT(offset % 8))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
> index 43d3fa5f511a..08d7c3b32038 100644
> --- a/drivers/gpio/gpio-xtensa.c
> +++ b/drivers/gpio/gpio-xtensa.c
> @@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
>  
>  static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
> -	return 1; /* input only */
> +	return GPIO_LINE_DIRECTION_IN; /* input only */
>  }
>  
>  static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
> @@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
>  
>  static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
> -	return 0; /* output only */
> +	return GPIO_LINE_DIRECTION_OUT; /* output only */
>  }
>  
>  static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index cd475ff4bcad..4c3f6370eab4 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
>   *
>   * This function returns the direction of the specified GPIO.
>   *
> - * Return: 0 for output, 1 for input
> + * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
>   */
>  static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  {
> @@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  
>  	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
>  
> -	return !(reg & BIT(bank_pin_num));
> +	if (reg & BIT(bank_pin_num))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  /**
> -- 
> 2.21.0
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 

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

* Re: [alsa-devel] [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
@ 2019-11-06 14:43     ` William Breathitt Gray
  0 siblings, 0 replies; 52+ messages in thread
From: William Breathitt Gray @ 2019-11-06 14:43 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König,
	Bamvor Jian Zhang, NXP Linux Team, linux-pwm, Grygorii Strashko,
	Charles Keepax, Maxime Coquelin, linux-omap, mazziesaccount,
	Ray Jui, Sascha Hauer, linux-gpio, Richard Fitzgerald,
	Santosh Shilimkar, linux-tegra, Andy Shevchenko,
	linux-arm-kernel, Scott Branden, Masahiro Yamada, Andrew Jeffery,
	Enrico Weigelt, metux IT consult, linux-kernel,
	linux-renesas-soc, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo

On Wed, Nov 06, 2019 at 10:54:12AM +0200, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
> 
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.
> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> Acked-by: Scott Branden <scott.branden@broadcom.com>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>

> 
> ---
> 
> This patch contains same changes as v1 patches 2-61 did. v1 was splitted
> into small patches in order to help reviewing but squashing was
> requested by Linus Walleij. I maintained all acks/reviewed-by tags from
> v1 series - so acks/review-by tags in this patch mean that specific
> portion of changes have been acked/reviewed by tagger. Eg, whole patch
> has not been reviewed/acked by persons mentioned. Please let me know if
> this is not Ok to you.
> 
>  drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>  drivers/gpio/gpio-104-idi-48.c      |  2 +-
>  drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>  drivers/gpio/gpio-amd-fch.c         |  2 +-
>  drivers/gpio/gpio-aspeed.c          |  7 +++----
>  drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>  drivers/gpio/gpio-bd70528.c         |  8 +++++---
>  drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>  drivers/gpio/gpio-dln2.c            |  6 +++---
>  drivers/gpio/gpio-exar.c            |  5 ++++-
>  drivers/gpio/gpio-f7188x.c          |  5 ++++-
>  drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>  drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>  drivers/gpio/gpio-ich.c             |  5 ++++-
>  drivers/gpio/gpio-kempld.c          |  5 ++++-
>  drivers/gpio/gpio-lp873x.c          |  2 +-
>  drivers/gpio/gpio-lp87565.c         |  5 ++++-
>  drivers/gpio/gpio-madera.c          |  5 ++++-
>  drivers/gpio/gpio-max3191x.c        |  2 +-
>  drivers/gpio/gpio-merrifield.c      |  5 ++++-
>  drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>  drivers/gpio/gpio-mockup.c          | 11 +++--------
>  drivers/gpio/gpio-moxtet.c          |  4 ++--
>  drivers/gpio/gpio-mvebu.c           |  5 ++++-
>  drivers/gpio/gpio-mxs.c             |  5 ++++-
>  drivers/gpio/gpio-omap.c            |  6 ++++--
>  drivers/gpio/gpio-pca953x.c         |  5 ++++-
>  drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>  drivers/gpio/gpio-pisosr.c          |  2 +-
>  drivers/gpio/gpio-pl061.c           |  5 ++++-
>  drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>  drivers/gpio/gpio-rcar.c            |  5 ++++-
>  drivers/gpio/gpio-reg.c             |  3 ++-
>  drivers/gpio/gpio-sa1100.c          |  5 ++++-
>  drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>  drivers/gpio/gpio-sch.c             |  5 ++++-
>  drivers/gpio/gpio-sch311x.c         |  5 ++++-
>  drivers/gpio/gpio-siox.c            |  4 ++--
>  drivers/gpio/gpio-stmpe.c           |  5 ++++-
>  drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>  drivers/gpio/gpio-tegra.c           |  5 ++++-
>  drivers/gpio/gpio-tegra186.c        |  4 ++--
>  drivers/gpio/gpio-thunderx.c        |  5 ++++-
>  drivers/gpio/gpio-tpic2810.c        |  2 +-
>  drivers/gpio/gpio-tps65086.c        |  2 +-
>  drivers/gpio/gpio-tps65912.c        |  4 ++--
>  drivers/gpio/gpio-tps68470.c        |  6 +++---
>  drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>  drivers/gpio/gpio-ts4900.c          |  5 ++++-
>  drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>  drivers/gpio/gpio-twl6040.c         |  3 +--
>  drivers/gpio/gpio-uniphier.c        |  5 ++++-
>  drivers/gpio/gpio-wcove.c           |  7 +++++--
>  drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>  drivers/gpio/gpio-xgene.c           |  5 ++++-
>  drivers/gpio/gpio-xra1403.c         |  5 ++++-
>  drivers/gpio/gpio-xtensa.c          |  4 ++--
>  drivers/gpio/gpio-zynq.c            |  7 +++++--
>  60 files changed, 211 insertions(+), 102 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
> index a44fa8af5b0d..400c09b905f8 100644
> --- a/drivers/gpio/gpio-104-dio-48e.c
> +++ b/drivers/gpio/gpio-104-dio-48e.c
> @@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	const unsigned port = offset / 8;
>  	const unsigned mask = BIT(offset % 8);
>  
> -	return !!(dio48egpio->io_state[port] & mask);
> +	if (dio48egpio->io_state[port] & mask)
> +		return  GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
> index 79dead61e776..c50329ab493a 100644
> --- a/drivers/gpio/gpio-104-idi-48.c
> +++ b/drivers/gpio/gpio-104-idi-48.c
> @@ -53,7 +53,7 @@ struct idi_48_gpio {
>  
>  static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
> index 8d2f51cd9d91..5752d9dab148 100644
> --- a/drivers/gpio/gpio-104-idio-16.c
> +++ b/drivers/gpio/gpio-104-idio-16.c
> @@ -51,9 +51,9 @@ struct idio_16_gpio {
>  static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
> index 83a2286d93f6..173e06758e6c 100644
> --- a/drivers/gpio/gpio-74xx-mmio.c
> +++ b/drivers/gpio/gpio-74xx-mmio.c
> @@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
>  
> -	return !(priv->flags & MMIO_74XX_DIR_OUT);
> +	if (priv->flags & MMIO_74XX_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return  GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
> index 181df1581df5..4e44ba4d7423 100644
> --- a/drivers/gpio/gpio-amd-fch.c
> +++ b/drivers/gpio/gpio-amd-fch.c
> @@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
>  	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
>  	spin_unlock_irqrestore(&priv->lock, flags);
>  
> -	return ret;
> +	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void amd_fch_gpio_set(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index 09e53c5f3b0a..f1037b61f763 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  	u32 val;
>  
>  	if (!have_input(gpio, offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	if (!have_output(gpio, offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
>  	spin_lock_irqsave(&gpio->lock, flags);
>  
> @@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  
>  	spin_unlock_irqrestore(&gpio->lock, flags);
>  
> -	return !val;
> -
> +	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index 9fa6d3a967d2..4122683eb1f9 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
>  	u32 val;
>  
>  	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
> -	return !!val;
> +	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
> @@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
>  	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>  
>  	/* this function only applies to output pin */
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>  		goto out;
>  
>  	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
> @@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
>  	reg_base = kona_gpio->reg_base;
>  	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>  
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>  		reg_offset = GPIO_IN_STATUS(bank_id);
>  	else
>  		reg_offset = GPIO_OUT_STATUS(bank_id);
> diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
> index 0c1ead12d883..734be6b752d0 100644
> --- a/drivers/gpio/gpio-bd70528.c
> +++ b/drivers/gpio/gpio-bd70528.c
> @@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
>  		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
>  		return ret;
>  	}
> +	if (val & BD70528_GPIO_OUT_EN_MASK)
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return !(val & BD70528_GPIO_OUT_EN_MASK);
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> @@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
>  	 * locking would make no sense.
>  	 */
>  	ret = bd70528_get_direction(chip, offset);
> -	if (ret == 0)
> +	if (ret == GPIO_LINE_DIRECTION_OUT)
>  		ret = bd70528_gpio_get_o(bdgpio, offset);
> -	else if (ret == 1)
> +	else if (ret == GPIO_LINE_DIRECTION_IN)
>  		ret = bd70528_gpio_get_i(bdgpio, offset);
>  	else
>  		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
> diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
> index 5224a946e8ab..c0abc9c6851b 100644
> --- a/drivers/gpio/gpio-bd9571mwv.c
> +++ b/drivers/gpio/gpio-bd9571mwv.c
> @@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
>  	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
>  	if (ret < 0)
>  		return ret;
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return val & BIT(offset);
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
> index 8a33c2fc174d..26b40c8b8a12 100644
> --- a/drivers/gpio/gpio-dln2.c
> +++ b/drivers/gpio/gpio-dln2.c
> @@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
>  
>  	if (test_bit(offset, dln2->output_enabled))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
> @@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
>  	if (dir < 0)
>  		return dir;
>  
> -	if (dir == 1)
> +	if (dir == GPIO_LINE_DIRECTION_IN)
>  		return dln2_gpio_pin_get_in_val(dln2, offset);
>  
>  	return dln2_gpio_pin_get_out_val(dln2, offset);
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index fae327d5b06e..da1ef0b1c291 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
>  		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
>  	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
>  
> -	return !!(exar_get(chip, addr) & BIT(bit));
> +	if (exar_get(chip, addr) & BIT(bit))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
> index fdc639f856f1..cadd02993539 100644
> --- a/drivers/gpio/gpio-f7188x.c
> +++ b/drivers/gpio/gpio-f7188x.c
> @@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  
>  	superio_exit(sio->addr);
>  
> -	return !(dir & 1 << offset);
> +	if (dir & 1 << offset)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
> index 78a1db24e931..c22d6f94129c 100644
> --- a/drivers/gpio/gpio-gpio-mm.c
> +++ b/drivers/gpio/gpio-gpio-mm.c
> @@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
>  	const unsigned int port = offset / 8;
>  	const unsigned int mask = BIT(offset % 8);
>  
> -	return !!(gpiommgpio->io_state[port] & mask);
> +	if (gpiommgpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
> index 8aa23d70b1e6..a40bd56673fe 100644
> --- a/drivers/gpio/gpio-htc-egpio.c
> +++ b/drivers/gpio/gpio-htc-egpio.c
> @@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  
>  	egpio = gpiochip_get_data(chip);
>  
> -	return !test_bit(offset, &egpio->is_out);
> +	if (test_bit(offset, &egpio->is_out))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static void egpio_write_cache(struct egpio_info *ei)
> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>  
>  static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>  {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
> diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
> index ef51638f3f75..4ea15f08e0f4 100644
> --- a/drivers/gpio/gpio-kempld.c
> +++ b/drivers/gpio/gpio-kempld.c
> @@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
>  	struct kempld_device_data *pld = gpio->pld;
>  
> -	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
> +	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int kempld_gpio_pincount(struct kempld_device_data *pld)
> diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
> index 801995dd9b26..70fad87ff2db 100644
> --- a/drivers/gpio/gpio-lp873x.c
> +++ b/drivers/gpio/gpio-lp873x.c
> @@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned int offset)
>  {
>  	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int lp873x_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
> index a121c8f10610..e1244520cf7d 100644
> --- a/drivers/gpio/gpio-lp87565.c
> +++ b/drivers/gpio/gpio-lp87565.c
> @@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(val & BIT(offset));
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int lp87565_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
> index 7086f8b5388f..8f38303fcbc4 100644
> --- a/drivers/gpio/gpio-madera.c
> +++ b/drivers/gpio/gpio-madera.c
> @@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(val & MADERA_GP1_DIR_MASK);
> +	if (val & MADERA_GP1_DIR_MASK)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
> index 4b4b2ceb82fc..0696d5a21431 100644
> --- a/drivers/gpio/gpio-max3191x.c
> +++ b/drivers/gpio/gpio-max3191x.c
> @@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
>  
>  static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
>  {
> -	return 1; /* always in */
> +	return GPIO_LINE_DIRECTION_IN; /* always in */
>  }
>  
>  static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>  
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> index 6f904c874678..cd07c948649f 100644
> --- a/drivers/gpio/gpio-mmio.c
> +++ b/drivers/gpio/gpio-mmio.c
> @@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
>  static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
>  {
>  	/* Return 0 if output, 1 if input */
> -	if (gc->bgpio_dir_unreadable)
> -		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
> -	if (gc->reg_dir_out)
> -		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
> +	if (gc->bgpio_dir_unreadable) {
> +		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
> +	if (gc->reg_dir_out) {
> +		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
>  	if (gc->reg_dir_in)
> -		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
> +		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
> +			return GPIO_LINE_DIRECTION_OUT;
>  
>  	/* This should not happen */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 213aedc97dc2..47c172b2f5ad 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -34,14 +34,9 @@
>  
>  #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
>  
> -enum {
> -	GPIO_MOCKUP_DIR_IN = 0,
> -	GPIO_MOCKUP_DIR_OUT = 1,
> -};
> -
>  /*
>   * struct gpio_pin_status - structure describing a GPIO status
> - * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
> + * @dir:       Configures direction of gpio as "in" or "out"
>   * @value:     Configures status of the gpio as 0(low) or 1(high)
>   */
>  struct gpio_mockup_line_status {
> @@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
>  	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>  
>  	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
>  	__gpio_mockup_set(chip, offset, value);
>  	mutex_unlock(&chip->lock);
>  
> @@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
>  	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>  
>  	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
>  	mutex_unlock(&chip->lock);
>  
>  	return 0;
> diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
> index 3fd729994a38..8299909318f4 100644
> --- a/drivers/gpio/gpio-moxtet.c
> +++ b/drivers/gpio/gpio-moxtet.c
> @@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  
>  	/* All lines are hard wired to be either input or output, not both. */
>  	if (chip->desc->in_mask & BIT(offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  	else if (chip->desc->out_mask & BIT(offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  	else
>  		return -EINVAL;
>  }
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 6c0687694341..9b2adf0ef880 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  
>  	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
>  
> -	return !!(u & BIT(pin));
> +	if (u & BIT(pin))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
> diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
> index 5e5437a2c607..c4a314c68555 100644
> --- a/drivers/gpio/gpio-mxs.c
> +++ b/drivers/gpio/gpio-mxs.c
> @@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
>  	u32 dir;
>  
>  	dir = readl(port->base + PINCTRL_DOE(port));
> -	return !(dir & mask);
> +	if (dir & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static const struct platform_device_id mxs_gpio_ids[] = {
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index d0f27084a942..3bd8adaeed9e 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	struct gpio_bank *bank = gpiochip_get_data(chip);
>  
> -	return !!(readl_relaxed(bank->base + bank->regs->direction) &
> -		  BIT(offset));
> +	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
> index 5aa136a6a3e0..df51dd08bdfe 100644
> --- a/drivers/gpio/gpio-pci-idio-16.c
> +++ b/drivers/gpio/gpio-pci-idio-16.c
> @@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
>  	unsigned int offset)
>  {
>  	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int idio_16_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
> index 52f1647a46fd..44c1e4fc489f 100644
> --- a/drivers/gpio/gpio-pcie-idio-24.c
> +++ b/drivers/gpio/gpio-pcie-idio-24.c
> @@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
>  
>  	/* FET Outputs */
>  	if (offset < 24)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	/* Isolated Inputs */
>  	if (offset < 48)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
>  	/* TTL/CMOS I/O */
>  	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
> -	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
> +	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int idio_24_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
> index f809a5a8e9eb..1331b2a94679 100644
> --- a/drivers/gpio/gpio-pisosr.c
> +++ b/drivers/gpio/gpio-pisosr.c
> @@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned offset)
>  {
>  	/* This device always input */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int pisosr_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 722ce5cf861e..5df7782e348f 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct pl061 *pl061 = gpiochip_get_data(gc);
>  
> -	return !(readb(pl061->base + GPIODIR) & BIT(offset));
> +	if (readb(pl061->base + GPIODIR) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
> index b77ea16ffa03..bb100e0124e6 100644
> --- a/drivers/gpio/gpio-raspberrypi-exp.c
> +++ b/drivers/gpio/gpio-raspberrypi-exp.c
> @@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
>  			get.gpio);
>  		return ret ? ret : -EIO;
>  	}
> -	return !get.direction;
> +	if (get.direction)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 187984d26f47..d7e6e68c25af 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
>  
> -	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
> +	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
> index fdc7a9d5b382..d35169bde25a 100644
> --- a/drivers/gpio/gpio-reg.c
> +++ b/drivers/gpio/gpio-reg.c
> @@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct gpio_reg *r = to_gpio_reg(gc);
>  
> -	return r->direction & BIT(offset) ? 1 : 0;
> +	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
> +					    GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
> diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
> index 46b7cf23fb0f..edff5e81489f 100644
> --- a/drivers/gpio/gpio-sa1100.c
> +++ b/drivers/gpio/gpio-sa1100.c
> @@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
>  
> -	return !(readl_relaxed(gpdr) & BIT(offset));
> +	if (readl_relaxed(gpdr) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
> index 7d718557092e..b04c561f3280 100644
> --- a/drivers/gpio/gpio-sama5d2-piobu.c
> +++ b/drivers/gpio/gpio-sama5d2-piobu.c
> @@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return (ret == PIOBU_IN) ? 1 : 0;
> +	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
> +				   GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  /**
> @@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
>  	/* if pin is input, read value from PDS else read from SOD */
>  	int ret = sama5d2_piobu_get_direction(chip, pin);
>  
> -	if (ret == 1)
> +	if (ret == GPIO_LINE_DIRECTION_IN)
>  		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
> -	else if (!ret)
> +	else if (ret == GPIO_LINE_DIRECTION_OUT)
>  		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
>  
>  	if (ret < 0)
> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>  {
>  	struct sch_gpio *sch = gpiochip_get_data(gc);
>  
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static const struct gpio_chip sch_gpio_chip = {
> diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
> index 8ecf336c9af4..da01e1cad7cb 100644
> --- a/drivers/gpio/gpio-sch311x.c
> +++ b/drivers/gpio/gpio-sch311x.c
> @@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	data = inb(block->runtime_reg + block->config_regs[offset]);
>  	spin_unlock(&block->lock);
>  
> -	return !!(data & SCH311X_GPIO_CONF_DIR);
> +	if (data & SCH311X_GPIO_CONF_DIR)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
> index 006a7e6a75f2..311f66757b92 100644
> --- a/drivers/gpio/gpio-siox.c
> +++ b/drivers/gpio/gpio-siox.c
> @@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
>  static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	if (offset < 12)
> -		return 1; /* input */
> +		return GPIO_LINE_DIRECTION_IN;
>  	else
> -		return 0; /* output */
> +		return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpio_siox_probe(struct siox_device *sdevice)
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 994d542daf53..542706a852e6 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(ret & mask);
> +	if (ret & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int stmpe_gpio_direction_output(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
> index 75b1135b383a..6be0684cfa49 100644
> --- a/drivers/gpio/gpio-tc3589x.c
> +++ b/drivers/gpio/gpio-tc3589x.c
> @@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(ret & BIT(pos));
> +	if (ret & BIT(pos))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 8a01d3694b28..6fdfe4c5303e 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
>  
>  	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
>  
> -	return !(oe & pin_mask);
> +	if (oe & pin_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 8a2a69178925..57185b96c110 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
>  
>  	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
>  	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tegra186_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
> index ddad5c7ea617..d08d86a22b1f 100644
> --- a/drivers/gpio/gpio-thunderx.c
> +++ b/drivers/gpio/gpio-thunderx.c
> @@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
>  
>  	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
>  
> -	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
> +	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int thunderx_gpio_set_config(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
> index c8b34d787eed..99d5a84a9129 100644
> --- a/drivers/gpio/gpio-tpic2810.c
> +++ b/drivers/gpio/gpio-tpic2810.c
> @@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
>  				  unsigned offset)
>  {
>  	/* This device always output */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int tpic2810_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
> index 2eea98ff4ea3..1e9d8262d0ff 100644
> --- a/drivers/gpio/gpio-tps65086.c
> +++ b/drivers/gpio/gpio-tps65086.c
> @@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
>  				       unsigned offset)
>  {
>  	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int tps65086_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
> index 3ad68bd78282..510d9ed9fd2a 100644
> --- a/drivers/gpio/gpio-tps65912.c
> +++ b/drivers/gpio/gpio-tps65912.c
> @@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
>  		return ret;
>  
>  	if (val & GPIO_CFG_MASK)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  	else
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
> index aff6e504c666..f7f5f770e0fb 100644
> --- a/drivers/gpio/gpio-tps68470.c
> +++ b/drivers/gpio/gpio-tps68470.c
> @@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
>  	return !!(val & BIT(offset));
>  }
>  
> -/* Return 0 if output, 1 if input */
>  static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  				       unsigned int offset)
>  {
> @@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  
>  	/* rest are always outputs */
>  	if (offset >= TPS68470_N_REGULAR_GPIO)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
>  	if (ret) {
> @@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  	}
>  
>  	val &= TPS68470_GPIO_MODE_MASK;
> -	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
> +	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
> +						    GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
> index a3109bcaa0ac..5022e0ad0fae 100644
> --- a/drivers/gpio/gpio-tqmx86.c
> +++ b/drivers/gpio/gpio-tqmx86.c
> @@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
>  static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned int offset)
>  {
> -	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
> +	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void tqmx86_gpio_irq_mask(struct irq_data *data)
> diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
> index 1da8d0586329..d885032cf814 100644
> --- a/drivers/gpio/gpio-ts4900.c
> +++ b/drivers/gpio/gpio-ts4900.c
> @@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
>  
>  	regmap_read(priv->regmap, offset, &reg);
>  
> -	return !(reg & TS4900_GPIO_OE);
> +	if (reg & TS4900_GPIO_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int ts4900_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index fbfb648d3502..de249726230e 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
>  	if (ret < 0)
>  		return ret;
>  
> -	/* 1 = output, but gpiolib semantics are inverse so invert */
> -	ret = !(ret & d_msk);
> +	if (ret & d_msk)
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return ret;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int twl4030_set_gpio_dataout(int gpio, int enable)
> @@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
>  	/*
> -	 * Default 0 = output
> +	 * Default GPIO_LINE_DIRECTION_OUT
>  	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
>  	 */
> -	int ret = 0;
> +	int ret = GPIO_LINE_DIRECTION_OUT;
>  
>  	mutex_lock(&priv->mutex);
>  	if (offset < TWL4030_GPIO_MAX) {
> diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
> index c845b2ff1f43..648fb418d775 100644
> --- a/drivers/gpio/gpio-twl6040.c
> +++ b/drivers/gpio/gpio-twl6040.c
> @@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
>  
>  static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
> -	/* This means "out" */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
> index 93cdcc41e9fb..bd203e8fa58e 100644
> --- a/drivers/gpio/gpio-uniphier.c
> +++ b/drivers/gpio/gpio-uniphier.c
> @@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
>  static int uniphier_gpio_get_direction(struct gpio_chip *chip,
>  				       unsigned int offset)
>  {
> -	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
> +	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int uniphier_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>  	int ret, reg = to_reg(gpio, CTRL_OUT);
>  
>  	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(wg->regmap, reg, &val);
>  	if (ret)
>  		return ret;
>  
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
> index e0ef66b6a237..fe456bea81f6 100644
> --- a/drivers/gpio/gpio-ws16c48.c
> +++ b/drivers/gpio/gpio-ws16c48.c
> @@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	const unsigned port = offset / 8;
>  	const unsigned mask = BIT(offset % 8);
>  
> -	return !!(ws16c48gpio->io_state[port] & mask);
> +	if (ws16c48gpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
> index a6e66ac18e1f..532b0df8a1f2 100644
> --- a/drivers/gpio/gpio-xgene.c
> +++ b/drivers/gpio/gpio-xgene.c
> @@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
>  	bit_offset = GPIO_BIT_OFFSET(offset);
>  
> -	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
> +	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
> index 05f1998c11a4..31b5072b2df0 100644
> --- a/drivers/gpio/gpio-xra1403.c
> +++ b/drivers/gpio/gpio-xra1403.c
> @@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
>  	if (ret)
>  		return ret;
>  
> -	return !!(val & BIT(offset % 8));
> +	if (val & BIT(offset % 8))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
> index 43d3fa5f511a..08d7c3b32038 100644
> --- a/drivers/gpio/gpio-xtensa.c
> +++ b/drivers/gpio/gpio-xtensa.c
> @@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
>  
>  static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
> -	return 1; /* input only */
> +	return GPIO_LINE_DIRECTION_IN; /* input only */
>  }
>  
>  static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
> @@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
>  
>  static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
> -	return 0; /* output only */
> +	return GPIO_LINE_DIRECTION_OUT; /* output only */
>  }
>  
>  static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index cd475ff4bcad..4c3f6370eab4 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
>   *
>   * This function returns the direction of the specified GPIO.
>   *
> - * Return: 0 for output, 1 for input
> + * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
>   */
>  static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  {
> @@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  
>  	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
>  
> -	return !(reg & BIT(bank_pin_num));
> +	if (reg & BIT(bank_pin_num))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  /**
> -- 
> 2.21.0
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
@ 2019-11-06 14:43     ` William Breathitt Gray
  0 siblings, 0 replies; 52+ messages in thread
From: William Breathitt Gray @ 2019-11-06 14:43 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	Linus Walleij, alsa-devel, Peter Tyser, Thierry Reding,
	Alexandre Torgue, Jonathan Hunter, Fabio Estevam, linux-stm32,
	Marek Vasut, Florian Fainelli, Kevin Hilman, Michal Simek,
	Marek Behun, Bartosz Golaszewski, Ludovic Desroches,
	bcm-kernel-feedback-list, Joel Stanley, Uwe Kleine-König,
	Bamvor Jian Zhang, NXP Linux Team, linux-pwm, Grygorii Strashko,
	Charles Keepax, Maxime Coquelin, linux-omap, mazziesaccount,
	Ray Jui, Sascha Hauer, linux-gpio, Richard Fitzgerald,
	Santosh Shilimkar, linux-tegra, Andy Shevchenko,
	linux-arm-kernel, Scott Branden, Masahiro Yamada, Andrew Jeffery,
	Enrico Weigelt, metux IT consult, linux-kernel,
	linux-renesas-soc, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo

On Wed, Nov 06, 2019 at 10:54:12AM +0200, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
> 
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.
> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> Acked-by: Scott Branden <scott.branden@broadcom.com>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>

> 
> ---
> 
> This patch contains same changes as v1 patches 2-61 did. v1 was splitted
> into small patches in order to help reviewing but squashing was
> requested by Linus Walleij. I maintained all acks/reviewed-by tags from
> v1 series - so acks/review-by tags in this patch mean that specific
> portion of changes have been acked/reviewed by tagger. Eg, whole patch
> has not been reviewed/acked by persons mentioned. Please let me know if
> this is not Ok to you.
> 
>  drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>  drivers/gpio/gpio-104-idi-48.c      |  2 +-
>  drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>  drivers/gpio/gpio-amd-fch.c         |  2 +-
>  drivers/gpio/gpio-aspeed.c          |  7 +++----
>  drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>  drivers/gpio/gpio-bd70528.c         |  8 +++++---
>  drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>  drivers/gpio/gpio-dln2.c            |  6 +++---
>  drivers/gpio/gpio-exar.c            |  5 ++++-
>  drivers/gpio/gpio-f7188x.c          |  5 ++++-
>  drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>  drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>  drivers/gpio/gpio-ich.c             |  5 ++++-
>  drivers/gpio/gpio-kempld.c          |  5 ++++-
>  drivers/gpio/gpio-lp873x.c          |  2 +-
>  drivers/gpio/gpio-lp87565.c         |  5 ++++-
>  drivers/gpio/gpio-madera.c          |  5 ++++-
>  drivers/gpio/gpio-max3191x.c        |  2 +-
>  drivers/gpio/gpio-merrifield.c      |  5 ++++-
>  drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>  drivers/gpio/gpio-mockup.c          | 11 +++--------
>  drivers/gpio/gpio-moxtet.c          |  4 ++--
>  drivers/gpio/gpio-mvebu.c           |  5 ++++-
>  drivers/gpio/gpio-mxs.c             |  5 ++++-
>  drivers/gpio/gpio-omap.c            |  6 ++++--
>  drivers/gpio/gpio-pca953x.c         |  5 ++++-
>  drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>  drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>  drivers/gpio/gpio-pisosr.c          |  2 +-
>  drivers/gpio/gpio-pl061.c           |  5 ++++-
>  drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>  drivers/gpio/gpio-rcar.c            |  5 ++++-
>  drivers/gpio/gpio-reg.c             |  3 ++-
>  drivers/gpio/gpio-sa1100.c          |  5 ++++-
>  drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>  drivers/gpio/gpio-sch.c             |  5 ++++-
>  drivers/gpio/gpio-sch311x.c         |  5 ++++-
>  drivers/gpio/gpio-siox.c            |  4 ++--
>  drivers/gpio/gpio-stmpe.c           |  5 ++++-
>  drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>  drivers/gpio/gpio-tegra.c           |  5 ++++-
>  drivers/gpio/gpio-tegra186.c        |  4 ++--
>  drivers/gpio/gpio-thunderx.c        |  5 ++++-
>  drivers/gpio/gpio-tpic2810.c        |  2 +-
>  drivers/gpio/gpio-tps65086.c        |  2 +-
>  drivers/gpio/gpio-tps65912.c        |  4 ++--
>  drivers/gpio/gpio-tps68470.c        |  6 +++---
>  drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>  drivers/gpio/gpio-ts4900.c          |  5 ++++-
>  drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>  drivers/gpio/gpio-twl6040.c         |  3 +--
>  drivers/gpio/gpio-uniphier.c        |  5 ++++-
>  drivers/gpio/gpio-wcove.c           |  7 +++++--
>  drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>  drivers/gpio/gpio-xgene.c           |  5 ++++-
>  drivers/gpio/gpio-xra1403.c         |  5 ++++-
>  drivers/gpio/gpio-xtensa.c          |  4 ++--
>  drivers/gpio/gpio-zynq.c            |  7 +++++--
>  60 files changed, 211 insertions(+), 102 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
> index a44fa8af5b0d..400c09b905f8 100644
> --- a/drivers/gpio/gpio-104-dio-48e.c
> +++ b/drivers/gpio/gpio-104-dio-48e.c
> @@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	const unsigned port = offset / 8;
>  	const unsigned mask = BIT(offset % 8);
>  
> -	return !!(dio48egpio->io_state[port] & mask);
> +	if (dio48egpio->io_state[port] & mask)
> +		return  GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
> index 79dead61e776..c50329ab493a 100644
> --- a/drivers/gpio/gpio-104-idi-48.c
> +++ b/drivers/gpio/gpio-104-idi-48.c
> @@ -53,7 +53,7 @@ struct idi_48_gpio {
>  
>  static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
> index 8d2f51cd9d91..5752d9dab148 100644
> --- a/drivers/gpio/gpio-104-idio-16.c
> +++ b/drivers/gpio/gpio-104-idio-16.c
> @@ -51,9 +51,9 @@ struct idio_16_gpio {
>  static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
> index 83a2286d93f6..173e06758e6c 100644
> --- a/drivers/gpio/gpio-74xx-mmio.c
> +++ b/drivers/gpio/gpio-74xx-mmio.c
> @@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
>  
> -	return !(priv->flags & MMIO_74XX_DIR_OUT);
> +	if (priv->flags & MMIO_74XX_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return  GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
> index 181df1581df5..4e44ba4d7423 100644
> --- a/drivers/gpio/gpio-amd-fch.c
> +++ b/drivers/gpio/gpio-amd-fch.c
> @@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
>  	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
>  	spin_unlock_irqrestore(&priv->lock, flags);
>  
> -	return ret;
> +	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void amd_fch_gpio_set(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index 09e53c5f3b0a..f1037b61f763 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  	u32 val;
>  
>  	if (!have_input(gpio, offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	if (!have_output(gpio, offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
>  	spin_lock_irqsave(&gpio->lock, flags);
>  
> @@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  
>  	spin_unlock_irqrestore(&gpio->lock, flags);
>  
> -	return !val;
> -
> +	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index 9fa6d3a967d2..4122683eb1f9 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
>  	u32 val;
>  
>  	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
> -	return !!val;
> +	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
> @@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
>  	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>  
>  	/* this function only applies to output pin */
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>  		goto out;
>  
>  	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
> @@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
>  	reg_base = kona_gpio->reg_base;
>  	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>  
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>  		reg_offset = GPIO_IN_STATUS(bank_id);
>  	else
>  		reg_offset = GPIO_OUT_STATUS(bank_id);
> diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
> index 0c1ead12d883..734be6b752d0 100644
> --- a/drivers/gpio/gpio-bd70528.c
> +++ b/drivers/gpio/gpio-bd70528.c
> @@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
>  		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
>  		return ret;
>  	}
> +	if (val & BD70528_GPIO_OUT_EN_MASK)
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return !(val & BD70528_GPIO_OUT_EN_MASK);
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> @@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
>  	 * locking would make no sense.
>  	 */
>  	ret = bd70528_get_direction(chip, offset);
> -	if (ret == 0)
> +	if (ret == GPIO_LINE_DIRECTION_OUT)
>  		ret = bd70528_gpio_get_o(bdgpio, offset);
> -	else if (ret == 1)
> +	else if (ret == GPIO_LINE_DIRECTION_IN)
>  		ret = bd70528_gpio_get_i(bdgpio, offset);
>  	else
>  		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
> diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
> index 5224a946e8ab..c0abc9c6851b 100644
> --- a/drivers/gpio/gpio-bd9571mwv.c
> +++ b/drivers/gpio/gpio-bd9571mwv.c
> @@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
>  	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
>  	if (ret < 0)
>  		return ret;
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return val & BIT(offset);
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
> index 8a33c2fc174d..26b40c8b8a12 100644
> --- a/drivers/gpio/gpio-dln2.c
> +++ b/drivers/gpio/gpio-dln2.c
> @@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
>  
>  	if (test_bit(offset, dln2->output_enabled))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
> @@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
>  	if (dir < 0)
>  		return dir;
>  
> -	if (dir == 1)
> +	if (dir == GPIO_LINE_DIRECTION_IN)
>  		return dln2_gpio_pin_get_in_val(dln2, offset);
>  
>  	return dln2_gpio_pin_get_out_val(dln2, offset);
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index fae327d5b06e..da1ef0b1c291 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
>  		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
>  	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
>  
> -	return !!(exar_get(chip, addr) & BIT(bit));
> +	if (exar_get(chip, addr) & BIT(bit))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
> index fdc639f856f1..cadd02993539 100644
> --- a/drivers/gpio/gpio-f7188x.c
> +++ b/drivers/gpio/gpio-f7188x.c
> @@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  
>  	superio_exit(sio->addr);
>  
> -	return !(dir & 1 << offset);
> +	if (dir & 1 << offset)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
> index 78a1db24e931..c22d6f94129c 100644
> --- a/drivers/gpio/gpio-gpio-mm.c
> +++ b/drivers/gpio/gpio-gpio-mm.c
> @@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
>  	const unsigned int port = offset / 8;
>  	const unsigned int mask = BIT(offset % 8);
>  
> -	return !!(gpiommgpio->io_state[port] & mask);
> +	if (gpiommgpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
> index 8aa23d70b1e6..a40bd56673fe 100644
> --- a/drivers/gpio/gpio-htc-egpio.c
> +++ b/drivers/gpio/gpio-htc-egpio.c
> @@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  
>  	egpio = gpiochip_get_data(chip);
>  
> -	return !test_bit(offset, &egpio->is_out);
> +	if (test_bit(offset, &egpio->is_out))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static void egpio_write_cache(struct egpio_info *ei)
> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>  
>  static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>  {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
> diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
> index ef51638f3f75..4ea15f08e0f4 100644
> --- a/drivers/gpio/gpio-kempld.c
> +++ b/drivers/gpio/gpio-kempld.c
> @@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
>  	struct kempld_device_data *pld = gpio->pld;
>  
> -	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
> +	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int kempld_gpio_pincount(struct kempld_device_data *pld)
> diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
> index 801995dd9b26..70fad87ff2db 100644
> --- a/drivers/gpio/gpio-lp873x.c
> +++ b/drivers/gpio/gpio-lp873x.c
> @@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned int offset)
>  {
>  	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int lp873x_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
> index a121c8f10610..e1244520cf7d 100644
> --- a/drivers/gpio/gpio-lp87565.c
> +++ b/drivers/gpio/gpio-lp87565.c
> @@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(val & BIT(offset));
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int lp87565_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
> index 7086f8b5388f..8f38303fcbc4 100644
> --- a/drivers/gpio/gpio-madera.c
> +++ b/drivers/gpio/gpio-madera.c
> @@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(val & MADERA_GP1_DIR_MASK);
> +	if (val & MADERA_GP1_DIR_MASK)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
> index 4b4b2ceb82fc..0696d5a21431 100644
> --- a/drivers/gpio/gpio-max3191x.c
> +++ b/drivers/gpio/gpio-max3191x.c
> @@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
>  
>  static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
>  {
> -	return 1; /* always in */
> +	return GPIO_LINE_DIRECTION_IN; /* always in */
>  }
>  
>  static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>  
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> index 6f904c874678..cd07c948649f 100644
> --- a/drivers/gpio/gpio-mmio.c
> +++ b/drivers/gpio/gpio-mmio.c
> @@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
>  static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
>  {
>  	/* Return 0 if output, 1 if input */
> -	if (gc->bgpio_dir_unreadable)
> -		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
> -	if (gc->reg_dir_out)
> -		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
> +	if (gc->bgpio_dir_unreadable) {
> +		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
> +	if (gc->reg_dir_out) {
> +		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
>  	if (gc->reg_dir_in)
> -		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
> +		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
> +			return GPIO_LINE_DIRECTION_OUT;
>  
>  	/* This should not happen */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 213aedc97dc2..47c172b2f5ad 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -34,14 +34,9 @@
>  
>  #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
>  
> -enum {
> -	GPIO_MOCKUP_DIR_IN = 0,
> -	GPIO_MOCKUP_DIR_OUT = 1,
> -};
> -
>  /*
>   * struct gpio_pin_status - structure describing a GPIO status
> - * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
> + * @dir:       Configures direction of gpio as "in" or "out"
>   * @value:     Configures status of the gpio as 0(low) or 1(high)
>   */
>  struct gpio_mockup_line_status {
> @@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
>  	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>  
>  	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
>  	__gpio_mockup_set(chip, offset, value);
>  	mutex_unlock(&chip->lock);
>  
> @@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
>  	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>  
>  	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
>  	mutex_unlock(&chip->lock);
>  
>  	return 0;
> diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
> index 3fd729994a38..8299909318f4 100644
> --- a/drivers/gpio/gpio-moxtet.c
> +++ b/drivers/gpio/gpio-moxtet.c
> @@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  
>  	/* All lines are hard wired to be either input or output, not both. */
>  	if (chip->desc->in_mask & BIT(offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  	else if (chip->desc->out_mask & BIT(offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  	else
>  		return -EINVAL;
>  }
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 6c0687694341..9b2adf0ef880 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  
>  	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
>  
> -	return !!(u & BIT(pin));
> +	if (u & BIT(pin))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
> diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
> index 5e5437a2c607..c4a314c68555 100644
> --- a/drivers/gpio/gpio-mxs.c
> +++ b/drivers/gpio/gpio-mxs.c
> @@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
>  	u32 dir;
>  
>  	dir = readl(port->base + PINCTRL_DOE(port));
> -	return !(dir & mask);
> +	if (dir & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static const struct platform_device_id mxs_gpio_ids[] = {
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index d0f27084a942..3bd8adaeed9e 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	struct gpio_bank *bank = gpiochip_get_data(chip);
>  
> -	return !!(readl_relaxed(bank->base + bank->regs->direction) &
> -		  BIT(offset));
> +	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>  	if (ret < 0)
>  		return ret;
>  
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
> index 5aa136a6a3e0..df51dd08bdfe 100644
> --- a/drivers/gpio/gpio-pci-idio-16.c
> +++ b/drivers/gpio/gpio-pci-idio-16.c
> @@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
>  	unsigned int offset)
>  {
>  	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int idio_16_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
> index 52f1647a46fd..44c1e4fc489f 100644
> --- a/drivers/gpio/gpio-pcie-idio-24.c
> +++ b/drivers/gpio/gpio-pcie-idio-24.c
> @@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
>  
>  	/* FET Outputs */
>  	if (offset < 24)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	/* Isolated Inputs */
>  	if (offset < 48)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  
>  	/* TTL/CMOS I/O */
>  	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
> -	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
> +	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int idio_24_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
> index f809a5a8e9eb..1331b2a94679 100644
> --- a/drivers/gpio/gpio-pisosr.c
> +++ b/drivers/gpio/gpio-pisosr.c
> @@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned offset)
>  {
>  	/* This device always input */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int pisosr_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 722ce5cf861e..5df7782e348f 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct pl061 *pl061 = gpiochip_get_data(gc);
>  
> -	return !(readb(pl061->base + GPIODIR) & BIT(offset));
> +	if (readb(pl061->base + GPIODIR) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
> index b77ea16ffa03..bb100e0124e6 100644
> --- a/drivers/gpio/gpio-raspberrypi-exp.c
> +++ b/drivers/gpio/gpio-raspberrypi-exp.c
> @@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
>  			get.gpio);
>  		return ret ? ret : -EIO;
>  	}
> -	return !get.direction;
> +	if (get.direction)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 187984d26f47..d7e6e68c25af 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
>  
> -	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
> +	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
> index fdc7a9d5b382..d35169bde25a 100644
> --- a/drivers/gpio/gpio-reg.c
> +++ b/drivers/gpio/gpio-reg.c
> @@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
>  	struct gpio_reg *r = to_gpio_reg(gc);
>  
> -	return r->direction & BIT(offset) ? 1 : 0;
> +	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
> +					    GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
> diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
> index 46b7cf23fb0f..edff5e81489f 100644
> --- a/drivers/gpio/gpio-sa1100.c
> +++ b/drivers/gpio/gpio-sa1100.c
> @@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
>  
> -	return !(readl_relaxed(gpdr) & BIT(offset));
> +	if (readl_relaxed(gpdr) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
> index 7d718557092e..b04c561f3280 100644
> --- a/drivers/gpio/gpio-sama5d2-piobu.c
> +++ b/drivers/gpio/gpio-sama5d2-piobu.c
> @@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return (ret == PIOBU_IN) ? 1 : 0;
> +	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
> +				   GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  /**
> @@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
>  	/* if pin is input, read value from PDS else read from SOD */
>  	int ret = sama5d2_piobu_get_direction(chip, pin);
>  
> -	if (ret == 1)
> +	if (ret == GPIO_LINE_DIRECTION_IN)
>  		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
> -	else if (!ret)
> +	else if (ret == GPIO_LINE_DIRECTION_OUT)
>  		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
>  
>  	if (ret < 0)
> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>  {
>  	struct sch_gpio *sch = gpiochip_get_data(gc);
>  
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static const struct gpio_chip sch_gpio_chip = {
> diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
> index 8ecf336c9af4..da01e1cad7cb 100644
> --- a/drivers/gpio/gpio-sch311x.c
> +++ b/drivers/gpio/gpio-sch311x.c
> @@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	data = inb(block->runtime_reg + block->config_regs[offset]);
>  	spin_unlock(&block->lock);
>  
> -	return !!(data & SCH311X_GPIO_CONF_DIR);
> +	if (data & SCH311X_GPIO_CONF_DIR)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
> index 006a7e6a75f2..311f66757b92 100644
> --- a/drivers/gpio/gpio-siox.c
> +++ b/drivers/gpio/gpio-siox.c
> @@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
>  static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
>  {
>  	if (offset < 12)
> -		return 1; /* input */
> +		return GPIO_LINE_DIRECTION_IN;
>  	else
> -		return 0; /* output */
> +		return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int gpio_siox_probe(struct siox_device *sdevice)
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 994d542daf53..542706a852e6 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(ret & mask);
> +	if (ret & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int stmpe_gpio_direction_output(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
> index 75b1135b383a..6be0684cfa49 100644
> --- a/drivers/gpio/gpio-tc3589x.c
> +++ b/drivers/gpio/gpio-tc3589x.c
> @@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
>  	if (ret < 0)
>  		return ret;
>  
> -	return !(ret & BIT(pos));
> +	if (ret & BIT(pos))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 8a01d3694b28..6fdfe4c5303e 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
>  
>  	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
>  
> -	return !(oe & pin_mask);
> +	if (oe & pin_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 8a2a69178925..57185b96c110 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
>  
>  	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
>  	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tegra186_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
> index ddad5c7ea617..d08d86a22b1f 100644
> --- a/drivers/gpio/gpio-thunderx.c
> +++ b/drivers/gpio/gpio-thunderx.c
> @@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
>  
>  	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
>  
> -	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
> +	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int thunderx_gpio_set_config(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
> index c8b34d787eed..99d5a84a9129 100644
> --- a/drivers/gpio/gpio-tpic2810.c
> +++ b/drivers/gpio/gpio-tpic2810.c
> @@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
>  				  unsigned offset)
>  {
>  	/* This device always output */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int tpic2810_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
> index 2eea98ff4ea3..1e9d8262d0ff 100644
> --- a/drivers/gpio/gpio-tps65086.c
> +++ b/drivers/gpio/gpio-tps65086.c
> @@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
>  				       unsigned offset)
>  {
>  	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int tps65086_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
> index 3ad68bd78282..510d9ed9fd2a 100644
> --- a/drivers/gpio/gpio-tps65912.c
> +++ b/drivers/gpio/gpio-tps65912.c
> @@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
>  		return ret;
>  
>  	if (val & GPIO_CFG_MASK)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  	else
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
> index aff6e504c666..f7f5f770e0fb 100644
> --- a/drivers/gpio/gpio-tps68470.c
> +++ b/drivers/gpio/gpio-tps68470.c
> @@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
>  	return !!(val & BIT(offset));
>  }
>  
> -/* Return 0 if output, 1 if input */
>  static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  				       unsigned int offset)
>  {
> @@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  
>  	/* rest are always outputs */
>  	if (offset >= TPS68470_N_REGULAR_GPIO)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
>  	if (ret) {
> @@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>  	}
>  
>  	val &= TPS68470_GPIO_MODE_MASK;
> -	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
> +	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
> +						    GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
> index a3109bcaa0ac..5022e0ad0fae 100644
> --- a/drivers/gpio/gpio-tqmx86.c
> +++ b/drivers/gpio/gpio-tqmx86.c
> @@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
>  static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
>  				     unsigned int offset)
>  {
> -	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
> +	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static void tqmx86_gpio_irq_mask(struct irq_data *data)
> diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
> index 1da8d0586329..d885032cf814 100644
> --- a/drivers/gpio/gpio-ts4900.c
> +++ b/drivers/gpio/gpio-ts4900.c
> @@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
>  
>  	regmap_read(priv->regmap, offset, &reg);
>  
> -	return !(reg & TS4900_GPIO_OE);
> +	if (reg & TS4900_GPIO_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int ts4900_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index fbfb648d3502..de249726230e 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
>  	if (ret < 0)
>  		return ret;
>  
> -	/* 1 = output, but gpiolib semantics are inverse so invert */
> -	ret = !(ret & d_msk);
> +	if (ret & d_msk)
> +		return GPIO_LINE_DIRECTION_OUT;
>  
> -	return ret;
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int twl4030_set_gpio_dataout(int gpio, int enable)
> @@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
>  	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
>  	/*
> -	 * Default 0 = output
> +	 * Default GPIO_LINE_DIRECTION_OUT
>  	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
>  	 */
> -	int ret = 0;
> +	int ret = GPIO_LINE_DIRECTION_OUT;
>  
>  	mutex_lock(&priv->mutex);
>  	if (offset < TWL4030_GPIO_MAX) {
> diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
> index c845b2ff1f43..648fb418d775 100644
> --- a/drivers/gpio/gpio-twl6040.c
> +++ b/drivers/gpio/gpio-twl6040.c
> @@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
>  
>  static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
>  {
> -	/* This means "out" */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
> index 93cdcc41e9fb..bd203e8fa58e 100644
> --- a/drivers/gpio/gpio-uniphier.c
> +++ b/drivers/gpio/gpio-uniphier.c
> @@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
>  static int uniphier_gpio_get_direction(struct gpio_chip *chip,
>  				       unsigned int offset)
>  {
> -	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
> +	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int uniphier_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>  	int ret, reg = to_reg(gpio, CTRL_OUT);
>  
>  	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>  
>  	ret = regmap_read(wg->regmap, reg, &val);
>  	if (ret)
>  		return ret;
>  
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
> index e0ef66b6a237..fe456bea81f6 100644
> --- a/drivers/gpio/gpio-ws16c48.c
> +++ b/drivers/gpio/gpio-ws16c48.c
> @@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>  	const unsigned port = offset / 8;
>  	const unsigned mask = BIT(offset % 8);
>  
> -	return !!(ws16c48gpio->io_state[port] & mask);
> +	if (ws16c48gpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
> index a6e66ac18e1f..532b0df8a1f2 100644
> --- a/drivers/gpio/gpio-xgene.c
> +++ b/drivers/gpio/gpio-xgene.c
> @@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
>  	bit_offset = GPIO_BIT_OFFSET(offset);
>  
> -	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
> +	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
> index 05f1998c11a4..31b5072b2df0 100644
> --- a/drivers/gpio/gpio-xra1403.c
> +++ b/drivers/gpio/gpio-xra1403.c
> @@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
>  	if (ret)
>  		return ret;
>  
> -	return !!(val & BIT(offset % 8));
> +	if (val & BIT(offset % 8))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>  }
>  
>  static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
> index 43d3fa5f511a..08d7c3b32038 100644
> --- a/drivers/gpio/gpio-xtensa.c
> +++ b/drivers/gpio/gpio-xtensa.c
> @@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
>  
>  static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
> -	return 1; /* input only */
> +	return GPIO_LINE_DIRECTION_IN; /* input only */
>  }
>  
>  static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
> @@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
>  
>  static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
>  {
> -	return 0; /* output only */
> +	return GPIO_LINE_DIRECTION_OUT; /* output only */
>  }
>  
>  static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index cd475ff4bcad..4c3f6370eab4 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
>   *
>   * This function returns the direction of the specified GPIO.
>   *
> - * Return: 0 for output, 1 for input
> + * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
>   */
>  static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  {
> @@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>  
>  	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
>  
> -	return !(reg & BIT(bank_pin_num));
> +	if (reg & BIT(bank_pin_num))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>  }
>  
>  /**
> -- 
> 2.21.0
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-06 14:39   ` [alsa-devel] " William Breathitt Gray
  (?)
@ 2019-11-06 17:28     ` Vaittinen, Matti
  -1 siblings, 0 replies; 52+ messages in thread
From: Vaittinen, Matti @ 2019-11-06 17:28 UTC (permalink / raw)
  To: vilhelm.gray
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, ptyser, thierry.reding, marek.behun,
	festevam, linux-stm32, marek.vasut+renesas, f.fainelli, khilman,
	michal.simek, jonathanh


On Wed, 2019-11-06 at 09:39 -0500, William Breathitt Gray wrote:
> On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > The patch series adds definitions for GPIO line directions.

...snip...

> > This patch series is based on GPIO tree devel branch.
> 
> Just a tip for future patchsets in case you didn't know, you case
> specify the base of your patchset by using the "--base" option:
> https://git-scm.com/docs/git-format-patch#_base_tree_information
> 
> This will append a "base-commit" line with the commit hash at the end
> of
> the first message so that it's unabiguous which base you're using
> (useful in case the branch changes before your patch is reviewed).

Tanks William! I didn't know about the --base. It's nice to learn
something new every day :]

> > -- 
> > Matti Vaittinen, Linux device drivers
> > ROHM Semiconductors, Finland SWDC
> > Kiviharjunlenkki 1E
> > 90220 OULU
> > FINLAND
> > 
> > ~~~ "I don't think so," said Rene Descartes. Just then he vanished
> > ~~~
> > Simon says - in Latin please.
> > ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> > Thanks to Simon Glass for the translation =] 

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

* Re: [alsa-devel] [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 17:28     ` Vaittinen, Matti
  0 siblings, 0 replies; 52+ messages in thread
From: Vaittinen, Matti @ 2019-11-06 17:28 UTC (permalink / raw)
  To: vilhelm.gray
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, ptyser, thierry.reding, marek.behun,
	festevam, linux-stm32, marek.vasut+renesas, f.fainelli, khilman,
	michal.simek, jonathanh, bgolaszewski, ludovic.desroches,
	bamv2005, joel, u.kleine-koenig, bcm-kernel-feedback-list,
	linux-imx, linux-pwm, grygorii.strashko, ckeepax,
	alexandre.torgue, linux-omap, mazziesaccount, rjui, s.hauer,
	linux-gpio, rf, ssantosh, linux-tegra, andriy.shevchenko, kernel,
	linux-arm-kernel, sbranden, yamada.masahiro, andrew, info,
	linux-kernel, linux-renesas-soc, t.scherer, mcoquelin.stm32,
	patches, shawnguo


On Wed, 2019-11-06 at 09:39 -0500, William Breathitt Gray wrote:
> On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > The patch series adds definitions for GPIO line directions.

...snip...

> > This patch series is based on GPIO tree devel branch.
> 
> Just a tip for future patchsets in case you didn't know, you case
> specify the base of your patchset by using the "--base" option:
> https://git-scm.com/docs/git-format-patch#_base_tree_information
> 
> This will append a "base-commit" line with the commit hash at the end
> of
> the first message so that it's unabiguous which base you're using
> (useful in case the branch changes before your patch is reviewed).

Tanks William! I didn't know about the --base. It's nice to learn
something new every day :]

> > -- 
> > Matti Vaittinen, Linux device drivers
> > ROHM Semiconductors, Finland SWDC
> > Kiviharjunlenkki 1E
> > 90220 OULU
> > FINLAND
> > 
> > ~~~ "I don't think so," said Rene Descartes. Just then he vanished
> > ~~~
> > Simon says - in Latin please.
> > ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> > Thanks to Simon Glass for the translation =] 

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-06 17:28     ` Vaittinen, Matti
  0 siblings, 0 replies; 52+ messages in thread
From: Vaittinen, Matti @ 2019-11-06 17:28 UTC (permalink / raw)
  To: vilhelm.gray
  Cc: alsa-devel, linux-aspeed, david.daney, linus.walleij,
	sathyanarayanan.kuppuswamy, ptyser, thierry.reding, marek.behun,
	festevam, linux-stm32, marek.vasut+renesas, f.fainelli, khilman,
	michal.simek, jonathanh, bgolaszewski, ludovic.desroches,
	bamv2005, joel, u.kleine-koenig, bcm-kernel-feedback-list,
	linux-imx, linux-pwm, grygorii.strashko, ckeepax,
	alexandre.torgue, linux-omap, mazziesaccount, rjui, s.hauer,
	linux-gpio, rf, ssantosh, linux-tegra, andriy.shevchenko, kernel,
	linux-arm-kernel, sbranden, yamada.masahiro, andrew, info,
	linux-kernel, linux-renesas-soc, t.scherer, mcoquelin.stm32,
	patches, shawnguo


On Wed, 2019-11-06 at 09:39 -0500, William Breathitt Gray wrote:
> On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > The patch series adds definitions for GPIO line directions.

...snip...

> > This patch series is based on GPIO tree devel branch.
> 
> Just a tip for future patchsets in case you didn't know, you case
> specify the base of your patchset by using the "--base" option:
> https://git-scm.com/docs/git-format-patch#_base_tree_information
> 
> This will append a "base-commit" line with the commit hash at the end
> of
> the first message so that it's unabiguous which base you're using
> (useful in case the branch changes before your patch is reviewed).

Tanks William! I didn't know about the --base. It's nice to learn
something new every day :]

> > -- 
> > Matti Vaittinen, Linux device drivers
> > ROHM Semiconductors, Finland SWDC
> > Kiviharjunlenkki 1E
> > 90220 OULU
> > FINLAND
> > 
> > ~~~ "I don't think so," said Rene Descartes. Just then he vanished
> > ~~~
> > Simon says - in Latin please.
> > ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> > Thanks to Simon Glass for the translation =] 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
  2019-11-06  8:54   ` [alsa-devel] " Matti Vaittinen
  (?)
@ 2019-11-06 17:35     ` Kuppuswamy Sathyanarayanan
  -1 siblings, 0 replies; 52+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2019-11-06 17:35 UTC (permalink / raw)
  To: Matti Vaittinen, mazziesaccount
  Cc: alsa-devel, linux-aspeed, David Daney, Linus Walleij,
	Peter Tyser, Thierry Reding, Jonathan Hunter, Fabio Estevam,
	linux-stm32, Marek Vasut, Florian Fainelli, Kevin Hilman,
	Michal Simek, Marek Behun, Bartosz Golaszewski,
	Ludovic Desroches, bcm-kernel-feedback-list, Joel Stanley,
	Uwe Kleine-König, Bamvor Jian Zhang, NXP Linux Team,
	linux-pwm


On 11/6/19 12:54 AM, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
>
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> Acked-by: Scott Branden <scott.branden@broadcom.com>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> ---

For wcove GPIO driver,

Acked-by: Kuppuswamy Sathyanarayanan 
<sathyanarayanan.kuppuswamy@linux.intel.com>

>
> This patch contains same changes as v1 patches 2-61 did. v1 was splitted
> into small patches in order to help reviewing but squashing was
> requested by Linus Walleij. I maintained all acks/reviewed-by tags from
> v1 series - so acks/review-by tags in this patch mean that specific
> portion of changes have been acked/reviewed by tagger. Eg, whole patch
> has not been reviewed/acked by persons mentioned. Please let me know if
> this is not Ok to you.
>
>   drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>   drivers/gpio/gpio-104-idi-48.c      |  2 +-
>   drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>   drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>   drivers/gpio/gpio-amd-fch.c         |  2 +-
>   drivers/gpio/gpio-aspeed.c          |  7 +++----
>   drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>   drivers/gpio/gpio-bd70528.c         |  8 +++++---
>   drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>   drivers/gpio/gpio-dln2.c            |  6 +++---
>   drivers/gpio/gpio-exar.c            |  5 ++++-
>   drivers/gpio/gpio-f7188x.c          |  5 ++++-
>   drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>   drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>   drivers/gpio/gpio-ich.c             |  5 ++++-
>   drivers/gpio/gpio-kempld.c          |  5 ++++-
>   drivers/gpio/gpio-lp873x.c          |  2 +-
>   drivers/gpio/gpio-lp87565.c         |  5 ++++-
>   drivers/gpio/gpio-madera.c          |  5 ++++-
>   drivers/gpio/gpio-max3191x.c        |  2 +-
>   drivers/gpio/gpio-merrifield.c      |  5 ++++-
>   drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>   drivers/gpio/gpio-mockup.c          | 11 +++--------
>   drivers/gpio/gpio-moxtet.c          |  4 ++--
>   drivers/gpio/gpio-mvebu.c           |  5 ++++-
>   drivers/gpio/gpio-mxs.c             |  5 ++++-
>   drivers/gpio/gpio-omap.c            |  6 ++++--
>   drivers/gpio/gpio-pca953x.c         |  5 ++++-
>   drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>   drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>   drivers/gpio/gpio-pisosr.c          |  2 +-
>   drivers/gpio/gpio-pl061.c           |  5 ++++-
>   drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>   drivers/gpio/gpio-rcar.c            |  5 ++++-
>   drivers/gpio/gpio-reg.c             |  3 ++-
>   drivers/gpio/gpio-sa1100.c          |  5 ++++-
>   drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>   drivers/gpio/gpio-sch.c             |  5 ++++-
>   drivers/gpio/gpio-sch311x.c         |  5 ++++-
>   drivers/gpio/gpio-siox.c            |  4 ++--
>   drivers/gpio/gpio-stmpe.c           |  5 ++++-
>   drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>   drivers/gpio/gpio-tegra.c           |  5 ++++-
>   drivers/gpio/gpio-tegra186.c        |  4 ++--
>   drivers/gpio/gpio-thunderx.c        |  5 ++++-
>   drivers/gpio/gpio-tpic2810.c        |  2 +-
>   drivers/gpio/gpio-tps65086.c        |  2 +-
>   drivers/gpio/gpio-tps65912.c        |  4 ++--
>   drivers/gpio/gpio-tps68470.c        |  6 +++---
>   drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>   drivers/gpio/gpio-ts4900.c          |  5 ++++-
>   drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>   drivers/gpio/gpio-twl6040.c         |  3 +--
>   drivers/gpio/gpio-uniphier.c        |  5 ++++-
>   drivers/gpio/gpio-wcove.c           |  7 +++++--
>   drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>   drivers/gpio/gpio-xgene.c           |  5 ++++-
>   drivers/gpio/gpio-xra1403.c         |  5 ++++-
>   drivers/gpio/gpio-xtensa.c          |  4 ++--
>   drivers/gpio/gpio-zynq.c            |  7 +++++--
>   60 files changed, 211 insertions(+), 102 deletions(-)
>
> diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
> index a44fa8af5b0d..400c09b905f8 100644
> --- a/drivers/gpio/gpio-104-dio-48e.c
> +++ b/drivers/gpio/gpio-104-dio-48e.c
> @@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	const unsigned port = offset / 8;
>   	const unsigned mask = BIT(offset % 8);
>   
> -	return !!(dio48egpio->io_state[port] & mask);
> +	if (dio48egpio->io_state[port] & mask)
> +		return  GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
> index 79dead61e776..c50329ab493a 100644
> --- a/drivers/gpio/gpio-104-idi-48.c
> +++ b/drivers/gpio/gpio-104-idi-48.c
> @@ -53,7 +53,7 @@ struct idi_48_gpio {
>   
>   static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
> index 8d2f51cd9d91..5752d9dab148 100644
> --- a/drivers/gpio/gpio-104-idio-16.c
> +++ b/drivers/gpio/gpio-104-idio-16.c
> @@ -51,9 +51,9 @@ struct idio_16_gpio {
>   static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
> index 83a2286d93f6..173e06758e6c 100644
> --- a/drivers/gpio/gpio-74xx-mmio.c
> +++ b/drivers/gpio/gpio-74xx-mmio.c
> @@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
>   
> -	return !(priv->flags & MMIO_74XX_DIR_OUT);
> +	if (priv->flags & MMIO_74XX_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return  GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
> index 181df1581df5..4e44ba4d7423 100644
> --- a/drivers/gpio/gpio-amd-fch.c
> +++ b/drivers/gpio/gpio-amd-fch.c
> @@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
>   	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
>   	spin_unlock_irqrestore(&priv->lock, flags);
>   
> -	return ret;
> +	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void amd_fch_gpio_set(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index 09e53c5f3b0a..f1037b61f763 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   	u32 val;
>   
>   	if (!have_input(gpio, offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	if (!have_output(gpio, offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
>   	spin_lock_irqsave(&gpio->lock, flags);
>   
> @@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   
>   	spin_unlock_irqrestore(&gpio->lock, flags);
>   
> -	return !val;
> -
> +	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index 9fa6d3a967d2..4122683eb1f9 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
>   	u32 val;
>   
>   	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
> -	return !!val;
> +	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
> @@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
>   	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>   
>   	/* this function only applies to output pin */
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>   		goto out;
>   
>   	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
> @@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
>   	reg_base = kona_gpio->reg_base;
>   	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>   
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>   		reg_offset = GPIO_IN_STATUS(bank_id);
>   	else
>   		reg_offset = GPIO_OUT_STATUS(bank_id);
> diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
> index 0c1ead12d883..734be6b752d0 100644
> --- a/drivers/gpio/gpio-bd70528.c
> +++ b/drivers/gpio/gpio-bd70528.c
> @@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
>   		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
>   		return ret;
>   	}
> +	if (val & BD70528_GPIO_OUT_EN_MASK)
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return !(val & BD70528_GPIO_OUT_EN_MASK);
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> @@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
>   	 * locking would make no sense.
>   	 */
>   	ret = bd70528_get_direction(chip, offset);
> -	if (ret == 0)
> +	if (ret == GPIO_LINE_DIRECTION_OUT)
>   		ret = bd70528_gpio_get_o(bdgpio, offset);
> -	else if (ret == 1)
> +	else if (ret == GPIO_LINE_DIRECTION_IN)
>   		ret = bd70528_gpio_get_i(bdgpio, offset);
>   	else
>   		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
> diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
> index 5224a946e8ab..c0abc9c6851b 100644
> --- a/drivers/gpio/gpio-bd9571mwv.c
> +++ b/drivers/gpio/gpio-bd9571mwv.c
> @@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
>   	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
>   	if (ret < 0)
>   		return ret;
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return val & BIT(offset);
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
> index 8a33c2fc174d..26b40c8b8a12 100644
> --- a/drivers/gpio/gpio-dln2.c
> +++ b/drivers/gpio/gpio-dln2.c
> @@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
>   
>   	if (test_bit(offset, dln2->output_enabled))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
> @@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
>   	if (dir < 0)
>   		return dir;
>   
> -	if (dir == 1)
> +	if (dir == GPIO_LINE_DIRECTION_IN)
>   		return dln2_gpio_pin_get_in_val(dln2, offset);
>   
>   	return dln2_gpio_pin_get_out_val(dln2, offset);
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index fae327d5b06e..da1ef0b1c291 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
>   		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
>   	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
>   
> -	return !!(exar_get(chip, addr) & BIT(bit));
> +	if (exar_get(chip, addr) & BIT(bit))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
> index fdc639f856f1..cadd02993539 100644
> --- a/drivers/gpio/gpio-f7188x.c
> +++ b/drivers/gpio/gpio-f7188x.c
> @@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   
>   	superio_exit(sio->addr);
>   
> -	return !(dir & 1 << offset);
> +	if (dir & 1 << offset)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
> index 78a1db24e931..c22d6f94129c 100644
> --- a/drivers/gpio/gpio-gpio-mm.c
> +++ b/drivers/gpio/gpio-gpio-mm.c
> @@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
>   	const unsigned int port = offset / 8;
>   	const unsigned int mask = BIT(offset % 8);
>   
> -	return !!(gpiommgpio->io_state[port] & mask);
> +	if (gpiommgpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
> index 8aa23d70b1e6..a40bd56673fe 100644
> --- a/drivers/gpio/gpio-htc-egpio.c
> +++ b/drivers/gpio/gpio-htc-egpio.c
> @@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   
>   	egpio = gpiochip_get_data(chip);
>   
> -	return !test_bit(offset, &egpio->is_out);
> +	if (test_bit(offset, &egpio->is_out))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static void egpio_write_cache(struct egpio_info *ei)
> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>   
>   static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>   {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
> diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
> index ef51638f3f75..4ea15f08e0f4 100644
> --- a/drivers/gpio/gpio-kempld.c
> +++ b/drivers/gpio/gpio-kempld.c
> @@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
>   	struct kempld_device_data *pld = gpio->pld;
>   
> -	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
> +	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int kempld_gpio_pincount(struct kempld_device_data *pld)
> diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
> index 801995dd9b26..70fad87ff2db 100644
> --- a/drivers/gpio/gpio-lp873x.c
> +++ b/drivers/gpio/gpio-lp873x.c
> @@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned int offset)
>   {
>   	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int lp873x_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
> index a121c8f10610..e1244520cf7d 100644
> --- a/drivers/gpio/gpio-lp87565.c
> +++ b/drivers/gpio/gpio-lp87565.c
> @@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(val & BIT(offset));
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int lp87565_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
> index 7086f8b5388f..8f38303fcbc4 100644
> --- a/drivers/gpio/gpio-madera.c
> +++ b/drivers/gpio/gpio-madera.c
> @@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !!(val & MADERA_GP1_DIR_MASK);
> +	if (val & MADERA_GP1_DIR_MASK)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
> index 4b4b2ceb82fc..0696d5a21431 100644
> --- a/drivers/gpio/gpio-max3191x.c
> +++ b/drivers/gpio/gpio-max3191x.c
> @@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
>   
>   static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
>   {
> -	return 1; /* always in */
> +	return GPIO_LINE_DIRECTION_IN; /* always in */
>   }
>   
>   static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>   
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> index 6f904c874678..cd07c948649f 100644
> --- a/drivers/gpio/gpio-mmio.c
> +++ b/drivers/gpio/gpio-mmio.c
> @@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
>   static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
>   {
>   	/* Return 0 if output, 1 if input */
> -	if (gc->bgpio_dir_unreadable)
> -		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
> -	if (gc->reg_dir_out)
> -		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
> +	if (gc->bgpio_dir_unreadable) {
> +		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
> +	if (gc->reg_dir_out) {
> +		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
>   	if (gc->reg_dir_in)
> -		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
> +		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
> +			return GPIO_LINE_DIRECTION_OUT;
>   
>   	/* This should not happen */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 213aedc97dc2..47c172b2f5ad 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -34,14 +34,9 @@
>   
>   #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
>   
> -enum {
> -	GPIO_MOCKUP_DIR_IN = 0,
> -	GPIO_MOCKUP_DIR_OUT = 1,
> -};
> -
>   /*
>    * struct gpio_pin_status - structure describing a GPIO status
> - * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
> + * @dir:       Configures direction of gpio as "in" or "out"
>    * @value:     Configures status of the gpio as 0(low) or 1(high)
>    */
>   struct gpio_mockup_line_status {
> @@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
>   	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>   
>   	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
>   	__gpio_mockup_set(chip, offset, value);
>   	mutex_unlock(&chip->lock);
>   
> @@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
>   	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>   
>   	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
>   	mutex_unlock(&chip->lock);
>   
>   	return 0;
> diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
> index 3fd729994a38..8299909318f4 100644
> --- a/drivers/gpio/gpio-moxtet.c
> +++ b/drivers/gpio/gpio-moxtet.c
> @@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   
>   	/* All lines are hard wired to be either input or output, not both. */
>   	if (chip->desc->in_mask & BIT(offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   	else if (chip->desc->out_mask & BIT(offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   	else
>   		return -EINVAL;
>   }
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 6c0687694341..9b2adf0ef880 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   
>   	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
>   
> -	return !!(u & BIT(pin));
> +	if (u & BIT(pin))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
> diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
> index 5e5437a2c607..c4a314c68555 100644
> --- a/drivers/gpio/gpio-mxs.c
> +++ b/drivers/gpio/gpio-mxs.c
> @@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
>   	u32 dir;
>   
>   	dir = readl(port->base + PINCTRL_DOE(port));
> -	return !(dir & mask);
> +	if (dir & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static const struct platform_device_id mxs_gpio_ids[] = {
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index d0f27084a942..3bd8adaeed9e 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	struct gpio_bank *bank = gpiochip_get_data(chip);
>   
> -	return !!(readl_relaxed(bank->base + bank->regs->direction) &
> -		  BIT(offset));
> +	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>   	if (ret < 0)
>   		return ret;
>   
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
> index 5aa136a6a3e0..df51dd08bdfe 100644
> --- a/drivers/gpio/gpio-pci-idio-16.c
> +++ b/drivers/gpio/gpio-pci-idio-16.c
> @@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
>   	unsigned int offset)
>   {
>   	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int idio_16_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
> index 52f1647a46fd..44c1e4fc489f 100644
> --- a/drivers/gpio/gpio-pcie-idio-24.c
> +++ b/drivers/gpio/gpio-pcie-idio-24.c
> @@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
>   
>   	/* FET Outputs */
>   	if (offset < 24)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	/* Isolated Inputs */
>   	if (offset < 48)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
>   	/* TTL/CMOS I/O */
>   	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
> -	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
> +	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int idio_24_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
> index f809a5a8e9eb..1331b2a94679 100644
> --- a/drivers/gpio/gpio-pisosr.c
> +++ b/drivers/gpio/gpio-pisosr.c
> @@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned offset)
>   {
>   	/* This device always input */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int pisosr_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 722ce5cf861e..5df7782e348f 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct pl061 *pl061 = gpiochip_get_data(gc);
>   
> -	return !(readb(pl061->base + GPIODIR) & BIT(offset));
> +	if (readb(pl061->base + GPIODIR) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
> index b77ea16ffa03..bb100e0124e6 100644
> --- a/drivers/gpio/gpio-raspberrypi-exp.c
> +++ b/drivers/gpio/gpio-raspberrypi-exp.c
> @@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
>   			get.gpio);
>   		return ret ? ret : -EIO;
>   	}
> -	return !get.direction;
> +	if (get.direction)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 187984d26f47..d7e6e68c25af 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
>   
> -	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
> +	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
> index fdc7a9d5b382..d35169bde25a 100644
> --- a/drivers/gpio/gpio-reg.c
> +++ b/drivers/gpio/gpio-reg.c
> @@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct gpio_reg *r = to_gpio_reg(gc);
>   
> -	return r->direction & BIT(offset) ? 1 : 0;
> +	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
> +					    GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
> diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
> index 46b7cf23fb0f..edff5e81489f 100644
> --- a/drivers/gpio/gpio-sa1100.c
> +++ b/drivers/gpio/gpio-sa1100.c
> @@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
>   
> -	return !(readl_relaxed(gpdr) & BIT(offset));
> +	if (readl_relaxed(gpdr) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
> index 7d718557092e..b04c561f3280 100644
> --- a/drivers/gpio/gpio-sama5d2-piobu.c
> +++ b/drivers/gpio/gpio-sama5d2-piobu.c
> @@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return (ret == PIOBU_IN) ? 1 : 0;
> +	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
> +				   GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   /**
> @@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
>   	/* if pin is input, read value from PDS else read from SOD */
>   	int ret = sama5d2_piobu_get_direction(chip, pin);
>   
> -	if (ret == 1)
> +	if (ret == GPIO_LINE_DIRECTION_IN)
>   		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
> -	else if (!ret)
> +	else if (ret == GPIO_LINE_DIRECTION_OUT)
>   		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
>   
>   	if (ret < 0)
> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>   {
>   	struct sch_gpio *sch = gpiochip_get_data(gc);
>   
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static const struct gpio_chip sch_gpio_chip = {
> diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
> index 8ecf336c9af4..da01e1cad7cb 100644
> --- a/drivers/gpio/gpio-sch311x.c
> +++ b/drivers/gpio/gpio-sch311x.c
> @@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	data = inb(block->runtime_reg + block->config_regs[offset]);
>   	spin_unlock(&block->lock);
>   
> -	return !!(data & SCH311X_GPIO_CONF_DIR);
> +	if (data & SCH311X_GPIO_CONF_DIR)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
> index 006a7e6a75f2..311f66757b92 100644
> --- a/drivers/gpio/gpio-siox.c
> +++ b/drivers/gpio/gpio-siox.c
> @@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
>   static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	if (offset < 12)
> -		return 1; /* input */
> +		return GPIO_LINE_DIRECTION_IN;
>   	else
> -		return 0; /* output */
> +		return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpio_siox_probe(struct siox_device *sdevice)
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 994d542daf53..542706a852e6 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(ret & mask);
> +	if (ret & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int stmpe_gpio_direction_output(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
> index 75b1135b383a..6be0684cfa49 100644
> --- a/drivers/gpio/gpio-tc3589x.c
> +++ b/drivers/gpio/gpio-tc3589x.c
> @@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(ret & BIT(pos));
> +	if (ret & BIT(pos))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 8a01d3694b28..6fdfe4c5303e 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
>   
>   	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
>   
> -	return !(oe & pin_mask);
> +	if (oe & pin_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 8a2a69178925..57185b96c110 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
>   
>   	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
>   	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tegra186_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
> index ddad5c7ea617..d08d86a22b1f 100644
> --- a/drivers/gpio/gpio-thunderx.c
> +++ b/drivers/gpio/gpio-thunderx.c
> @@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
>   
>   	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
>   
> -	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
> +	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int thunderx_gpio_set_config(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
> index c8b34d787eed..99d5a84a9129 100644
> --- a/drivers/gpio/gpio-tpic2810.c
> +++ b/drivers/gpio/gpio-tpic2810.c
> @@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
>   				  unsigned offset)
>   {
>   	/* This device always output */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int tpic2810_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
> index 2eea98ff4ea3..1e9d8262d0ff 100644
> --- a/drivers/gpio/gpio-tps65086.c
> +++ b/drivers/gpio/gpio-tps65086.c
> @@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
>   				       unsigned offset)
>   {
>   	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int tps65086_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
> index 3ad68bd78282..510d9ed9fd2a 100644
> --- a/drivers/gpio/gpio-tps65912.c
> +++ b/drivers/gpio/gpio-tps65912.c
> @@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
>   		return ret;
>   
>   	if (val & GPIO_CFG_MASK)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   	else
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
> index aff6e504c666..f7f5f770e0fb 100644
> --- a/drivers/gpio/gpio-tps68470.c
> +++ b/drivers/gpio/gpio-tps68470.c
> @@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
>   	return !!(val & BIT(offset));
>   }
>   
> -/* Return 0 if output, 1 if input */
>   static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   				       unsigned int offset)
>   {
> @@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   
>   	/* rest are always outputs */
>   	if (offset >= TPS68470_N_REGULAR_GPIO)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
>   	if (ret) {
> @@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   	}
>   
>   	val &= TPS68470_GPIO_MODE_MASK;
> -	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
> +	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
> +						    GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
> index a3109bcaa0ac..5022e0ad0fae 100644
> --- a/drivers/gpio/gpio-tqmx86.c
> +++ b/drivers/gpio/gpio-tqmx86.c
> @@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
>   static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned int offset)
>   {
> -	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
> +	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void tqmx86_gpio_irq_mask(struct irq_data *data)
> diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
> index 1da8d0586329..d885032cf814 100644
> --- a/drivers/gpio/gpio-ts4900.c
> +++ b/drivers/gpio/gpio-ts4900.c
> @@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
>   
>   	regmap_read(priv->regmap, offset, &reg);
>   
> -	return !(reg & TS4900_GPIO_OE);
> +	if (reg & TS4900_GPIO_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int ts4900_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index fbfb648d3502..de249726230e 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
>   	if (ret < 0)
>   		return ret;
>   
> -	/* 1 = output, but gpiolib semantics are inverse so invert */
> -	ret = !(ret & d_msk);
> +	if (ret & d_msk)
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return ret;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int twl4030_set_gpio_dataout(int gpio, int enable)
> @@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
>   	/*
> -	 * Default 0 = output
> +	 * Default GPIO_LINE_DIRECTION_OUT
>   	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
>   	 */
> -	int ret = 0;
> +	int ret = GPIO_LINE_DIRECTION_OUT;
>   
>   	mutex_lock(&priv->mutex);
>   	if (offset < TWL4030_GPIO_MAX) {
> diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
> index c845b2ff1f43..648fb418d775 100644
> --- a/drivers/gpio/gpio-twl6040.c
> +++ b/drivers/gpio/gpio-twl6040.c
> @@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
>   
>   static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
> -	/* This means "out" */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
> index 93cdcc41e9fb..bd203e8fa58e 100644
> --- a/drivers/gpio/gpio-uniphier.c
> +++ b/drivers/gpio/gpio-uniphier.c
> @@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
>   static int uniphier_gpio_get_direction(struct gpio_chip *chip,
>   				       unsigned int offset)
>   {
> -	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
> +	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int uniphier_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>   	int ret, reg = to_reg(gpio, CTRL_OUT);
>   
>   	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	ret = regmap_read(wg->regmap, reg, &val);
>   	if (ret)
>   		return ret;
>   
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
> index e0ef66b6a237..fe456bea81f6 100644
> --- a/drivers/gpio/gpio-ws16c48.c
> +++ b/drivers/gpio/gpio-ws16c48.c
> @@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	const unsigned port = offset / 8;
>   	const unsigned mask = BIT(offset % 8);
>   
> -	return !!(ws16c48gpio->io_state[port] & mask);
> +	if (ws16c48gpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
> index a6e66ac18e1f..532b0df8a1f2 100644
> --- a/drivers/gpio/gpio-xgene.c
> +++ b/drivers/gpio/gpio-xgene.c
> @@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
>   	bit_offset = GPIO_BIT_OFFSET(offset);
>   
> -	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
> +	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
> index 05f1998c11a4..31b5072b2df0 100644
> --- a/drivers/gpio/gpio-xra1403.c
> +++ b/drivers/gpio/gpio-xra1403.c
> @@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
>   	if (ret)
>   		return ret;
>   
> -	return !!(val & BIT(offset % 8));
> +	if (val & BIT(offset % 8))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
> index 43d3fa5f511a..08d7c3b32038 100644
> --- a/drivers/gpio/gpio-xtensa.c
> +++ b/drivers/gpio/gpio-xtensa.c
> @@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
>   
>   static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
> -	return 1; /* input only */
> +	return GPIO_LINE_DIRECTION_IN; /* input only */
>   }
>   
>   static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
> @@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
>   
>   static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
> -	return 0; /* output only */
> +	return GPIO_LINE_DIRECTION_OUT; /* output only */
>   }
>   
>   static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index cd475ff4bcad..4c3f6370eab4 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
>    *
>    * This function returns the direction of the specified GPIO.
>    *
> - * Return: 0 for output, 1 for input
> + * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
>    */
>   static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   {
> @@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   
>   	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
>   
> -	return !(reg & BIT(bank_pin_num));
> +	if (reg & BIT(bank_pin_num))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   /**

-- 
Sathyanarayanan Kuppuswamy
Linux kernel developer

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

* Re: [alsa-devel] [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
@ 2019-11-06 17:35     ` Kuppuswamy Sathyanarayanan
  0 siblings, 0 replies; 52+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2019-11-06 17:35 UTC (permalink / raw)
  To: Matti Vaittinen, mazziesaccount
  Cc: alsa-devel, linux-aspeed, David Daney, Linus Walleij,
	Peter Tyser, Thierry Reding, Jonathan Hunter, Fabio Estevam,
	linux-stm32, Marek Vasut, Florian Fainelli, Kevin Hilman,
	Michal Simek, Marek Behun, Bartosz Golaszewski,
	Ludovic Desroches, bcm-kernel-feedback-list, Joel Stanley,
	Uwe Kleine-König, Bamvor Jian Zhang, NXP Linux Team,
	linux-pwm, Grygorii Strashko, Charles Keepax, Maxime Coquelin,
	linux-omap, Alexandre Torgue, Ray Jui, Sascha Hauer,
	William Breathitt Gray, linux-gpio, Richard Fitzgerald,
	Santosh Shilimkar, linux-tegra, Andy Shevchenko,
	linux-arm-kernel, Scott Branden, Masahiro Yamada, Andrew Jeffery,
	Enrico Weigelt, metux IT consult, linux-kernel,
	linux-renesas-soc, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo


On 11/6/19 12:54 AM, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
>
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> Acked-by: Scott Branden <scott.branden@broadcom.com>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> ---

For wcove GPIO driver,

Acked-by: Kuppuswamy Sathyanarayanan 
<sathyanarayanan.kuppuswamy@linux.intel.com>

>
> This patch contains same changes as v1 patches 2-61 did. v1 was splitted
> into small patches in order to help reviewing but squashing was
> requested by Linus Walleij. I maintained all acks/reviewed-by tags from
> v1 series - so acks/review-by tags in this patch mean that specific
> portion of changes have been acked/reviewed by tagger. Eg, whole patch
> has not been reviewed/acked by persons mentioned. Please let me know if
> this is not Ok to you.
>
>   drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>   drivers/gpio/gpio-104-idi-48.c      |  2 +-
>   drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>   drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>   drivers/gpio/gpio-amd-fch.c         |  2 +-
>   drivers/gpio/gpio-aspeed.c          |  7 +++----
>   drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>   drivers/gpio/gpio-bd70528.c         |  8 +++++---
>   drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>   drivers/gpio/gpio-dln2.c            |  6 +++---
>   drivers/gpio/gpio-exar.c            |  5 ++++-
>   drivers/gpio/gpio-f7188x.c          |  5 ++++-
>   drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>   drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>   drivers/gpio/gpio-ich.c             |  5 ++++-
>   drivers/gpio/gpio-kempld.c          |  5 ++++-
>   drivers/gpio/gpio-lp873x.c          |  2 +-
>   drivers/gpio/gpio-lp87565.c         |  5 ++++-
>   drivers/gpio/gpio-madera.c          |  5 ++++-
>   drivers/gpio/gpio-max3191x.c        |  2 +-
>   drivers/gpio/gpio-merrifield.c      |  5 ++++-
>   drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>   drivers/gpio/gpio-mockup.c          | 11 +++--------
>   drivers/gpio/gpio-moxtet.c          |  4 ++--
>   drivers/gpio/gpio-mvebu.c           |  5 ++++-
>   drivers/gpio/gpio-mxs.c             |  5 ++++-
>   drivers/gpio/gpio-omap.c            |  6 ++++--
>   drivers/gpio/gpio-pca953x.c         |  5 ++++-
>   drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>   drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>   drivers/gpio/gpio-pisosr.c          |  2 +-
>   drivers/gpio/gpio-pl061.c           |  5 ++++-
>   drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>   drivers/gpio/gpio-rcar.c            |  5 ++++-
>   drivers/gpio/gpio-reg.c             |  3 ++-
>   drivers/gpio/gpio-sa1100.c          |  5 ++++-
>   drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>   drivers/gpio/gpio-sch.c             |  5 ++++-
>   drivers/gpio/gpio-sch311x.c         |  5 ++++-
>   drivers/gpio/gpio-siox.c            |  4 ++--
>   drivers/gpio/gpio-stmpe.c           |  5 ++++-
>   drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>   drivers/gpio/gpio-tegra.c           |  5 ++++-
>   drivers/gpio/gpio-tegra186.c        |  4 ++--
>   drivers/gpio/gpio-thunderx.c        |  5 ++++-
>   drivers/gpio/gpio-tpic2810.c        |  2 +-
>   drivers/gpio/gpio-tps65086.c        |  2 +-
>   drivers/gpio/gpio-tps65912.c        |  4 ++--
>   drivers/gpio/gpio-tps68470.c        |  6 +++---
>   drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>   drivers/gpio/gpio-ts4900.c          |  5 ++++-
>   drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>   drivers/gpio/gpio-twl6040.c         |  3 +--
>   drivers/gpio/gpio-uniphier.c        |  5 ++++-
>   drivers/gpio/gpio-wcove.c           |  7 +++++--
>   drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>   drivers/gpio/gpio-xgene.c           |  5 ++++-
>   drivers/gpio/gpio-xra1403.c         |  5 ++++-
>   drivers/gpio/gpio-xtensa.c          |  4 ++--
>   drivers/gpio/gpio-zynq.c            |  7 +++++--
>   60 files changed, 211 insertions(+), 102 deletions(-)
>
> diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
> index a44fa8af5b0d..400c09b905f8 100644
> --- a/drivers/gpio/gpio-104-dio-48e.c
> +++ b/drivers/gpio/gpio-104-dio-48e.c
> @@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	const unsigned port = offset / 8;
>   	const unsigned mask = BIT(offset % 8);
>   
> -	return !!(dio48egpio->io_state[port] & mask);
> +	if (dio48egpio->io_state[port] & mask)
> +		return  GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
> index 79dead61e776..c50329ab493a 100644
> --- a/drivers/gpio/gpio-104-idi-48.c
> +++ b/drivers/gpio/gpio-104-idi-48.c
> @@ -53,7 +53,7 @@ struct idi_48_gpio {
>   
>   static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
> index 8d2f51cd9d91..5752d9dab148 100644
> --- a/drivers/gpio/gpio-104-idio-16.c
> +++ b/drivers/gpio/gpio-104-idio-16.c
> @@ -51,9 +51,9 @@ struct idio_16_gpio {
>   static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
> index 83a2286d93f6..173e06758e6c 100644
> --- a/drivers/gpio/gpio-74xx-mmio.c
> +++ b/drivers/gpio/gpio-74xx-mmio.c
> @@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
>   
> -	return !(priv->flags & MMIO_74XX_DIR_OUT);
> +	if (priv->flags & MMIO_74XX_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return  GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
> index 181df1581df5..4e44ba4d7423 100644
> --- a/drivers/gpio/gpio-amd-fch.c
> +++ b/drivers/gpio/gpio-amd-fch.c
> @@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
>   	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
>   	spin_unlock_irqrestore(&priv->lock, flags);
>   
> -	return ret;
> +	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void amd_fch_gpio_set(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index 09e53c5f3b0a..f1037b61f763 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   	u32 val;
>   
>   	if (!have_input(gpio, offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	if (!have_output(gpio, offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
>   	spin_lock_irqsave(&gpio->lock, flags);
>   
> @@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   
>   	spin_unlock_irqrestore(&gpio->lock, flags);
>   
> -	return !val;
> -
> +	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index 9fa6d3a967d2..4122683eb1f9 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
>   	u32 val;
>   
>   	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
> -	return !!val;
> +	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
> @@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
>   	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>   
>   	/* this function only applies to output pin */
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>   		goto out;
>   
>   	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
> @@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
>   	reg_base = kona_gpio->reg_base;
>   	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>   
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>   		reg_offset = GPIO_IN_STATUS(bank_id);
>   	else
>   		reg_offset = GPIO_OUT_STATUS(bank_id);
> diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
> index 0c1ead12d883..734be6b752d0 100644
> --- a/drivers/gpio/gpio-bd70528.c
> +++ b/drivers/gpio/gpio-bd70528.c
> @@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
>   		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
>   		return ret;
>   	}
> +	if (val & BD70528_GPIO_OUT_EN_MASK)
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return !(val & BD70528_GPIO_OUT_EN_MASK);
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> @@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
>   	 * locking would make no sense.
>   	 */
>   	ret = bd70528_get_direction(chip, offset);
> -	if (ret == 0)
> +	if (ret == GPIO_LINE_DIRECTION_OUT)
>   		ret = bd70528_gpio_get_o(bdgpio, offset);
> -	else if (ret == 1)
> +	else if (ret == GPIO_LINE_DIRECTION_IN)
>   		ret = bd70528_gpio_get_i(bdgpio, offset);
>   	else
>   		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
> diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
> index 5224a946e8ab..c0abc9c6851b 100644
> --- a/drivers/gpio/gpio-bd9571mwv.c
> +++ b/drivers/gpio/gpio-bd9571mwv.c
> @@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
>   	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
>   	if (ret < 0)
>   		return ret;
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return val & BIT(offset);
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
> index 8a33c2fc174d..26b40c8b8a12 100644
> --- a/drivers/gpio/gpio-dln2.c
> +++ b/drivers/gpio/gpio-dln2.c
> @@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
>   
>   	if (test_bit(offset, dln2->output_enabled))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
> @@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
>   	if (dir < 0)
>   		return dir;
>   
> -	if (dir == 1)
> +	if (dir == GPIO_LINE_DIRECTION_IN)
>   		return dln2_gpio_pin_get_in_val(dln2, offset);
>   
>   	return dln2_gpio_pin_get_out_val(dln2, offset);
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index fae327d5b06e..da1ef0b1c291 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
>   		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
>   	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
>   
> -	return !!(exar_get(chip, addr) & BIT(bit));
> +	if (exar_get(chip, addr) & BIT(bit))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
> index fdc639f856f1..cadd02993539 100644
> --- a/drivers/gpio/gpio-f7188x.c
> +++ b/drivers/gpio/gpio-f7188x.c
> @@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   
>   	superio_exit(sio->addr);
>   
> -	return !(dir & 1 << offset);
> +	if (dir & 1 << offset)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
> index 78a1db24e931..c22d6f94129c 100644
> --- a/drivers/gpio/gpio-gpio-mm.c
> +++ b/drivers/gpio/gpio-gpio-mm.c
> @@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
>   	const unsigned int port = offset / 8;
>   	const unsigned int mask = BIT(offset % 8);
>   
> -	return !!(gpiommgpio->io_state[port] & mask);
> +	if (gpiommgpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
> index 8aa23d70b1e6..a40bd56673fe 100644
> --- a/drivers/gpio/gpio-htc-egpio.c
> +++ b/drivers/gpio/gpio-htc-egpio.c
> @@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   
>   	egpio = gpiochip_get_data(chip);
>   
> -	return !test_bit(offset, &egpio->is_out);
> +	if (test_bit(offset, &egpio->is_out))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static void egpio_write_cache(struct egpio_info *ei)
> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>   
>   static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>   {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
> diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
> index ef51638f3f75..4ea15f08e0f4 100644
> --- a/drivers/gpio/gpio-kempld.c
> +++ b/drivers/gpio/gpio-kempld.c
> @@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
>   	struct kempld_device_data *pld = gpio->pld;
>   
> -	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
> +	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int kempld_gpio_pincount(struct kempld_device_data *pld)
> diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
> index 801995dd9b26..70fad87ff2db 100644
> --- a/drivers/gpio/gpio-lp873x.c
> +++ b/drivers/gpio/gpio-lp873x.c
> @@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned int offset)
>   {
>   	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int lp873x_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
> index a121c8f10610..e1244520cf7d 100644
> --- a/drivers/gpio/gpio-lp87565.c
> +++ b/drivers/gpio/gpio-lp87565.c
> @@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(val & BIT(offset));
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int lp87565_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
> index 7086f8b5388f..8f38303fcbc4 100644
> --- a/drivers/gpio/gpio-madera.c
> +++ b/drivers/gpio/gpio-madera.c
> @@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !!(val & MADERA_GP1_DIR_MASK);
> +	if (val & MADERA_GP1_DIR_MASK)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
> index 4b4b2ceb82fc..0696d5a21431 100644
> --- a/drivers/gpio/gpio-max3191x.c
> +++ b/drivers/gpio/gpio-max3191x.c
> @@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
>   
>   static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
>   {
> -	return 1; /* always in */
> +	return GPIO_LINE_DIRECTION_IN; /* always in */
>   }
>   
>   static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>   
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> index 6f904c874678..cd07c948649f 100644
> --- a/drivers/gpio/gpio-mmio.c
> +++ b/drivers/gpio/gpio-mmio.c
> @@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
>   static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
>   {
>   	/* Return 0 if output, 1 if input */
> -	if (gc->bgpio_dir_unreadable)
> -		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
> -	if (gc->reg_dir_out)
> -		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
> +	if (gc->bgpio_dir_unreadable) {
> +		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
> +	if (gc->reg_dir_out) {
> +		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
>   	if (gc->reg_dir_in)
> -		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
> +		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
> +			return GPIO_LINE_DIRECTION_OUT;
>   
>   	/* This should not happen */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 213aedc97dc2..47c172b2f5ad 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -34,14 +34,9 @@
>   
>   #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
>   
> -enum {
> -	GPIO_MOCKUP_DIR_IN = 0,
> -	GPIO_MOCKUP_DIR_OUT = 1,
> -};
> -
>   /*
>    * struct gpio_pin_status - structure describing a GPIO status
> - * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
> + * @dir:       Configures direction of gpio as "in" or "out"
>    * @value:     Configures status of the gpio as 0(low) or 1(high)
>    */
>   struct gpio_mockup_line_status {
> @@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
>   	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>   
>   	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
>   	__gpio_mockup_set(chip, offset, value);
>   	mutex_unlock(&chip->lock);
>   
> @@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
>   	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>   
>   	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
>   	mutex_unlock(&chip->lock);
>   
>   	return 0;
> diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
> index 3fd729994a38..8299909318f4 100644
> --- a/drivers/gpio/gpio-moxtet.c
> +++ b/drivers/gpio/gpio-moxtet.c
> @@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   
>   	/* All lines are hard wired to be either input or output, not both. */
>   	if (chip->desc->in_mask & BIT(offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   	else if (chip->desc->out_mask & BIT(offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   	else
>   		return -EINVAL;
>   }
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 6c0687694341..9b2adf0ef880 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   
>   	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
>   
> -	return !!(u & BIT(pin));
> +	if (u & BIT(pin))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
> diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
> index 5e5437a2c607..c4a314c68555 100644
> --- a/drivers/gpio/gpio-mxs.c
> +++ b/drivers/gpio/gpio-mxs.c
> @@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
>   	u32 dir;
>   
>   	dir = readl(port->base + PINCTRL_DOE(port));
> -	return !(dir & mask);
> +	if (dir & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static const struct platform_device_id mxs_gpio_ids[] = {
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index d0f27084a942..3bd8adaeed9e 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	struct gpio_bank *bank = gpiochip_get_data(chip);
>   
> -	return !!(readl_relaxed(bank->base + bank->regs->direction) &
> -		  BIT(offset));
> +	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>   	if (ret < 0)
>   		return ret;
>   
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
> index 5aa136a6a3e0..df51dd08bdfe 100644
> --- a/drivers/gpio/gpio-pci-idio-16.c
> +++ b/drivers/gpio/gpio-pci-idio-16.c
> @@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
>   	unsigned int offset)
>   {
>   	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int idio_16_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
> index 52f1647a46fd..44c1e4fc489f 100644
> --- a/drivers/gpio/gpio-pcie-idio-24.c
> +++ b/drivers/gpio/gpio-pcie-idio-24.c
> @@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
>   
>   	/* FET Outputs */
>   	if (offset < 24)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	/* Isolated Inputs */
>   	if (offset < 48)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
>   	/* TTL/CMOS I/O */
>   	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
> -	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
> +	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int idio_24_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
> index f809a5a8e9eb..1331b2a94679 100644
> --- a/drivers/gpio/gpio-pisosr.c
> +++ b/drivers/gpio/gpio-pisosr.c
> @@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned offset)
>   {
>   	/* This device always input */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int pisosr_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 722ce5cf861e..5df7782e348f 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct pl061 *pl061 = gpiochip_get_data(gc);
>   
> -	return !(readb(pl061->base + GPIODIR) & BIT(offset));
> +	if (readb(pl061->base + GPIODIR) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
> index b77ea16ffa03..bb100e0124e6 100644
> --- a/drivers/gpio/gpio-raspberrypi-exp.c
> +++ b/drivers/gpio/gpio-raspberrypi-exp.c
> @@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
>   			get.gpio);
>   		return ret ? ret : -EIO;
>   	}
> -	return !get.direction;
> +	if (get.direction)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 187984d26f47..d7e6e68c25af 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
>   
> -	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
> +	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
> index fdc7a9d5b382..d35169bde25a 100644
> --- a/drivers/gpio/gpio-reg.c
> +++ b/drivers/gpio/gpio-reg.c
> @@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct gpio_reg *r = to_gpio_reg(gc);
>   
> -	return r->direction & BIT(offset) ? 1 : 0;
> +	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
> +					    GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
> diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
> index 46b7cf23fb0f..edff5e81489f 100644
> --- a/drivers/gpio/gpio-sa1100.c
> +++ b/drivers/gpio/gpio-sa1100.c
> @@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
>   
> -	return !(readl_relaxed(gpdr) & BIT(offset));
> +	if (readl_relaxed(gpdr) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
> index 7d718557092e..b04c561f3280 100644
> --- a/drivers/gpio/gpio-sama5d2-piobu.c
> +++ b/drivers/gpio/gpio-sama5d2-piobu.c
> @@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return (ret == PIOBU_IN) ? 1 : 0;
> +	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
> +				   GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   /**
> @@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
>   	/* if pin is input, read value from PDS else read from SOD */
>   	int ret = sama5d2_piobu_get_direction(chip, pin);
>   
> -	if (ret == 1)
> +	if (ret == GPIO_LINE_DIRECTION_IN)
>   		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
> -	else if (!ret)
> +	else if (ret == GPIO_LINE_DIRECTION_OUT)
>   		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
>   
>   	if (ret < 0)
> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>   {
>   	struct sch_gpio *sch = gpiochip_get_data(gc);
>   
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static const struct gpio_chip sch_gpio_chip = {
> diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
> index 8ecf336c9af4..da01e1cad7cb 100644
> --- a/drivers/gpio/gpio-sch311x.c
> +++ b/drivers/gpio/gpio-sch311x.c
> @@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	data = inb(block->runtime_reg + block->config_regs[offset]);
>   	spin_unlock(&block->lock);
>   
> -	return !!(data & SCH311X_GPIO_CONF_DIR);
> +	if (data & SCH311X_GPIO_CONF_DIR)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
> index 006a7e6a75f2..311f66757b92 100644
> --- a/drivers/gpio/gpio-siox.c
> +++ b/drivers/gpio/gpio-siox.c
> @@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
>   static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	if (offset < 12)
> -		return 1; /* input */
> +		return GPIO_LINE_DIRECTION_IN;
>   	else
> -		return 0; /* output */
> +		return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpio_siox_probe(struct siox_device *sdevice)
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 994d542daf53..542706a852e6 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(ret & mask);
> +	if (ret & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int stmpe_gpio_direction_output(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
> index 75b1135b383a..6be0684cfa49 100644
> --- a/drivers/gpio/gpio-tc3589x.c
> +++ b/drivers/gpio/gpio-tc3589x.c
> @@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(ret & BIT(pos));
> +	if (ret & BIT(pos))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 8a01d3694b28..6fdfe4c5303e 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
>   
>   	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
>   
> -	return !(oe & pin_mask);
> +	if (oe & pin_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 8a2a69178925..57185b96c110 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
>   
>   	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
>   	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tegra186_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
> index ddad5c7ea617..d08d86a22b1f 100644
> --- a/drivers/gpio/gpio-thunderx.c
> +++ b/drivers/gpio/gpio-thunderx.c
> @@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
>   
>   	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
>   
> -	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
> +	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int thunderx_gpio_set_config(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
> index c8b34d787eed..99d5a84a9129 100644
> --- a/drivers/gpio/gpio-tpic2810.c
> +++ b/drivers/gpio/gpio-tpic2810.c
> @@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
>   				  unsigned offset)
>   {
>   	/* This device always output */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int tpic2810_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
> index 2eea98ff4ea3..1e9d8262d0ff 100644
> --- a/drivers/gpio/gpio-tps65086.c
> +++ b/drivers/gpio/gpio-tps65086.c
> @@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
>   				       unsigned offset)
>   {
>   	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int tps65086_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
> index 3ad68bd78282..510d9ed9fd2a 100644
> --- a/drivers/gpio/gpio-tps65912.c
> +++ b/drivers/gpio/gpio-tps65912.c
> @@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
>   		return ret;
>   
>   	if (val & GPIO_CFG_MASK)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   	else
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
> index aff6e504c666..f7f5f770e0fb 100644
> --- a/drivers/gpio/gpio-tps68470.c
> +++ b/drivers/gpio/gpio-tps68470.c
> @@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
>   	return !!(val & BIT(offset));
>   }
>   
> -/* Return 0 if output, 1 if input */
>   static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   				       unsigned int offset)
>   {
> @@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   
>   	/* rest are always outputs */
>   	if (offset >= TPS68470_N_REGULAR_GPIO)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
>   	if (ret) {
> @@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   	}
>   
>   	val &= TPS68470_GPIO_MODE_MASK;
> -	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
> +	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
> +						    GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
> index a3109bcaa0ac..5022e0ad0fae 100644
> --- a/drivers/gpio/gpio-tqmx86.c
> +++ b/drivers/gpio/gpio-tqmx86.c
> @@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
>   static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned int offset)
>   {
> -	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
> +	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void tqmx86_gpio_irq_mask(struct irq_data *data)
> diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
> index 1da8d0586329..d885032cf814 100644
> --- a/drivers/gpio/gpio-ts4900.c
> +++ b/drivers/gpio/gpio-ts4900.c
> @@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
>   
>   	regmap_read(priv->regmap, offset, &reg);
>   
> -	return !(reg & TS4900_GPIO_OE);
> +	if (reg & TS4900_GPIO_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int ts4900_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index fbfb648d3502..de249726230e 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
>   	if (ret < 0)
>   		return ret;
>   
> -	/* 1 = output, but gpiolib semantics are inverse so invert */
> -	ret = !(ret & d_msk);
> +	if (ret & d_msk)
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return ret;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int twl4030_set_gpio_dataout(int gpio, int enable)
> @@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
>   	/*
> -	 * Default 0 = output
> +	 * Default GPIO_LINE_DIRECTION_OUT
>   	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
>   	 */
> -	int ret = 0;
> +	int ret = GPIO_LINE_DIRECTION_OUT;
>   
>   	mutex_lock(&priv->mutex);
>   	if (offset < TWL4030_GPIO_MAX) {
> diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
> index c845b2ff1f43..648fb418d775 100644
> --- a/drivers/gpio/gpio-twl6040.c
> +++ b/drivers/gpio/gpio-twl6040.c
> @@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
>   
>   static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
> -	/* This means "out" */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
> index 93cdcc41e9fb..bd203e8fa58e 100644
> --- a/drivers/gpio/gpio-uniphier.c
> +++ b/drivers/gpio/gpio-uniphier.c
> @@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
>   static int uniphier_gpio_get_direction(struct gpio_chip *chip,
>   				       unsigned int offset)
>   {
> -	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
> +	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int uniphier_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>   	int ret, reg = to_reg(gpio, CTRL_OUT);
>   
>   	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	ret = regmap_read(wg->regmap, reg, &val);
>   	if (ret)
>   		return ret;
>   
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
> index e0ef66b6a237..fe456bea81f6 100644
> --- a/drivers/gpio/gpio-ws16c48.c
> +++ b/drivers/gpio/gpio-ws16c48.c
> @@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	const unsigned port = offset / 8;
>   	const unsigned mask = BIT(offset % 8);
>   
> -	return !!(ws16c48gpio->io_state[port] & mask);
> +	if (ws16c48gpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
> index a6e66ac18e1f..532b0df8a1f2 100644
> --- a/drivers/gpio/gpio-xgene.c
> +++ b/drivers/gpio/gpio-xgene.c
> @@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
>   	bit_offset = GPIO_BIT_OFFSET(offset);
>   
> -	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
> +	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
> index 05f1998c11a4..31b5072b2df0 100644
> --- a/drivers/gpio/gpio-xra1403.c
> +++ b/drivers/gpio/gpio-xra1403.c
> @@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
>   	if (ret)
>   		return ret;
>   
> -	return !!(val & BIT(offset % 8));
> +	if (val & BIT(offset % 8))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
> index 43d3fa5f511a..08d7c3b32038 100644
> --- a/drivers/gpio/gpio-xtensa.c
> +++ b/drivers/gpio/gpio-xtensa.c
> @@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
>   
>   static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
> -	return 1; /* input only */
> +	return GPIO_LINE_DIRECTION_IN; /* input only */
>   }
>   
>   static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
> @@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
>   
>   static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
> -	return 0; /* output only */
> +	return GPIO_LINE_DIRECTION_OUT; /* output only */
>   }
>   
>   static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index cd475ff4bcad..4c3f6370eab4 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
>    *
>    * This function returns the direction of the specified GPIO.
>    *
> - * Return: 0 for output, 1 for input
> + * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
>    */
>   static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   {
> @@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   
>   	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
>   
> -	return !(reg & BIT(bank_pin_num));
> +	if (reg & BIT(bank_pin_num))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   /**

-- 
Sathyanarayanan Kuppuswamy
Linux kernel developer

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
@ 2019-11-06 17:35     ` Kuppuswamy Sathyanarayanan
  0 siblings, 0 replies; 52+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2019-11-06 17:35 UTC (permalink / raw)
  To: Matti Vaittinen, mazziesaccount
  Cc: alsa-devel, linux-aspeed, David Daney, Linus Walleij,
	Peter Tyser, Thierry Reding, Jonathan Hunter, Fabio Estevam,
	linux-stm32, Marek Vasut, Florian Fainelli, Kevin Hilman,
	Michal Simek, Marek Behun, Bartosz Golaszewski,
	Ludovic Desroches, bcm-kernel-feedback-list, Joel Stanley,
	Uwe Kleine-König, Bamvor Jian Zhang, NXP Linux Team,
	linux-pwm, Grygorii Strashko, Charles Keepax, Maxime Coquelin,
	linux-omap, Alexandre Torgue, Ray Jui, Sascha Hauer,
	William Breathitt Gray, linux-gpio, Richard Fitzgerald,
	Santosh Shilimkar, linux-tegra, Andy Shevchenko,
	linux-arm-kernel, Scott Branden, Masahiro Yamada, Andrew Jeffery,
	Enrico Weigelt, metux IT consult, linux-kernel,
	linux-renesas-soc, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo


On 11/6/19 12:54 AM, Matti Vaittinen wrote:
> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
>
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> Acked-by: Scott Branden <scott.branden@broadcom.com>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> ---

For wcove GPIO driver,

Acked-by: Kuppuswamy Sathyanarayanan 
<sathyanarayanan.kuppuswamy@linux.intel.com>

>
> This patch contains same changes as v1 patches 2-61 did. v1 was splitted
> into small patches in order to help reviewing but squashing was
> requested by Linus Walleij. I maintained all acks/reviewed-by tags from
> v1 series - so acks/review-by tags in this patch mean that specific
> portion of changes have been acked/reviewed by tagger. Eg, whole patch
> has not been reviewed/acked by persons mentioned. Please let me know if
> this is not Ok to you.
>
>   drivers/gpio/gpio-104-dio-48e.c     |  5 ++++-
>   drivers/gpio/gpio-104-idi-48.c      |  2 +-
>   drivers/gpio/gpio-104-idio-16.c     |  4 ++--
>   drivers/gpio/gpio-74xx-mmio.c       |  5 ++++-
>   drivers/gpio/gpio-amd-fch.c         |  2 +-
>   drivers/gpio/gpio-aspeed.c          |  7 +++----
>   drivers/gpio/gpio-bcm-kona.c        |  6 +++---
>   drivers/gpio/gpio-bd70528.c         |  8 +++++---
>   drivers/gpio/gpio-bd9571mwv.c       |  4 +++-
>   drivers/gpio/gpio-dln2.c            |  6 +++---
>   drivers/gpio/gpio-exar.c            |  5 ++++-
>   drivers/gpio/gpio-f7188x.c          |  5 ++++-
>   drivers/gpio/gpio-gpio-mm.c         |  5 ++++-
>   drivers/gpio/gpio-htc-egpio.c       |  5 ++++-
>   drivers/gpio/gpio-ich.c             |  5 ++++-
>   drivers/gpio/gpio-kempld.c          |  5 ++++-
>   drivers/gpio/gpio-lp873x.c          |  2 +-
>   drivers/gpio/gpio-lp87565.c         |  5 ++++-
>   drivers/gpio/gpio-madera.c          |  5 ++++-
>   drivers/gpio/gpio-max3191x.c        |  2 +-
>   drivers/gpio/gpio-merrifield.c      |  5 ++++-
>   drivers/gpio/gpio-mmio.c            | 21 +++++++++++++++------
>   drivers/gpio/gpio-mockup.c          | 11 +++--------
>   drivers/gpio/gpio-moxtet.c          |  4 ++--
>   drivers/gpio/gpio-mvebu.c           |  5 ++++-
>   drivers/gpio/gpio-mxs.c             |  5 ++++-
>   drivers/gpio/gpio-omap.c            |  6 ++++--
>   drivers/gpio/gpio-pca953x.c         |  5 ++++-
>   drivers/gpio/gpio-pci-idio-16.c     |  4 ++--
>   drivers/gpio/gpio-pcie-idio-24.c    |  9 ++++++---
>   drivers/gpio/gpio-pisosr.c          |  2 +-
>   drivers/gpio/gpio-pl061.c           |  5 ++++-
>   drivers/gpio/gpio-raspberrypi-exp.c |  5 ++++-
>   drivers/gpio/gpio-rcar.c            |  5 ++++-
>   drivers/gpio/gpio-reg.c             |  3 ++-
>   drivers/gpio/gpio-sa1100.c          |  5 ++++-
>   drivers/gpio/gpio-sama5d2-piobu.c   |  7 ++++---
>   drivers/gpio/gpio-sch.c             |  5 ++++-
>   drivers/gpio/gpio-sch311x.c         |  5 ++++-
>   drivers/gpio/gpio-siox.c            |  4 ++--
>   drivers/gpio/gpio-stmpe.c           |  5 ++++-
>   drivers/gpio/gpio-tc3589x.c         |  5 ++++-
>   drivers/gpio/gpio-tegra.c           |  5 ++++-
>   drivers/gpio/gpio-tegra186.c        |  4 ++--
>   drivers/gpio/gpio-thunderx.c        |  5 ++++-
>   drivers/gpio/gpio-tpic2810.c        |  2 +-
>   drivers/gpio/gpio-tps65086.c        |  2 +-
>   drivers/gpio/gpio-tps65912.c        |  4 ++--
>   drivers/gpio/gpio-tps68470.c        |  6 +++---
>   drivers/gpio/gpio-tqmx86.c          |  5 ++++-
>   drivers/gpio/gpio-ts4900.c          |  5 ++++-
>   drivers/gpio/gpio-twl4030.c         | 10 +++++-----
>   drivers/gpio/gpio-twl6040.c         |  3 +--
>   drivers/gpio/gpio-uniphier.c        |  5 ++++-
>   drivers/gpio/gpio-wcove.c           |  7 +++++--
>   drivers/gpio/gpio-ws16c48.c         |  5 ++++-
>   drivers/gpio/gpio-xgene.c           |  5 ++++-
>   drivers/gpio/gpio-xra1403.c         |  5 ++++-
>   drivers/gpio/gpio-xtensa.c          |  4 ++--
>   drivers/gpio/gpio-zynq.c            |  7 +++++--
>   60 files changed, 211 insertions(+), 102 deletions(-)
>
> diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
> index a44fa8af5b0d..400c09b905f8 100644
> --- a/drivers/gpio/gpio-104-dio-48e.c
> +++ b/drivers/gpio/gpio-104-dio-48e.c
> @@ -59,7 +59,10 @@ static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	const unsigned port = offset / 8;
>   	const unsigned mask = BIT(offset % 8);
>   
> -	return !!(dio48egpio->io_state[port] & mask);
> +	if (dio48egpio->io_state[port] & mask)
> +		return  GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
> index 79dead61e776..c50329ab493a 100644
> --- a/drivers/gpio/gpio-104-idi-48.c
> +++ b/drivers/gpio/gpio-104-idi-48.c
> @@ -53,7 +53,7 @@ struct idi_48_gpio {
>   
>   static int idi_48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int idi_48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
> index 8d2f51cd9d91..5752d9dab148 100644
> --- a/drivers/gpio/gpio-104-idio-16.c
> +++ b/drivers/gpio/gpio-104-idio-16.c
> @@ -51,9 +51,9 @@ struct idio_16_gpio {
>   static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
> index 83a2286d93f6..173e06758e6c 100644
> --- a/drivers/gpio/gpio-74xx-mmio.c
> +++ b/drivers/gpio/gpio-74xx-mmio.c
> @@ -77,7 +77,10 @@ static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct mmio_74xx_gpio_priv *priv = gpiochip_get_data(gc);
>   
> -	return !(priv->flags & MMIO_74XX_DIR_OUT);
> +	if (priv->flags & MMIO_74XX_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return  GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
> index 181df1581df5..4e44ba4d7423 100644
> --- a/drivers/gpio/gpio-amd-fch.c
> +++ b/drivers/gpio/gpio-amd-fch.c
> @@ -92,7 +92,7 @@ static int amd_fch_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
>   	ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_DIRECTION);
>   	spin_unlock_irqrestore(&priv->lock, flags);
>   
> -	return ret;
> +	return ret ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void amd_fch_gpio_set(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
> index 09e53c5f3b0a..f1037b61f763 100644
> --- a/drivers/gpio/gpio-aspeed.c
> +++ b/drivers/gpio/gpio-aspeed.c
> @@ -487,10 +487,10 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   	u32 val;
>   
>   	if (!have_input(gpio, offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	if (!have_output(gpio, offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
>   	spin_lock_irqsave(&gpio->lock, flags);
>   
> @@ -498,8 +498,7 @@ static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   
>   	spin_unlock_irqrestore(&gpio->lock, flags);
>   
> -	return !val;
> -
> +	return val ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static inline int irqd_to_aspeed_gpio_data(struct irq_data *d,
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index 9fa6d3a967d2..4122683eb1f9 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -127,7 +127,7 @@ static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio)
>   	u32 val;
>   
>   	val = readl(reg_base + GPIO_CONTROL(gpio)) & GPIO_GPCTR0_IOTR_MASK;
> -	return !!val;
> +	return val ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
> @@ -144,7 +144,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
>   	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>   
>   	/* this function only applies to output pin */
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>   		goto out;
>   
>   	reg_offset = value ? GPIO_OUT_SET(bank_id) : GPIO_OUT_CLEAR(bank_id);
> @@ -170,7 +170,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
>   	reg_base = kona_gpio->reg_base;
>   	raw_spin_lock_irqsave(&kona_gpio->lock, flags);
>   
> -	if (bcm_kona_gpio_get_dir(chip, gpio) == 1)
> +	if (bcm_kona_gpio_get_dir(chip, gpio) == GPIO_LINE_DIRECTION_IN)
>   		reg_offset = GPIO_IN_STATUS(bank_id);
>   	else
>   		reg_offset = GPIO_OUT_STATUS(bank_id);
> diff --git a/drivers/gpio/gpio-bd70528.c b/drivers/gpio/gpio-bd70528.c
> index 0c1ead12d883..734be6b752d0 100644
> --- a/drivers/gpio/gpio-bd70528.c
> +++ b/drivers/gpio/gpio-bd70528.c
> @@ -54,8 +54,10 @@ static int bd70528_get_direction(struct gpio_chip *chip, unsigned int offset)
>   		dev_err(bdgpio->chip.dev, "Could not read gpio direction\n");
>   		return ret;
>   	}
> +	if (val & BD70528_GPIO_OUT_EN_MASK)
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return !(val & BD70528_GPIO_OUT_EN_MASK);
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int bd70528_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> @@ -166,9 +168,9 @@ static int bd70528_gpio_get(struct gpio_chip *chip, unsigned int offset)
>   	 * locking would make no sense.
>   	 */
>   	ret = bd70528_get_direction(chip, offset);
> -	if (ret == 0)
> +	if (ret == GPIO_LINE_DIRECTION_OUT)
>   		ret = bd70528_gpio_get_o(bdgpio, offset);
> -	else if (ret == 1)
> +	else if (ret == GPIO_LINE_DIRECTION_IN)
>   		ret = bd70528_gpio_get_i(bdgpio, offset);
>   	else
>   		dev_err(bdgpio->chip.dev, "failed to read GPIO direction\n");
> diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c
> index 5224a946e8ab..c0abc9c6851b 100644
> --- a/drivers/gpio/gpio-bd9571mwv.c
> +++ b/drivers/gpio/gpio-bd9571mwv.c
> @@ -37,8 +37,10 @@ static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip,
>   	ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val);
>   	if (ret < 0)
>   		return ret;
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return val & BIT(offset);
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c
> index 8a33c2fc174d..26b40c8b8a12 100644
> --- a/drivers/gpio/gpio-dln2.c
> +++ b/drivers/gpio/gpio-dln2.c
> @@ -200,9 +200,9 @@ static int dln2_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	struct dln2_gpio *dln2 = gpiochip_get_data(chip);
>   
>   	if (test_bit(offset, dln2->output_enabled))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
> @@ -214,7 +214,7 @@ static int dln2_gpio_get(struct gpio_chip *chip, unsigned int offset)
>   	if (dir < 0)
>   		return dir;
>   
> -	if (dir == 1)
> +	if (dir == GPIO_LINE_DIRECTION_IN)
>   		return dln2_gpio_pin_get_in_val(dln2, offset);
>   
>   	return dln2_gpio_pin_get_out_val(dln2, offset);
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index fae327d5b06e..da1ef0b1c291 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -77,7 +77,10 @@ static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
>   		EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
>   	unsigned int bit  = (offset + exar_gpio->first_pin) % 8;
>   
> -	return !!(exar_get(chip, addr) & BIT(bit));
> +	if (exar_get(chip, addr) & BIT(bit))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
> index fdc639f856f1..cadd02993539 100644
> --- a/drivers/gpio/gpio-f7188x.c
> +++ b/drivers/gpio/gpio-f7188x.c
> @@ -250,7 +250,10 @@ static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   
>   	superio_exit(sio->addr);
>   
> -	return !(dir & 1 << offset);
> +	if (dir & 1 << offset)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-gpio-mm.c b/drivers/gpio/gpio-gpio-mm.c
> index 78a1db24e931..c22d6f94129c 100644
> --- a/drivers/gpio/gpio-gpio-mm.c
> +++ b/drivers/gpio/gpio-gpio-mm.c
> @@ -52,7 +52,10 @@ static int gpiomm_gpio_get_direction(struct gpio_chip *chip,
>   	const unsigned int port = offset / 8;
>   	const unsigned int mask = BIT(offset % 8);
>   
> -	return !!(gpiommgpio->io_state[port] & mask);
> +	if (gpiommgpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpiomm_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
> index 8aa23d70b1e6..a40bd56673fe 100644
> --- a/drivers/gpio/gpio-htc-egpio.c
> +++ b/drivers/gpio/gpio-htc-egpio.c
> @@ -220,7 +220,10 @@ static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   
>   	egpio = gpiochip_get_data(chip);
>   
> -	return !test_bit(offset, &egpio->is_out);
> +	if (test_bit(offset, &egpio->is_out))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static void egpio_write_cache(struct egpio_info *ei)
> diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
> index 90bf7742f9b0..2f086d0aa1f4 100644
> --- a/drivers/gpio/gpio-ich.c
> +++ b/drivers/gpio/gpio-ich.c
> @@ -159,7 +159,10 @@ static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
>   
>   static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
>   {
> -	return ichx_read_bit(GPIO_IO_SEL, nr);
> +	if (ichx_read_bit(GPIO_IO_SEL, nr))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
> diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
> index ef51638f3f75..4ea15f08e0f4 100644
> --- a/drivers/gpio/gpio-kempld.c
> +++ b/drivers/gpio/gpio-kempld.c
> @@ -104,7 +104,10 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	struct kempld_gpio_data *gpio = gpiochip_get_data(chip);
>   	struct kempld_device_data *pld = gpio->pld;
>   
> -	return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
> +	if (kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int kempld_gpio_pincount(struct kempld_device_data *pld)
> diff --git a/drivers/gpio/gpio-lp873x.c b/drivers/gpio/gpio-lp873x.c
> index 801995dd9b26..70fad87ff2db 100644
> --- a/drivers/gpio/gpio-lp873x.c
> +++ b/drivers/gpio/gpio-lp873x.c
> @@ -33,7 +33,7 @@ static int lp873x_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned int offset)
>   {
>   	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int lp873x_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
> index a121c8f10610..e1244520cf7d 100644
> --- a/drivers/gpio/gpio-lp87565.c
> +++ b/drivers/gpio/gpio-lp87565.c
> @@ -57,7 +57,10 @@ static int lp87565_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(val & BIT(offset));
> +	if (val & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int lp87565_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
> index 7086f8b5388f..8f38303fcbc4 100644
> --- a/drivers/gpio/gpio-madera.c
> +++ b/drivers/gpio/gpio-madera.c
> @@ -34,7 +34,10 @@ static int madera_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !!(val & MADERA_GP1_DIR_MASK);
> +	if (val & MADERA_GP1_DIR_MASK)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c
> index 4b4b2ceb82fc..0696d5a21431 100644
> --- a/drivers/gpio/gpio-max3191x.c
> +++ b/drivers/gpio/gpio-max3191x.c
> @@ -94,7 +94,7 @@ DECLARE_CRC8_TABLE(max3191x_crc8);
>   
>   static int max3191x_get_direction(struct gpio_chip *gpio, unsigned int offset)
>   {
> -	return 1; /* always in */
> +	return GPIO_LINE_DIRECTION_IN; /* always in */
>   }
>   
>   static int max3191x_direction_input(struct gpio_chip *gpio, unsigned int offset)
> diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
> index 2f1e9da81c1e..d4fa6e9560f3 100644
> --- a/drivers/gpio/gpio-merrifield.c
> +++ b/drivers/gpio/gpio-merrifield.c
> @@ -162,7 +162,10 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	void __iomem *gpdr = gpio_reg(chip, offset, GPDR);
>   
> -	return !(readl(gpdr) & BIT(offset % 32));
> +	if (readl(gpdr) & BIT(offset % 32))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> index 6f904c874678..cd07c948649f 100644
> --- a/drivers/gpio/gpio-mmio.c
> +++ b/drivers/gpio/gpio-mmio.c
> @@ -370,15 +370,24 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
>   static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio)
>   {
>   	/* Return 0 if output, 1 if input */
> -	if (gc->bgpio_dir_unreadable)
> -		return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio));
> -	if (gc->reg_dir_out)
> -		return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio));
> +	if (gc->bgpio_dir_unreadable) {
> +		if (gc->bgpio_dir & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
> +	if (gc->reg_dir_out) {
> +		if (gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio))
> +			return GPIO_LINE_DIRECTION_OUT;
> +		return GPIO_LINE_DIRECTION_IN;
> +	}
> +
>   	if (gc->reg_dir_in)
> -		return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio));
> +		if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)))
> +			return GPIO_LINE_DIRECTION_OUT;
>   
>   	/* This should not happen */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 213aedc97dc2..47c172b2f5ad 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -34,14 +34,9 @@
>   
>   #define gpio_mockup_err(...)	pr_err(GPIO_MOCKUP_NAME ": " __VA_ARGS__)
>   
> -enum {
> -	GPIO_MOCKUP_DIR_IN = 0,
> -	GPIO_MOCKUP_DIR_OUT = 1,
> -};
> -
>   /*
>    * struct gpio_pin_status - structure describing a GPIO status
> - * @dir:       Configures direction of gpio as "in" or "out", 0=in, 1=out
> + * @dir:       Configures direction of gpio as "in" or "out"
>    * @value:     Configures status of the gpio as 0(low) or 1(high)
>    */
>   struct gpio_mockup_line_status {
> @@ -152,7 +147,7 @@ static int gpio_mockup_dirout(struct gpio_chip *gc,
>   	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>   
>   	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT;
>   	__gpio_mockup_set(chip, offset, value);
>   	mutex_unlock(&chip->lock);
>   
> @@ -164,7 +159,7 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset)
>   	struct gpio_mockup_chip *chip = gpiochip_get_data(gc);
>   
>   	mutex_lock(&chip->lock);
> -	chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN;
> +	chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN;
>   	mutex_unlock(&chip->lock);
>   
>   	return 0;
> diff --git a/drivers/gpio/gpio-moxtet.c b/drivers/gpio/gpio-moxtet.c
> index 3fd729994a38..8299909318f4 100644
> --- a/drivers/gpio/gpio-moxtet.c
> +++ b/drivers/gpio/gpio-moxtet.c
> @@ -78,9 +78,9 @@ static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   
>   	/* All lines are hard wired to be either input or output, not both. */
>   	if (chip->desc->in_mask & BIT(offset))
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   	else if (chip->desc->out_mask & BIT(offset))
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   	else
>   		return -EINVAL;
>   }
> diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
> index 6c0687694341..9b2adf0ef880 100644
> --- a/drivers/gpio/gpio-mvebu.c
> +++ b/drivers/gpio/gpio-mvebu.c
> @@ -384,7 +384,10 @@ static int mvebu_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   
>   	regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u);
>   
> -	return !!(u & BIT(pin));
> +	if (u & BIT(pin))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
> diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
> index 5e5437a2c607..c4a314c68555 100644
> --- a/drivers/gpio/gpio-mxs.c
> +++ b/drivers/gpio/gpio-mxs.c
> @@ -248,7 +248,10 @@ static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset)
>   	u32 dir;
>   
>   	dir = readl(port->base + PINCTRL_DOE(port));
> -	return !(dir & mask);
> +	if (dir & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static const struct platform_device_id mxs_gpio_ids[] = {
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index d0f27084a942..3bd8adaeed9e 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -805,8 +805,10 @@ static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	struct gpio_bank *bank = gpiochip_get_data(chip);
>   
> -	return !!(readl_relaxed(bank->base + bank->regs->direction) &
> -		  BIT(offset));
> +	if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de5d1383f28d..82122c3c688a 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -449,7 +449,10 @@ static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
>   	if (ret < 0)
>   		return ret;
>   
> -	return !!(reg_val & bit);
> +	if (reg_val & bit)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
> diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
> index 5aa136a6a3e0..df51dd08bdfe 100644
> --- a/drivers/gpio/gpio-pci-idio-16.c
> +++ b/drivers/gpio/gpio-pci-idio-16.c
> @@ -61,9 +61,9 @@ static int idio_16_gpio_get_direction(struct gpio_chip *chip,
>   	unsigned int offset)
>   {
>   	if (offset > 15)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int idio_16_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
> index 52f1647a46fd..44c1e4fc489f 100644
> --- a/drivers/gpio/gpio-pcie-idio-24.c
> +++ b/drivers/gpio/gpio-pcie-idio-24.c
> @@ -104,15 +104,18 @@ static int idio_24_gpio_get_direction(struct gpio_chip *chip,
>   
>   	/* FET Outputs */
>   	if (offset < 24)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	/* Isolated Inputs */
>   	if (offset < 48)
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   
>   	/* TTL/CMOS I/O */
>   	/* OUT MODE = 1 when TTL/CMOS Output Mode is set */
> -	return !(ioread8(&idio24gpio->reg->ctl) & out_mode_mask);
> +	if (ioread8(&idio24gpio->reg->ctl) & out_mode_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int idio_24_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pisosr.c b/drivers/gpio/gpio-pisosr.c
> index f809a5a8e9eb..1331b2a94679 100644
> --- a/drivers/gpio/gpio-pisosr.c
> +++ b/drivers/gpio/gpio-pisosr.c
> @@ -65,7 +65,7 @@ static int pisosr_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned offset)
>   {
>   	/* This device always input */
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int pisosr_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 722ce5cf861e..5df7782e348f 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -63,7 +63,10 @@ static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct pl061 *pl061 = gpiochip_get_data(gc);
>   
> -	return !(readb(pl061->base + GPIODIR) & BIT(offset));
> +	if (readb(pl061->base + GPIODIR) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-raspberrypi-exp.c b/drivers/gpio/gpio-raspberrypi-exp.c
> index b77ea16ffa03..bb100e0124e6 100644
> --- a/drivers/gpio/gpio-raspberrypi-exp.c
> +++ b/drivers/gpio/gpio-raspberrypi-exp.c
> @@ -147,7 +147,10 @@ static int rpi_exp_gpio_get_direction(struct gpio_chip *gc, unsigned int off)
>   			get.gpio);
>   		return ret ? ret : -EIO;
>   	}
> -	return !get.direction;
> +	if (get.direction)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int rpi_exp_gpio_get(struct gpio_chip *gc, unsigned int off)
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 187984d26f47..d7e6e68c25af 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -279,7 +279,10 @@ static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	struct gpio_rcar_priv *p = gpiochip_get_data(chip);
>   
> -	return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
> +	if (gpio_rcar_read(p, INOUTSEL) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c
> index fdc7a9d5b382..d35169bde25a 100644
> --- a/drivers/gpio/gpio-reg.c
> +++ b/drivers/gpio/gpio-reg.c
> @@ -26,7 +26,8 @@ static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
>   	struct gpio_reg *r = to_gpio_reg(gc);
>   
> -	return r->direction & BIT(offset) ? 1 : 0;
> +	return r->direction & BIT(offset) ? GPIO_LINE_DIRECTION_IN :
> +					    GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
> diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c
> index 46b7cf23fb0f..edff5e81489f 100644
> --- a/drivers/gpio/gpio-sa1100.c
> +++ b/drivers/gpio/gpio-sa1100.c
> @@ -53,7 +53,10 @@ static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR;
>   
> -	return !(readl_relaxed(gpdr) & BIT(offset));
> +	if (readl_relaxed(gpdr) & BIT(offset))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
> index 7d718557092e..b04c561f3280 100644
> --- a/drivers/gpio/gpio-sama5d2-piobu.c
> +++ b/drivers/gpio/gpio-sama5d2-piobu.c
> @@ -119,7 +119,8 @@ static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return (ret == PIOBU_IN) ? 1 : 0;
> +	return (ret == PIOBU_IN) ? GPIO_LINE_DIRECTION_IN :
> +				   GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   /**
> @@ -154,9 +155,9 @@ static int sama5d2_piobu_get(struct gpio_chip *chip, unsigned int pin)
>   	/* if pin is input, read value from PDS else read from SOD */
>   	int ret = sama5d2_piobu_get_direction(chip, pin);
>   
> -	if (ret == 1)
> +	if (ret == GPIO_LINE_DIRECTION_IN)
>   		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_PDS);
> -	else if (!ret)
> +	else if (ret == GPIO_LINE_DIRECTION_OUT)
>   		ret = sama5d2_piobu_read_value(chip, pin, PIOBU_SOD);
>   
>   	if (ret < 0)
> diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
> index fb143f28c386..c65f35b68202 100644
> --- a/drivers/gpio/gpio-sch.c
> +++ b/drivers/gpio/gpio-sch.c
> @@ -127,7 +127,10 @@ static int sch_gpio_get_direction(struct gpio_chip *gc, unsigned gpio_num)
>   {
>   	struct sch_gpio *sch = gpiochip_get_data(gc);
>   
> -	return sch_gpio_reg_get(sch, gpio_num, GIO);
> +	if (sch_gpio_reg_get(sch, gpio_num, GIO))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static const struct gpio_chip sch_gpio_chip = {
> diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
> index 8ecf336c9af4..da01e1cad7cb 100644
> --- a/drivers/gpio/gpio-sch311x.c
> +++ b/drivers/gpio/gpio-sch311x.c
> @@ -228,7 +228,10 @@ static int sch311x_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	data = inb(block->runtime_reg + block->config_regs[offset]);
>   	spin_unlock(&block->lock);
>   
> -	return !!(data & SCH311X_GPIO_CONF_DIR);
> +	if (data & SCH311X_GPIO_CONF_DIR)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int sch311x_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
> index 006a7e6a75f2..311f66757b92 100644
> --- a/drivers/gpio/gpio-siox.c
> +++ b/drivers/gpio/gpio-siox.c
> @@ -203,9 +203,9 @@ static int gpio_siox_direction_output(struct gpio_chip *chip,
>   static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
>   {
>   	if (offset < 12)
> -		return 1; /* input */
> +		return GPIO_LINE_DIRECTION_IN;
>   	else
> -		return 0; /* output */
> +		return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int gpio_siox_probe(struct siox_device *sdevice)
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 994d542daf53..542706a852e6 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -84,7 +84,10 @@ static int stmpe_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(ret & mask);
> +	if (ret & mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int stmpe_gpio_direction_output(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
> index 75b1135b383a..6be0684cfa49 100644
> --- a/drivers/gpio/gpio-tc3589x.c
> +++ b/drivers/gpio/gpio-tc3589x.c
> @@ -97,7 +97,10 @@ static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
>   	if (ret < 0)
>   		return ret;
>   
> -	return !(ret & BIT(pos));
> +	if (ret & BIT(pos))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tc3589x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 8a01d3694b28..6fdfe4c5303e 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -215,7 +215,10 @@ static int tegra_gpio_get_direction(struct gpio_chip *chip,
>   
>   	oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
>   
> -	return !(oe & pin_mask);
> +	if (oe & pin_mask)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 8a2a69178925..57185b96c110 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -111,9 +111,9 @@ static int tegra186_gpio_get_direction(struct gpio_chip *chip,
>   
>   	value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG);
>   	if (value & TEGRA186_GPIO_ENABLE_CONFIG_OUT)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return 1;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tegra186_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
> index ddad5c7ea617..d08d86a22b1f 100644
> --- a/drivers/gpio/gpio-thunderx.c
> +++ b/drivers/gpio/gpio-thunderx.c
> @@ -169,7 +169,10 @@ static int thunderx_gpio_get_direction(struct gpio_chip *chip, unsigned int line
>   
>   	bit_cfg = readq(txgpio->register_base + bit_cfg_reg(line));
>   
> -	return !(bit_cfg & GPIO_BIT_CFG_TX_OE);
> +	if (bit_cfg & GPIO_BIT_CFG_TX_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int thunderx_gpio_set_config(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
> index c8b34d787eed..99d5a84a9129 100644
> --- a/drivers/gpio/gpio-tpic2810.c
> +++ b/drivers/gpio/gpio-tpic2810.c
> @@ -39,7 +39,7 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
>   				  unsigned offset)
>   {
>   	/* This device always output */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int tpic2810_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
> index 2eea98ff4ea3..1e9d8262d0ff 100644
> --- a/drivers/gpio/gpio-tps65086.c
> +++ b/drivers/gpio/gpio-tps65086.c
> @@ -21,7 +21,7 @@ static int tps65086_gpio_get_direction(struct gpio_chip *chip,
>   				       unsigned offset)
>   {
>   	/* This device is output only */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int tps65086_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
> index 3ad68bd78282..510d9ed9fd2a 100644
> --- a/drivers/gpio/gpio-tps65912.c
> +++ b/drivers/gpio/gpio-tps65912.c
> @@ -32,9 +32,9 @@ static int tps65912_gpio_get_direction(struct gpio_chip *gc,
>   		return ret;
>   
>   	if (val & GPIO_CFG_MASK)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   	else
> -		return 1;
> +		return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int tps65912_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c
> index aff6e504c666..f7f5f770e0fb 100644
> --- a/drivers/gpio/gpio-tps68470.c
> +++ b/drivers/gpio/gpio-tps68470.c
> @@ -47,7 +47,6 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
>   	return !!(val & BIT(offset));
>   }
>   
> -/* Return 0 if output, 1 if input */
>   static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   				       unsigned int offset)
>   {
> @@ -57,7 +56,7 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   
>   	/* rest are always outputs */
>   	if (offset >= TPS68470_N_REGULAR_GPIO)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
>   	if (ret) {
> @@ -67,7 +66,8 @@ static int tps68470_gpio_get_direction(struct gpio_chip *gc,
>   	}
>   
>   	val &= TPS68470_GPIO_MODE_MASK;
> -	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? 0 : 1;
> +	return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
> +						    GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
> diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
> index a3109bcaa0ac..5022e0ad0fae 100644
> --- a/drivers/gpio/gpio-tqmx86.c
> +++ b/drivers/gpio/gpio-tqmx86.c
> @@ -101,7 +101,10 @@ static int tqmx86_gpio_direction_output(struct gpio_chip *chip,
>   static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
>   				     unsigned int offset)
>   {
> -	return !!(TQMX86_DIR_INPUT_MASK & BIT(offset));
> +	if (TQMX86_DIR_INPUT_MASK & BIT(offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static void tqmx86_gpio_irq_mask(struct irq_data *data)
> diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
> index 1da8d0586329..d885032cf814 100644
> --- a/drivers/gpio/gpio-ts4900.c
> +++ b/drivers/gpio/gpio-ts4900.c
> @@ -44,7 +44,10 @@ static int ts4900_gpio_get_direction(struct gpio_chip *chip,
>   
>   	regmap_read(priv->regmap, offset, &reg);
>   
> -	return !(reg & TS4900_GPIO_OE);
> +	if (reg & TS4900_GPIO_OE)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int ts4900_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index fbfb648d3502..de249726230e 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -165,10 +165,10 @@ static int twl4030_get_gpio_direction(int gpio)
>   	if (ret < 0)
>   		return ret;
>   
> -	/* 1 = output, but gpiolib semantics are inverse so invert */
> -	ret = !(ret & d_msk);
> +	if (ret & d_msk)
> +		return GPIO_LINE_DIRECTION_OUT;
>   
> -	return ret;
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int twl4030_set_gpio_dataout(int gpio, int enable)
> @@ -380,10 +380,10 @@ static int twl_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
>   	struct gpio_twl4030_priv *priv = gpiochip_get_data(chip);
>   	/*
> -	 * Default 0 = output
> +	 * Default GPIO_LINE_DIRECTION_OUT
>   	 * LED GPIOs >= TWL4030_GPIO_MAX are always output
>   	 */
> -	int ret = 0;
> +	int ret = GPIO_LINE_DIRECTION_OUT;
>   
>   	mutex_lock(&priv->mutex);
>   	if (offset < TWL4030_GPIO_MAX) {
> diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
> index c845b2ff1f43..648fb418d775 100644
> --- a/drivers/gpio/gpio-twl6040.c
> +++ b/drivers/gpio/gpio-twl6040.c
> @@ -34,8 +34,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
>   
>   static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset)
>   {
> -	/* This means "out" */
> -	return 0;
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
> diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
> index 93cdcc41e9fb..bd203e8fa58e 100644
> --- a/drivers/gpio/gpio-uniphier.c
> +++ b/drivers/gpio/gpio-uniphier.c
> @@ -113,7 +113,10 @@ static int uniphier_gpio_offset_read(struct gpio_chip *chip,
>   static int uniphier_gpio_get_direction(struct gpio_chip *chip,
>   				       unsigned int offset)
>   {
> -	return uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR);
> +	if (uniphier_gpio_offset_read(chip, offset, UNIPHIER_GPIO_PORT_DIR))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int uniphier_gpio_direction_input(struct gpio_chip *chip,
> diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
> index 444fe9e7f04a..8b481b3c1ebe 100644
> --- a/drivers/gpio/gpio-wcove.c
> +++ b/drivers/gpio/gpio-wcove.c
> @@ -170,13 +170,16 @@ static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
>   	int ret, reg = to_reg(gpio, CTRL_OUT);
>   
>   	if (reg < 0)
> -		return 0;
> +		return GPIO_LINE_DIRECTION_OUT;
>   
>   	ret = regmap_read(wg->regmap, reg, &val);
>   	if (ret)
>   		return ret;
>   
> -	return !(val & CTLO_DIR_OUT);
> +	if (val & CTLO_DIR_OUT)
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
> diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
> index e0ef66b6a237..fe456bea81f6 100644
> --- a/drivers/gpio/gpio-ws16c48.c
> +++ b/drivers/gpio/gpio-ws16c48.c
> @@ -56,7 +56,10 @@ static int ws16c48_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
>   	const unsigned port = offset / 8;
>   	const unsigned mask = BIT(offset % 8);
>   
> -	return !!(ws16c48gpio->io_state[port] & mask);
> +	if (ws16c48gpio->io_state[port] & mask)
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> diff --git a/drivers/gpio/gpio-xgene.c b/drivers/gpio/gpio-xgene.c
> index a6e66ac18e1f..532b0df8a1f2 100644
> --- a/drivers/gpio/gpio-xgene.c
> +++ b/drivers/gpio/gpio-xgene.c
> @@ -80,7 +80,10 @@ static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>   	bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
>   	bit_offset = GPIO_BIT_OFFSET(offset);
>   
> -	return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset));
> +	if (ioread32(chip->base + bank_offset) & BIT(bit_offset))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xra1403.c b/drivers/gpio/gpio-xra1403.c
> index 05f1998c11a4..31b5072b2df0 100644
> --- a/drivers/gpio/gpio-xra1403.c
> +++ b/drivers/gpio/gpio-xra1403.c
> @@ -83,7 +83,10 @@ static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset)
>   	if (ret)
>   		return ret;
>   
> -	return !!(val & BIT(offset % 8));
> +	if (val & BIT(offset % 8))
> +		return GPIO_LINE_DIRECTION_IN;
> +
> +	return GPIO_LINE_DIRECTION_OUT;
>   }
>   
>   static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
> diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
> index 43d3fa5f511a..08d7c3b32038 100644
> --- a/drivers/gpio/gpio-xtensa.c
> +++ b/drivers/gpio/gpio-xtensa.c
> @@ -72,7 +72,7 @@ static inline void disable_cp(unsigned long flags, unsigned long cpenable)
>   
>   static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
> -	return 1; /* input only */
> +	return GPIO_LINE_DIRECTION_IN; /* input only */
>   }
>   
>   static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
> @@ -95,7 +95,7 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
>   
>   static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
>   {
> -	return 0; /* output only */
> +	return GPIO_LINE_DIRECTION_OUT; /* output only */
>   }
>   
>   static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index cd475ff4bcad..4c3f6370eab4 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -360,7 +360,7 @@ static int zynq_gpio_dir_out(struct gpio_chip *chip, unsigned int pin,
>    *
>    * This function returns the direction of the specified GPIO.
>    *
> - * Return: 0 for output, 1 for input
> + * Return: GPIO_LINE_DIRECTION_OUT or GPIO_LINE_DIRECTION_IN
>    */
>   static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   {
> @@ -372,7 +372,10 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
>   
>   	reg = readl_relaxed(gpio->base_addr + ZYNQ_GPIO_DIRM_OFFSET(bank_num));
>   
> -	return !(reg & BIT(bank_pin_num));
> +	if (reg & BIT(bank_pin_num))
> +		return GPIO_LINE_DIRECTION_OUT;
> +
> +	return GPIO_LINE_DIRECTION_IN;
>   }
>   
>   /**

-- 
Sathyanarayanan Kuppuswamy
Linux kernel developer


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 1/2] gpio: Add definition for GPIO direction
  2019-11-06  8:51   ` [alsa-devel] " Matti Vaittinen
  (?)
@ 2019-11-07  8:20     ` Linus Walleij
  -1 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:20 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Peter Tyser, Thierry Reding, Alexandre Torgue, Jonathan Hunter,
	Fabio Estevam, linux-stm32, Marek Vasut, Florian Fainelli,
	Kevin Hilman, Michal Simek, Marek Behun, Bartosz Golaszewski,
	Ludovic Desroches, bcm-kernel-feedback-list, Joel Stanley

On Wed, Nov 6, 2019 at 9:51 AM Matti Vaittinen
<matti.vaittinen@fi.rohmeurope.com> wrote:

> At least for me it is difficult to remember the meaning of GPIO
> direction values. Define GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT so that occasional GPIO contributors would
> not need to always check the meaning of hard coded values 1 and 0.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [alsa-devel] [PATCH v2 1/2] gpio: Add definition for GPIO direction
@ 2019-11-07  8:20     ` Linus Walleij
  0 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:20 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Peter Tyser, Thierry Reding, Alexandre Torgue, Jonathan Hunter,
	Fabio Estevam, linux-stm32, Marek Vasut, Florian Fainelli,
	Kevin Hilman, Michal Simek, Marek Behun, Bartosz Golaszewski,
	Ludovic Desroches, bcm-kernel-feedback-list, Joel Stanley,
	Uwe Kleine-König, Bamvor Jian Zhang, NXP Linux Team,
	linux-pwm, Grygorii Strashko, Charles Keepax, Maxime Coquelin,
	Linux-OMAP, Matti Vaittinen, Ray Jui, Sascha Hauer,
	William Breathitt Gray, open list:GPIO SUBSYSTEM,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	Andy Shevchenko, Linux ARM, Scott Branden, Masahiro Yamada,
	Andrew Jeffery, Enrico Weigelt, metux IT consult, linux-kernel,
	Linux-Renesas, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo

On Wed, Nov 6, 2019 at 9:51 AM Matti Vaittinen
<matti.vaittinen@fi.rohmeurope.com> wrote:

> At least for me it is difficult to remember the meaning of GPIO
> direction values. Define GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT so that occasional GPIO contributors would
> not need to always check the meaning of hard coded values 1 and 0.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

Patch applied.

Yours,
Linus Walleij
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 1/2] gpio: Add definition for GPIO direction
@ 2019-11-07  8:20     ` Linus Walleij
  0 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:20 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Kuppuswamy Sathyanarayanan, linux-aspeed, David Daney,
	moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...,
	Peter Tyser, Thierry Reding, Alexandre Torgue, Jonathan Hunter,
	Fabio Estevam, linux-stm32, Marek Vasut, Florian Fainelli,
	Kevin Hilman, Michal Simek, Marek Behun, Bartosz Golaszewski,
	Ludovic Desroches, bcm-kernel-feedback-list, Joel Stanley,
	Uwe Kleine-König, Bamvor Jian Zhang, NXP Linux Team,
	linux-pwm, Grygorii Strashko, Charles Keepax, Maxime Coquelin,
	Linux-OMAP, Matti Vaittinen, Ray Jui, Sascha Hauer,
	William Breathitt Gray, open list:GPIO SUBSYSTEM,
	Richard Fitzgerald, Santosh Shilimkar, linux-tegra,
	Andy Shevchenko, Linux ARM, Scott Branden, Masahiro Yamada,
	Andrew Jeffery, Enrico Weigelt, metux IT consult, linux-kernel,
	Linux-Renesas, Thorsten Scherer, Pengutronix Kernel Team,
	patches, Shawn Guo

On Wed, Nov 6, 2019 at 9:51 AM Matti Vaittinen
<matti.vaittinen@fi.rohmeurope.com> wrote:

> At least for me it is difficult to remember the meaning of GPIO
> direction values. Define GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT so that occasional GPIO contributors would
> not need to always check the meaning of hard coded values 1 and 0.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

Patch applied.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-06 12:25     ` [alsa-devel] " Vaittinen, Matti
  (?)
@ 2019-11-07  8:22       ` Linus Walleij
  -1 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:22 UTC (permalink / raw)
  To: Vaittinen, Matti
  Cc: alsa-devel, linux-aspeed, david.daney,
	sathyanarayanan.kuppuswamy, sre, ptyser, thierry.reding,
	marek.behun, festevam, linux-stm32, marek.vasut+renesas,
	f.fainelli, khilman, michal.simek, jonathanh,
	bgolaszewski@baylibre.com

On Wed, Nov 6, 2019 at 1:25 PM Vaittinen, Matti
<Matti.Vaittinen@fi.rohmeurope.com> wrote:
> On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> > On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > > The patch series adds definitions for GPIO line directions.
> > >
> > > For occasional GPIO contributor like me it is always a pain to
> > > remember
> > > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> >
> > Maybe also update the GPIO drivers in pinctrl?
(...)
> Ouch. I didn't check from pinctrl but I see those should be converted
> as well. I'm a bit short on time right now so if anyone else is
> interested I won't mind :)
>
> Luckily the value for IN and OUT is not changed - only the defines were
> added - so all of the drivers do not need to be done at once. If no one
> else will take the pinctrl part then I can probably do pinctrl patches
> for v5.6 cycle.

No hurry with that. This is a good start, we don't have to fix
the whole world at once.

Let's look at this for v5.6.

Yours,
Linus Walleij

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

* Re: [alsa-devel] [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-07  8:22       ` Linus Walleij
  0 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:22 UTC (permalink / raw)
  To: Vaittinen, Matti
  Cc: alsa-devel, linux-aspeed, david.daney,
	sathyanarayanan.kuppuswamy, sre, ptyser, thierry.reding,
	marek.behun, festevam, linux-stm32, marek.vasut+renesas,
	f.fainelli, khilman, michal.simek, jonathanh, bgolaszewski,
	linux-omap, bamv2005, joel, u.kleine-koenig,
	bcm-kernel-feedback-list, linux-imx, linux-pwm,
	grygorii.strashko, ckeepax, alexandre.torgue, mazziesaccount,
	rjui, s.hauer, vilhelm.gray, linux-gpio, rf, ssantosh,
	linux-tegra, andriy.shevchenko, kernel, linux-arm-kernel,
	sbranden, yamada.masahiro, andrew, shawnguo, linux-kernel,
	linux-renesas-soc, t.scherer, ludovic.desroches, mcoquelin.stm32,
	patches, info

On Wed, Nov 6, 2019 at 1:25 PM Vaittinen, Matti
<Matti.Vaittinen@fi.rohmeurope.com> wrote:
> On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> > On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > > The patch series adds definitions for GPIO line directions.
> > >
> > > For occasional GPIO contributor like me it is always a pain to
> > > remember
> > > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> >
> > Maybe also update the GPIO drivers in pinctrl?
(...)
> Ouch. I didn't check from pinctrl but I see those should be converted
> as well. I'm a bit short on time right now so if anyone else is
> interested I won't mind :)
>
> Luckily the value for IN and OUT is not changed - only the defines were
> added - so all of the drivers do not need to be done at once. If no one
> else will take the pinctrl part then I can probably do pinctrl patches
> for v5.6 cycle.

No hurry with that. This is a good start, we don't have to fix
the whole world at once.

Let's look at this for v5.6.

Yours,
Linus Walleij
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-07  8:22       ` Linus Walleij
  0 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:22 UTC (permalink / raw)
  To: Vaittinen, Matti
  Cc: alsa-devel, linux-aspeed, david.daney,
	sathyanarayanan.kuppuswamy, sre, ptyser, thierry.reding,
	marek.behun, festevam, linux-stm32, marek.vasut+renesas,
	f.fainelli, khilman, michal.simek, jonathanh, bgolaszewski,
	linux-omap, bamv2005, joel, u.kleine-koenig,
	bcm-kernel-feedback-list, linux-imx, linux-pwm,
	grygorii.strashko, ckeepax, alexandre.torgue, mazziesaccount,
	rjui, s.hauer, vilhelm.gray, linux-gpio, rf, ssantosh,
	linux-tegra, andriy.shevchenko, kernel, linux-arm-kernel,
	sbranden, yamada.masahiro, andrew, shawnguo, linux-kernel,
	linux-renesas-soc, t.scherer, ludovic.desroches, mcoquelin.stm32,
	patches, info

On Wed, Nov 6, 2019 at 1:25 PM Vaittinen, Matti
<Matti.Vaittinen@fi.rohmeurope.com> wrote:
> On Wed, 2019-11-06 at 13:08 +0100, Sebastian Reichel wrote:
> > On Wed, Nov 06, 2019 at 10:51:06AM +0200, Matti Vaittinen wrote:
> > > The patch series adds definitions for GPIO line directions.
> > >
> > > For occasional GPIO contributor like me it is always a pain to
> > > remember
> > > whether 1 or 0 was used for GPIO direction INPUT/OUTPUT.
> >
> > Maybe also update the GPIO drivers in pinctrl?
(...)
> Ouch. I didn't check from pinctrl but I see those should be converted
> as well. I'm a bit short on time right now so if anyone else is
> interested I won't mind :)
>
> Luckily the value for IN and OUT is not changed - only the defines were
> added - so all of the drivers do not need to be done at once. If no one
> else will take the pinctrl part then I can probably do pinctrl patches
> for v5.6 cycle.

No hurry with that. This is a good start, we don't have to fix
the whole world at once.

Let's look at this for v5.6.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-06 14:24       ` [alsa-devel] " andriy.shevchenko
@ 2019-11-07  8:26         ` Linus Walleij
  -1 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:26 UTC (permalink / raw)
  To: andriy.shevchenko, Geert Uytterhoeven
  Cc: Vaittinen, Matti, linux-arm-kernel, linux-renesas-soc, andrew,
	bgolaszewski

On Wed, Nov 6, 2019 at 3:25 PM andriy.shevchenko@linux.intel.com
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:

> > If no one
> > else will take the pinctrl part then I can probably do pinctrl patches
> > for v5.6 cycle.
>
> For pin control Intel, since we send PR to Linus and it won't be different to
> him, we would like to see patch per driver.

It is generally good to bundle these changes because so many
driver maintainers are passive. (Not Intel!)

If you are concerned, what about we just make a separate patch
for the drivers under drivers/pinctrl/intel and bundle the rest?
Possibly Geert want the sh-pfc changes separately as well
as he build his own pinctrl changes.

Rough consensus and working patches.

Yours,
Linus Walleij

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-07  8:26         ` Linus Walleij
  0 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:26 UTC (permalink / raw)
  To: andriy.shevchenko, Geert Uytterhoeven
  Cc: linux-renesas-soc, andrew, Vaittinen, Matti, linux-arm-kernel,
	bgolaszewski

On Wed, Nov 6, 2019 at 3:25 PM andriy.shevchenko@linux.intel.com
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:

> > If no one
> > else will take the pinctrl part then I can probably do pinctrl patches
> > for v5.6 cycle.
>
> For pin control Intel, since we send PR to Linus and it won't be different to
> him, we would like to see patch per driver.

It is generally good to bundle these changes because so many
driver maintainers are passive. (Not Intel!)

If you are concerned, what about we just make a separate patch
for the drivers under drivers/pinctrl/intel and bundle the rest?
Possibly Geert want the sh-pfc changes separately as well
as he build his own pinctrl changes.

Rough consensus and working patches.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-07  8:26         ` Linus Walleij
@ 2019-11-07  8:32           ` Geert Uytterhoeven
  -1 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2019-11-07  8:32 UTC (permalink / raw)
  To: Linus Walleij
  Cc: andriy.shevchenko, Geert Uytterhoeven, Vaittinen, Matti,
	linux-arm-kernel, linux-renesas-soc, andrew, bgolaszewski

Hi Linus,

On Thu, Nov 7, 2019 at 9:26 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Nov 6, 2019 at 3:25 PM andriy.shevchenko@linux.intel.com
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:
>
> > > If no one
> > > else will take the pinctrl part then I can probably do pinctrl patches
> > > for v5.6 cycle.
> >
> > For pin control Intel, since we send PR to Linus and it won't be different to
> > him, we would like to see patch per driver.
>
> It is generally good to bundle these changes because so many
> driver maintainers are passive. (Not Intel!)
>
> If you are concerned, what about we just make a separate patch
> for the drivers under drivers/pinctrl/intel and bundle the rest?
> Possibly Geert want the sh-pfc changes separately as well
> as he build his own pinctrl changes.

I guess the sh-pfc change would be small, and limited to a part of the code
that isn't touched regularly?
So that means it can go in with the rest, bypassing me (but please CC me).
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-07  8:32           ` Geert Uytterhoeven
  0 siblings, 0 replies; 52+ messages in thread
From: Geert Uytterhoeven @ 2019-11-07  8:32 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Geert Uytterhoeven, andrew, Vaittinen, Matti, linux-renesas-soc,
	bgolaszewski, andriy.shevchenko, linux-arm-kernel

Hi Linus,

On Thu, Nov 7, 2019 at 9:26 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Nov 6, 2019 at 3:25 PM andriy.shevchenko@linux.intel.com
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:
>
> > > If no one
> > > else will take the pinctrl part then I can probably do pinctrl patches
> > > for v5.6 cycle.
> >
> > For pin control Intel, since we send PR to Linus and it won't be different to
> > him, we would like to see patch per driver.
>
> It is generally good to bundle these changes because so many
> driver maintainers are passive. (Not Intel!)
>
> If you are concerned, what about we just make a separate patch
> for the drivers under drivers/pinctrl/intel and bundle the rest?
> Possibly Geert want the sh-pfc changes separately as well
> as he build his own pinctrl changes.

I guess the sh-pfc change would be small, and limited to a part of the code
that isn't touched regularly?
So that means it can go in with the rest, bypassing me (but please CC me).
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION
  2019-11-06  8:54   ` [alsa-devel] " Matti Vaittinen
                     ` (4 preceding siblings ...)
  (?)
@ 2019-11-07  8:33   ` Linus Walleij
  -1 siblings, 0 replies; 52+ messages in thread
From: Linus Walleij @ 2019-11-07  8:33 UTC (permalink / raw)
  To: Matti Vaittinen, open list:GPIO SUBSYSTEM

On Wed, Nov 6, 2019 at 9:54 AM Matti Vaittinen
<matti.vaittinen@fi.rohmeurope.com> wrote:

> It's hard for occasional GPIO code reader/writer to know if values 0/1
> equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
> GPIO_LINE_DIRECTION_OUT to help them out.
>
> NOTE - for gpio-amd-fch and gpio-bd9571mwv:
> This commit also changes the return value for direction get to equal 1
> for direction INPUT. Prior this commit these drivers might have
> returned some other positive value but 1 for INPUT.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> Acked-by: Scott Branden <scott.branden@broadcom.com>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-07  8:26         ` Linus Walleij
@ 2019-11-07  8:52           ` Vaittinen, Matti
  -1 siblings, 0 replies; 52+ messages in thread
From: Vaittinen, Matti @ 2019-11-07  8:52 UTC (permalink / raw)
  To: andriy.shevchenko, geert+renesas, linus.walleij, nandor.han
  Cc: linux-arm-kernel, andrew, bgolaszewski, linux-renesas-soc


On Thu, 2019-11-07 at 09:26 +0100, Linus Walleij wrote:
> On Wed, Nov 6, 2019 at 3:25 PM andriy.shevchenko@linux.intel.com
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:
> > > If no one
> > > else will take the pinctrl part then I can probably do pinctrl
> > > patches
> > > for v5.6 cycle.
> > 
> > For pin control Intel, since we send PR to Linus and it won't be
> > different to
> > him, we would like to see patch per driver.
> 
> It is generally good to bundle these changes because so many
> driver maintainers are passive. (Not Intel!)

That reminded me.. I got 'unknown recipient' replies
<nandor.han@ge.com>: 550 5.1.1 No such user - pp
<semi.malinen@ge.com>: 550 5.1.1 No such user - pp

from both Semi and Nandor - who seem to be the only maintainers listed
for XRA1403 GPIO EXPANDER in MAINTAINERS.

XRA1403 GPIO EXPANDER
M:      Nandor Han <nandor.han@ge.com>
M:      Semi Malinen <semi.malinen@ge.com>
L:      linux-gpio@vger.kernel.org
S:      Maintained
F:      drivers/gpio/gpio-xra1403.c
F:      Documentation/devicetree/bindings/gpio/gpio-xra1403.txt

Anyone knows new mail addresses or perhaps the separate entry
for XRA1403 should be removed? 

> If you are concerned, what about we just make a separate patch
> for the drivers under drivers/pinctrl/intel and bundle the rest?
> Possibly Geert want the sh-pfc changes separately as well
> as he build his own pinctrl changes.
> 
> Rough consensus and working patches.

In general - Which one is harder? xD

But this works for me.

Br,
	Matti Vaittinen

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-07  8:52           ` Vaittinen, Matti
  0 siblings, 0 replies; 52+ messages in thread
From: Vaittinen, Matti @ 2019-11-07  8:52 UTC (permalink / raw)
  To: andriy.shevchenko, geert+renesas, linus.walleij, nandor.han
  Cc: andrew, bgolaszewski, linux-renesas-soc, linux-arm-kernel


On Thu, 2019-11-07 at 09:26 +0100, Linus Walleij wrote:
> On Wed, Nov 6, 2019 at 3:25 PM andriy.shevchenko@linux.intel.com
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:
> > > If no one
> > > else will take the pinctrl part then I can probably do pinctrl
> > > patches
> > > for v5.6 cycle.
> > 
> > For pin control Intel, since we send PR to Linus and it won't be
> > different to
> > him, we would like to see patch per driver.
> 
> It is generally good to bundle these changes because so many
> driver maintainers are passive. (Not Intel!)

That reminded me.. I got 'unknown recipient' replies
<nandor.han@ge.com>: 550 5.1.1 No such user - pp
<semi.malinen@ge.com>: 550 5.1.1 No such user - pp

from both Semi and Nandor - who seem to be the only maintainers listed
for XRA1403 GPIO EXPANDER in MAINTAINERS.

XRA1403 GPIO EXPANDER
M:      Nandor Han <nandor.han@ge.com>
M:      Semi Malinen <semi.malinen@ge.com>
L:      linux-gpio@vger.kernel.org
S:      Maintained
F:      drivers/gpio/gpio-xra1403.c
F:      Documentation/devicetree/bindings/gpio/gpio-xra1403.txt

Anyone knows new mail addresses or perhaps the separate entry
for XRA1403 should be removed? 

> If you are concerned, what about we just make a separate patch
> for the drivers under drivers/pinctrl/intel and bundle the rest?
> Possibly Geert want the sh-pfc changes separately as well
> as he build his own pinctrl changes.
> 
> Rough consensus and working patches.

In general - Which one is harder? xD

But this works for me.

Br,
	Matti Vaittinen
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-07  8:26         ` Linus Walleij
@ 2019-11-07  8:52           ` andriy.shevchenko
  -1 siblings, 0 replies; 52+ messages in thread
From: andriy.shevchenko @ 2019-11-07  8:52 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Geert Uytterhoeven, Vaittinen, Matti, linux-arm-kernel,
	linux-renesas-soc, andrew, bgolaszewski

On Thu, Nov 07, 2019 at 09:26:43AM +0100, Linus Walleij wrote:
> On Wed, Nov 6, 2019 at 3:25 PM andriy.shevchenko@linux.intel.com
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:

> > For pin control Intel, since we send PR to Linus and it won't be different to
> > him, we would like to see patch per driver.
> 
> It is generally good to bundle these changes because so many
> driver maintainers are passive. (Not Intel!)
> 
> If you are concerned, what about we just make a separate patch
> for the drivers under drivers/pinctrl/intel and bundle the rest?

Fine with me!

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-07  8:52           ` andriy.shevchenko
  0 siblings, 0 replies; 52+ messages in thread
From: andriy.shevchenko @ 2019-11-07  8:52 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Geert Uytterhoeven, andrew, Vaittinen, Matti, linux-renesas-soc,
	bgolaszewski, linux-arm-kernel

On Thu, Nov 07, 2019 at 09:26:43AM +0100, Linus Walleij wrote:
> On Wed, Nov 6, 2019 at 3:25 PM andriy.shevchenko@linux.intel.com
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Wed, Nov 06, 2019 at 12:25:18PM +0000, Vaittinen, Matti wrote:

> > For pin control Intel, since we send PR to Linus and it won't be different to
> > him, we would like to see patch per driver.
> 
> It is generally good to bundle these changes because so many
> driver maintainers are passive. (Not Intel!)
> 
> If you are concerned, what about we just make a separate patch
> for the drivers under drivers/pinctrl/intel and bundle the rest?

Fine with me!

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-07  8:52           ` Vaittinen, Matti
@ 2019-11-07 12:08             ` Sebastian Reichel
  -1 siblings, 0 replies; 52+ messages in thread
From: Sebastian Reichel @ 2019-11-07 12:08 UTC (permalink / raw)
  To: Vaittinen, Matti, Ian Ray, Nandor Han
  Cc: andriy.shevchenko, geert+renesas, linus.walleij, andrew,
	bgolaszewski, linux-renesas-soc, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 841 bytes --]

Hi,

On Thu, Nov 07, 2019 at 08:52:11AM +0000, Vaittinen, Matti wrote:
> That reminded me.. I got 'unknown recipient' replies
> <nandor.han@ge.com>: 550 5.1.1 No such user - pp
> <semi.malinen@ge.com>: 550 5.1.1 No such user - pp
> 
> from both Semi and Nandor - who seem to be the only maintainers listed
> for XRA1403 GPIO EXPANDER in MAINTAINERS.
> 
> XRA1403 GPIO EXPANDER
> M:      Nandor Han <nandor.han@ge.com>
> M:      Semi Malinen <semi.malinen@ge.com>
> L:      linux-gpio@vger.kernel.org
> S:      Maintained
> F:      drivers/gpio/gpio-xra1403.c
> F:      Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
> 
> Anyone knows new mail addresses or perhaps the separate entry
> for XRA1403 should be removed?

+cc new mail address from Nandor Han
+cc Ian Ray with valid GE mail address

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-07 12:08             ` Sebastian Reichel
  0 siblings, 0 replies; 52+ messages in thread
From: Sebastian Reichel @ 2019-11-07 12:08 UTC (permalink / raw)
  To: Vaittinen, Matti, Ian Ray, Nandor Han
  Cc: geert+renesas, andrew, linus.walleij, linux-renesas-soc,
	bgolaszewski, andriy.shevchenko, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 841 bytes --]

Hi,

On Thu, Nov 07, 2019 at 08:52:11AM +0000, Vaittinen, Matti wrote:
> That reminded me.. I got 'unknown recipient' replies
> <nandor.han@ge.com>: 550 5.1.1 No such user - pp
> <semi.malinen@ge.com>: 550 5.1.1 No such user - pp
> 
> from both Semi and Nandor - who seem to be the only maintainers listed
> for XRA1403 GPIO EXPANDER in MAINTAINERS.
> 
> XRA1403 GPIO EXPANDER
> M:      Nandor Han <nandor.han@ge.com>
> M:      Semi Malinen <semi.malinen@ge.com>
> L:      linux-gpio@vger.kernel.org
> S:      Maintained
> F:      drivers/gpio/gpio-xra1403.c
> F:      Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
> 
> Anyone knows new mail addresses or perhaps the separate entry
> for XRA1403 should be removed?

+cc new mail address from Nandor Han
+cc Ian Ray with valid GE mail address

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
  2019-11-07 12:08             ` Sebastian Reichel
@ 2019-11-08  7:46               ` Nandor Han
  -1 siblings, 0 replies; 52+ messages in thread
From: Nandor Han @ 2019-11-08  7:46 UTC (permalink / raw)
  To: Sebastian Reichel, Vaittinen, Matti, Ian Ray
  Cc: andriy.shevchenko, geert+renesas, linus.walleij, andrew,
	bgolaszewski, linux-renesas-soc, linux-arm-kernel

On 11/7/19 2:08 PM, Sebastian Reichel wrote:
> Hi,
> 
> On Thu, Nov 07, 2019 at 08:52:11AM +0000, Vaittinen, Matti wrote:
>> That reminded me.. I got 'unknown recipient' replies
>> <nandor.han@ge.com>: 550 5.1.1 No such user - pp
>> <semi.malinen@ge.com>: 550 5.1.1 No such user - pp
>>
>> from both Semi and Nandor - who seem to be the only maintainers listed
>> for XRA1403 GPIO EXPANDER in MAINTAINERS.
>>
>> XRA1403 GPIO EXPANDER
>> M:      Nandor Han <nandor.han@ge.com>
>> M:      Semi Malinen <semi.malinen@ge.com>
>> L:      linux-gpio@vger.kernel.org
>> S:      Maintained
>> F:      drivers/gpio/gpio-xra1403.c
>> F:      Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
>>
>> Anyone knows new mail addresses or perhaps the separate entry
>> for XRA1403 should be removed?
> 
> +cc new mail address from Nandor Han
> +cc Ian Ray with valid GE mail address
> 
> -- Sebastian
> 

Thanks Sebastian.

Matti, I did review the gpio-xra1403 changes and LGTM.

According with the datasheet, 1 means direction input:

XRA1403 datasheet (https://www.maxlinear.com/ds/xra1403_100_092011.pdf)
```
  Setting these bits to ’1’ will enable the GPIOs as inputs.
```

Note: I will update also the maintainers list.

Nandor


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

* Re: [PATCH v2 0/2] Add definition for GPIO direction
@ 2019-11-08  7:46               ` Nandor Han
  0 siblings, 0 replies; 52+ messages in thread
From: Nandor Han @ 2019-11-08  7:46 UTC (permalink / raw)
  To: Sebastian Reichel, Vaittinen, Matti, Ian Ray
  Cc: geert+renesas, andrew, linus.walleij, linux-renesas-soc,
	bgolaszewski, andriy.shevchenko, linux-arm-kernel

On 11/7/19 2:08 PM, Sebastian Reichel wrote:
> Hi,
> 
> On Thu, Nov 07, 2019 at 08:52:11AM +0000, Vaittinen, Matti wrote:
>> That reminded me.. I got 'unknown recipient' replies
>> <nandor.han@ge.com>: 550 5.1.1 No such user - pp
>> <semi.malinen@ge.com>: 550 5.1.1 No such user - pp
>>
>> from both Semi and Nandor - who seem to be the only maintainers listed
>> for XRA1403 GPIO EXPANDER in MAINTAINERS.
>>
>> XRA1403 GPIO EXPANDER
>> M:      Nandor Han <nandor.han@ge.com>
>> M:      Semi Malinen <semi.malinen@ge.com>
>> L:      linux-gpio@vger.kernel.org
>> S:      Maintained
>> F:      drivers/gpio/gpio-xra1403.c
>> F:      Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
>>
>> Anyone knows new mail addresses or perhaps the separate entry
>> for XRA1403 should be removed?
> 
> +cc new mail address from Nandor Han
> +cc Ian Ray with valid GE mail address
> 
> -- Sebastian
> 

Thanks Sebastian.

Matti, I did review the gpio-xra1403 changes and LGTM.

According with the datasheet, 1 means direction input:

XRA1403 datasheet (https://www.maxlinear.com/ds/xra1403_100_092011.pdf)
```
  Setting these bits to ’1’ will enable the GPIOs as inputs.
```

Note: I will update also the maintainers list.

Nandor


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-11-08  7:53 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06  8:51 [PATCH v2 0/2] Add definition for GPIO direction Matti Vaittinen
2019-11-06  8:51 ` Matti Vaittinen
2019-11-06  8:51 ` [alsa-devel] " Matti Vaittinen
2019-11-06  8:51 ` [PATCH v2 1/2] gpio: " Matti Vaittinen
2019-11-06  8:51   ` Matti Vaittinen
2019-11-06  8:51   ` [alsa-devel] " Matti Vaittinen
2019-11-07  8:20   ` Linus Walleij
2019-11-07  8:20     ` Linus Walleij
2019-11-07  8:20     ` [alsa-devel] " Linus Walleij
2019-11-06  8:54 ` [PATCH v2 2/2] gpio: Use new GPIO_LINE_DIRECTION Matti Vaittinen
2019-11-06  8:54   ` Matti Vaittinen
2019-11-06  8:54   ` [alsa-devel] " Matti Vaittinen
2019-11-06 14:22   ` Andy Shevchenko
2019-11-06 14:22     ` Andy Shevchenko
2019-11-06 14:22     ` [alsa-devel] " Andy Shevchenko
2019-11-06 14:43   ` William Breathitt Gray
2019-11-06 14:43     ` William Breathitt Gray
2019-11-06 14:43     ` [alsa-devel] " William Breathitt Gray
2019-11-06 17:35   ` Kuppuswamy Sathyanarayanan
2019-11-06 17:35     ` Kuppuswamy Sathyanarayanan
2019-11-06 17:35     ` [alsa-devel] " Kuppuswamy Sathyanarayanan
2019-11-07  8:33   ` Linus Walleij
2019-11-06 12:08 ` [PATCH v2 0/2] Add definition for GPIO direction Sebastian Reichel
2019-11-06 12:08   ` Sebastian Reichel
2019-11-06 12:08   ` [alsa-devel] " Sebastian Reichel
2019-11-06 12:25   ` Vaittinen, Matti
2019-11-06 12:25     ` Vaittinen, Matti
2019-11-06 12:25     ` [alsa-devel] " Vaittinen, Matti
2019-11-06 14:24     ` andriy.shevchenko
2019-11-06 14:24       ` andriy.shevchenko
2019-11-06 14:24       ` [alsa-devel] " andriy.shevchenko
2019-11-07  8:26       ` Linus Walleij
2019-11-07  8:26         ` Linus Walleij
2019-11-07  8:32         ` Geert Uytterhoeven
2019-11-07  8:32           ` Geert Uytterhoeven
2019-11-07  8:52         ` Vaittinen, Matti
2019-11-07  8:52           ` Vaittinen, Matti
2019-11-07 12:08           ` Sebastian Reichel
2019-11-07 12:08             ` Sebastian Reichel
2019-11-08  7:46             ` Nandor Han
2019-11-08  7:46               ` Nandor Han
2019-11-07  8:52         ` andriy.shevchenko
2019-11-07  8:52           ` andriy.shevchenko
2019-11-07  8:22     ` Linus Walleij
2019-11-07  8:22       ` Linus Walleij
2019-11-07  8:22       ` [alsa-devel] " Linus Walleij
2019-11-06 14:39 ` William Breathitt Gray
2019-11-06 14:39   ` William Breathitt Gray
2019-11-06 14:39   ` [alsa-devel] " William Breathitt Gray
2019-11-06 17:28   ` Vaittinen, Matti
2019-11-06 17:28     ` Vaittinen, Matti
2019-11-06 17:28     ` [alsa-devel] " Vaittinen, Matti

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.