Message ID | b14ba01f6fcbaffbbfbfe1f257fd25691671c652.1576073444.git.matti.vaittinen@fi.rohmeurope.com |
---|---|
State | New |
Headers | show |
Series | Use new GPIO direction defines for intel pinctrl | expand |
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;
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)
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(-)