lkml.org 
[lkml]   [2019]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] pinctrl: pinctrl-intel: Use GPIO direction definitions
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


\
 
 \ /
  Last update: 2019-12-11 15:55    [W:1.944 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site