* [PATCH 0/3] Use new GPIO direction defines for intel pinctrl
@ 2019-12-11 14:31 Matti Vaittinen
2019-12-11 14:32 ` [PATCH 1/3] pinctrl: pinctrl-intel: Use GPIO direction definitions Matti Vaittinen
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Matti Vaittinen @ 2019-12-11 14:31 UTC (permalink / raw)
To: matti.vaittinen, mazziesaccount
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij, linux-gpio,
linux-kernel
We added definitions for GPIO line directions here:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/commit/?id=9208b1e77d6e8e9776f34f46ef4079ecac9c3c25
Let's use them on Intel pincontrollers too.
---
Matti Vaittinen (3):
pinctrl: pinctrl-intel: Use GPIO direction definitions
pinctrl: pinctrl-cherryview: Use GPIO direction definitions
pinctrl: pinctrl-baytrail: Use GPIO direction definitions
drivers/pinctrl/intel/pinctrl-baytrail.c | 4 ++--
drivers/pinctrl/intel/pinctrl-cherryview.c | 3 ++-
drivers/pinctrl/intel/pinctrl-intel.c | 3 ++-
3 files changed, 6 insertions(+), 4 deletions(-)
base-commit: e42617b825f8 ("Linux 5.5-rc1")
--
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] 7+ messages in thread
* [PATCH 1/3] pinctrl: pinctrl-intel: Use GPIO direction definitions
2019-12-11 14:31 [PATCH 0/3] Use new GPIO direction defines for intel pinctrl Matti Vaittinen
@ 2019-12-11 14:32 ` Matti Vaittinen
2019-12-11 14:54 ` Andy Shevchenko
2019-12-11 14:32 ` [PATCH 2/3] pinctrl: pinctrl-cherryview: " Matti Vaittinen
2019-12-11 14:33 ` [PATCH 3/3] pinctrl: pinctrl-baytrail: " Matti Vaittinen
2 siblings, 1 reply; 7+ messages in thread
From: Matti Vaittinen @ 2019-12-11 14:32 UTC (permalink / raw)
To: matti.vaittinen, mazziesaccount
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij, linux-gpio,
linux-kernel
Use new GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT when
returning GPIO direction to GPIO framework.
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
drivers/pinctrl/intel/pinctrl-intel.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index 4860bc9a4e48..821da94cfa6c 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -944,7 +944,8 @@ static int intel_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
if (padcfg0 & PADCFG0_PMODE_MASK)
return -EINVAL;
- return !!(padcfg0 & PADCFG0_GPIOTXDIS);
+ return padcfg0 & PADCFG0_GPIOTXDIS ? GPIO_LINE_DIRECTION_IN :
+ GPIO_LINE_DIRECTION_OUT;
}
static int intel_gpio_direction_input(struct gpio_chip *chip, unsigned int 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] 7+ messages in thread
* [PATCH 2/3] pinctrl: pinctrl-cherryview: Use GPIO direction definitions
2019-12-11 14:31 [PATCH 0/3] Use new GPIO direction defines for intel pinctrl Matti Vaittinen
2019-12-11 14:32 ` [PATCH 1/3] pinctrl: pinctrl-intel: Use GPIO direction definitions Matti Vaittinen
@ 2019-12-11 14:32 ` Matti Vaittinen
2019-12-11 14:55 ` Andy Shevchenko
2019-12-11 14:33 ` [PATCH 3/3] pinctrl: pinctrl-baytrail: " Matti Vaittinen
2 siblings, 1 reply; 7+ messages in thread
From: Matti Vaittinen @ 2019-12-11 14:32 UTC (permalink / raw)
To: matti.vaittinen, mazziesaccount
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij, linux-gpio,
linux-kernel
Use new GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT when
returning GPIO direction to GPIO framework.
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
drivers/pinctrl/intel/pinctrl-cherryview.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index 582fa8a75559..797a226e2043 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -1287,7 +1287,8 @@ static int chv_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
direction = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK;
direction >>= CHV_PADCTRL0_GPIOCFG_SHIFT;
- return direction != CHV_PADCTRL0_GPIOCFG_GPO;
+ return direction != CHV_PADCTRL0_GPIOCFG_GPO ? GPIO_LINE_DIRECTION_IN :
+ GPIO_LINE_DIRECTION_OUT;
}
static int chv_gpio_direction_input(struct gpio_chip *chip, unsigned int 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] 7+ messages in thread
* [PATCH 3/3] pinctrl: pinctrl-baytrail: Use GPIO direction definitions
2019-12-11 14:31 [PATCH 0/3] Use new GPIO direction defines for intel pinctrl Matti Vaittinen
2019-12-11 14:32 ` [PATCH 1/3] pinctrl: pinctrl-intel: Use GPIO direction definitions Matti Vaittinen
2019-12-11 14:32 ` [PATCH 2/3] pinctrl: pinctrl-cherryview: " Matti Vaittinen
@ 2019-12-11 14:33 ` Matti Vaittinen
2019-12-11 14:55 ` Andy Shevchenko
2 siblings, 1 reply; 7+ messages in thread
From: Matti Vaittinen @ 2019-12-11 14:33 UTC (permalink / raw)
To: matti.vaittinen, mazziesaccount
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij, linux-gpio,
linux-kernel
Use new GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT when
returning GPIO direction to GPIO framework.
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
drivers/pinctrl/intel/pinctrl-baytrail.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 9ffb22211d2b..362276ad5640 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -1160,9 +1160,9 @@ static int byt_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
raw_spin_unlock_irqrestore(&vg->lock, flags);
if (!(value & BYT_OUTPUT_EN))
- return 0;
+ return GPIO_LINE_DIRECTION_OUT;
if (!(value & BYT_INPUT_EN))
- return 1;
+ return GPIO_LINE_DIRECTION_IN;
return -EINVAL;
}
--
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] 7+ messages in thread
* Re: [PATCH 1/3] pinctrl: pinctrl-intel: Use GPIO direction definitions
2019-12-11 14:32 ` [PATCH 1/3] pinctrl: pinctrl-intel: Use GPIO direction definitions Matti Vaittinen
@ 2019-12-11 14:54 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2019-12-11 14:54 UTC (permalink / raw)
To: Matti Vaittinen
Cc: mazziesaccount, Mika Westerberg, Andy Shevchenko, Linus Walleij,
linux-gpio, linux-kernel
On Wed, Dec 11, 2019 at 04:32:24PM +0200, Matti Vaittinen wrote:
> Use new GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT when
> returning GPIO direction to GPIO framework.
Thanks for the patch!
My comment below.
> - return !!(padcfg0 & PADCFG0_GPIOTXDIS);
> + return padcfg0 & PADCFG0_GPIOTXDIS ? GPIO_LINE_DIRECTION_IN :
> + GPIO_LINE_DIRECTION_OUT;
Despite I have told about ternary operator before, the most important here is
readability as well. With these definitions applied to the initial code the
readability has been slightly decreased.
Two variants to fix, though I prefer second one due to less stack use.
1/
u32 tmp;
...
tmp = padcfg0 & PADCFG0_GPIOTXDIS;
return tmp ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
2/
if (padcfg0 & PADCFG0_GPIOTXDIS)
return GPIO_LINE_DIRECTION_IN;
return GPIO_LINE_DIRECTION_OUT;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] pinctrl: pinctrl-cherryview: Use GPIO direction definitions
2019-12-11 14:32 ` [PATCH 2/3] pinctrl: pinctrl-cherryview: " Matti Vaittinen
@ 2019-12-11 14:55 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2019-12-11 14:55 UTC (permalink / raw)
To: Matti Vaittinen
Cc: mazziesaccount, Mika Westerberg, Andy Shevchenko, Linus Walleij,
linux-gpio, linux-kernel
On Wed, Dec 11, 2019 at 04:32:54PM +0200, Matti Vaittinen wrote:
> Use new GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT when
> returning GPIO direction to GPIO framework.
> - return direction != CHV_PADCTRL0_GPIOCFG_GPO;
> + return direction != CHV_PADCTRL0_GPIOCFG_GPO ? GPIO_LINE_DIRECTION_IN :
> + GPIO_LINE_DIRECTION_OUT;
Same as per patch 1.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] pinctrl: pinctrl-baytrail: Use GPIO direction definitions
2019-12-11 14:33 ` [PATCH 3/3] pinctrl: pinctrl-baytrail: " Matti Vaittinen
@ 2019-12-11 14:55 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2019-12-11 14:55 UTC (permalink / raw)
To: Matti Vaittinen
Cc: mazziesaccount, Mika Westerberg, Andy Shevchenko, Linus Walleij,
linux-gpio, linux-kernel
On Wed, Dec 11, 2019 at 04:33:25PM +0200, Matti Vaittinen wrote:
> Use new GPIO_LINE_DIRECTION_IN and GPIO_LINE_DIRECTION_OUT when
> returning GPIO direction to GPIO framework.
LGTM!
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> ---
> drivers/pinctrl/intel/pinctrl-baytrail.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
> index 9ffb22211d2b..362276ad5640 100644
> --- a/drivers/pinctrl/intel/pinctrl-baytrail.c
> +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
> @@ -1160,9 +1160,9 @@ static int byt_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
> raw_spin_unlock_irqrestore(&vg->lock, flags);
>
> if (!(value & BYT_OUTPUT_EN))
> - return 0;
> + return GPIO_LINE_DIRECTION_OUT;
> if (!(value & BYT_INPUT_EN))
> - return 1;
> + return GPIO_LINE_DIRECTION_IN;
>
> return -EINVAL;
> }
> --
> 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 =]
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-12-11 14:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 14:31 [PATCH 0/3] Use new GPIO direction defines for intel pinctrl Matti Vaittinen
2019-12-11 14:32 ` [PATCH 1/3] pinctrl: pinctrl-intel: Use GPIO direction definitions Matti Vaittinen
2019-12-11 14:54 ` Andy Shevchenko
2019-12-11 14:32 ` [PATCH 2/3] pinctrl: pinctrl-cherryview: " Matti Vaittinen
2019-12-11 14:55 ` Andy Shevchenko
2019-12-11 14:33 ` [PATCH 3/3] pinctrl: pinctrl-baytrail: " Matti Vaittinen
2019-12-11 14:55 ` Andy Shevchenko
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.