Re: [PATCH v1 3/7] gpiolib: Change type of lflags in gpiod_hog() and gpiod_configure_flags()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 04, 2019 at 11:52:20AM +0300, Mika Westerberg wrote:
> On Thu, Apr 04, 2019 at 11:37:35AM +0300, Andy Shevchenko wrote:
> > On Wed, Apr 03, 2019 at 09:36:24PM +0300, Mika Westerberg wrote:
> > > On Tue, Apr 02, 2019 at 01:57:32PM +0300, Andy Shevchenko wrote:
> > > > Most of the code inside GPIO library is using enum gpio_lookup_flags.
> > > > Some of the function still operate with unsigned long.
> > > > 
> > > > In order to be more consistent and better type checking, convert
> > > > gpiod_hog() and gpiod_configure_flags() to use enum gpio_lookup_flags
> > > > instead of unsigned long.
> > > > 
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> > > > ---
> > > >  drivers/gpio/gpiolib.c | 4 ++--
> > > >  drivers/gpio/gpiolib.h | 4 ++--
> > > >  2 files changed, 4 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> > > > index a3fe41a2c6c0..ea0d38164b06 100644
> > > > --- a/drivers/gpio/gpiolib.c
> > > > +++ b/drivers/gpio/gpiolib.c
> > > > @@ -4078,7 +4078,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_optional);
> > > >   * occurred while trying to acquire the GPIO.
> > > >   */
> > > >  int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
> > > > -		unsigned long lflags, enum gpiod_flags dflags)
> > > > +		enum gpio_lookup_flags lflags, enum gpiod_flags dflags)
> > > 
> > > I actually think unsigned long here is more correct because enum is
> > > supposed to present a single enumerated value and here we pass several of
> > > them as bitmask.
> > 
> > There are more functions that are using enum to keep bit mask, for example,
> > gpiochip_request_own_desc(). Are you suggesting to change them all to unsigned
> > long?
> 
> No just wanted to mention it. For example enum gpiod_flags used by
> gpiochip_request_own_desc() encodes bitmask as part of the enumeration
> value which is fine but enum gpio_lookup_flags on the other hand does
> not. So for the latter I would prefer to use unsigned int/long instead.

Ah, okay, so, basically using enum gpio_lookup_flags as a parameter to
functions doesn't feel right.

Thank you for a comment.

> Up to you really. I'm fine either way :)

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux