linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/62] gpio: Add definition for GPIO direction
       [not found] <cover.1572946026.git.matti.vaittinen@fi.rohmeurope.com>
@ 2019-11-05 10:09 ` Matti Vaittinen
  2019-11-05 10:40 ` [PATCH 61/62] gpio: gpio-sa1100: Use new GPIO_LINE_DIRECTION Matti Vaittinen
  1 sibling, 0 replies; 2+ messages in thread
From: Matti Vaittinen @ 2019-11-05 10:09 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel

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>
---
 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] 2+ messages in thread

* [PATCH 61/62] gpio: gpio-sa1100: Use new GPIO_LINE_DIRECTION
       [not found] <cover.1572946026.git.matti.vaittinen@fi.rohmeurope.com>
  2019-11-05 10:09 ` [PATCH 01/62] gpio: Add definition for GPIO direction Matti Vaittinen
@ 2019-11-05 10:40 ` Matti Vaittinen
  1 sibling, 0 replies; 2+ messages in thread
From: Matti Vaittinen @ 2019-11-05 10:40 UTC (permalink / raw)
  To: matti.vaittinen, mazziesaccount
  Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel

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.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
 drivers/gpio/gpio-sa1100.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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)
-- 
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] 2+ messages in thread

end of thread, other threads:[~2019-11-05 10:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1572946026.git.matti.vaittinen@fi.rohmeurope.com>
2019-11-05 10:09 ` [PATCH 01/62] gpio: Add definition for GPIO direction Matti Vaittinen
2019-11-05 10:40 ` [PATCH 61/62] gpio: gpio-sa1100: Use new GPIO_LINE_DIRECTION Matti Vaittinen

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