On 18:04 Fri 10 May     , Alexander Shiyan wrote:
> Patch adds gpio_to_desc helper for validate GPIO.
> A bit optimization is performed (about -250 bytes on ARM).
> 
> Signed-off-by: Alexander Shiyan <shc_w...@mail.ru>
> ---
>  drivers/gpio/gpiolib.c | 97 
> ++++++++++++++++++++++++++------------------------
>  1 file changed, 51 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 6398268..d7aa094 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -32,20 +32,30 @@ static int gpio_ensure_requested(struct gpio_info *gi, 
> int gpio)
>       return gpio_request(gpio, "gpio");
>  }
>  
> +static struct gpio_info *gpio_to_desc(unsigned gpio)
> +{
> +     if (!gpio_is_valid(gpio))
put the WARN too as we need to known a gpio_xxx is used on a non valid gpio
> +             return NULL;
> +
> +     if (!gpio_desc[gpio].chip)
> +             return NULL;
> +
> +     return &gpio_desc[gpio];
> +}
> +

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to