Re: [PATCH] gpio: gpio-ich: fix ichx_gpio_check_available() return what callers expect

Mika Westerberg
2013-03-07T06:31:29Z

On Thu, Mar 07, 2013 at 04:23:56AM +0100, Linus Walleij wrote:
> Hi Mika,
>
> On Wed, Feb 27, 2013 at 4:25 PM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
>
> > -static int ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
> > +static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
> > {
> > - return (ichx_priv.use_gpio & (1 << (nr / 32))) ? 0 : -ENXIO;
> > + return ichx_priv.use_gpio & (1 << (nr / 32));
> > }
>
> Strictly speaking what you're returning there is not a bool.
> Shouldn't it be:
>
> return !!(ichx_priv.use_gpio & (1 << (nr / 32)));
>
> ?

A C reference manual says something like: When converting any scalar value
to type _Bool, all nonzero values are converted to 1, while zero values are
converted to 0 (1 being canonical value for true).

However, I'm happy to send a patch changing this if you like so (Grant
applied the patch already).