Re: [PATCH v2] gpio: generic: add request function pointer

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

 



On Tue, May 20, 2014 at 2:49 AM, Anthony Fee <anthony.fee@xxxxxxxxxx> wrote:
> gpiolib will require all gpio drivers to expicitly set the request function pointer
> in future. To encourage gpio driver developers to adhere to this standard
> gpio-generic.c now sets this function pointer.

This one applies. ;)

Acked-by: Alexandre Courbot <acourbot@xxxxxxxxxx>

(btw, please carry the acks you received to the next revisions of your
patches, that will be that much that the maintainer does not need to
do).

>
> Signed-off-by: Anthony Fee <anthony.fee@xxxxxxxxxx>
> ---
>  drivers/gpio/gpio-generic.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
> index b5dff9e..fea8c82 100644
> --- a/drivers/gpio/gpio-generic.c
> +++ b/drivers/gpio/gpio-generic.c
> @@ -388,6 +388,14 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc,
>         return 0;
>  }
>
> +static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin)
> +{
> +       if (gpio_pin < chip->ngpio)
> +               return 0;
> +
> +       return -EINVAL;

Nit: I might have preferred it turned that way:

    if (gpio_pin >= chip->ngpio)
            return -EINVAL;

    return 0;

That makes the error case the exception and the success case the
default, which looks more natural to me. But the statement is simple
enough to be easily understood anyway.

> +}
> +
>  int bgpio_remove(struct bgpio_chip *bgc)
>  {
>         return gpiochip_remove(&bgc->gc);
> @@ -413,6 +421,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,
>         bgc->gc.label = dev_name(dev);
>         bgc->gc.base = -1;
>         bgc->gc.ngpio = bgc->bits;
> +       bgc->gc.request = bgpio_request;
>
>         ret = bgpio_setup_io(bgc, dat, set, clr);
>         if (ret)
> --
> 1.9.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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