* [PATCH 08/62] gpio: gpio-bcm-kona: Use new GPIO_LINE_DIRECTION
[not found] <cover.1572945719.git.matti.vaittinen@fi.rohmeurope.com>
@ 2019-11-05 10:13 ` Matti Vaittinen
2019-11-05 18:14 ` Scott Branden
0 siblings, 1 reply; 2+ messages in thread
From: Matti Vaittinen @ 2019-11-05 10:13 UTC (permalink / raw)
To: matti.vaittinen, mazziesaccount
Cc: Ray Jui, Linus Walleij, Bartosz Golaszewski, Florian Fainelli,
Scott Branden, bcm-kernel-feedback-list, linux-gpio,
linux-kernel
t'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-bcm-kona.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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);
--
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
* Re: [PATCH 08/62] gpio: gpio-bcm-kona: Use new GPIO_LINE_DIRECTION
2019-11-05 10:13 ` [PATCH 08/62] gpio: gpio-bcm-kona: Use new GPIO_LINE_DIRECTION Matti Vaittinen
@ 2019-11-05 18:14 ` Scott Branden
0 siblings, 0 replies; 2+ messages in thread
From: Scott Branden @ 2019-11-05 18:14 UTC (permalink / raw)
To: Matti Vaittinen, mazziesaccount
Cc: Ray Jui, Linus Walleij, Bartosz Golaszewski, Florian Fainelli,
Scott Branden, bcm-kernel-feedback-list, linux-gpio,
linux-kernel
Unlike some other opinions I've seen, I like the use of an
understandable define.
On 2019-11-05 2:13 a.m., Matti Vaittinen wrote:
> t'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>
Acked-by: Scott Branden <scott.branden@broadcom.com>
> ---
> drivers/gpio/gpio-bcm-kona.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-05 18:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <cover.1572945719.git.matti.vaittinen@fi.rohmeurope.com>
2019-11-05 10:13 ` [PATCH 08/62] gpio: gpio-bcm-kona: Use new GPIO_LINE_DIRECTION Matti Vaittinen
2019-11-05 18:14 ` Scott Branden
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).