[U-Boot] [PATCH] gpio: omap_gpio: Remove check_gpio() function

Nikita Kiryanov nikita at compulab.co.il
Thu Jun 20 09:44:43 CEST 2013


On 06/20/2013 10:20 AM, Axel Lin wrote:
> 2013/6/20 Nikita Kiryanov <nikita at compulab.co.il>
>
>> Hi Axel,
>>
>>
>> On 06/20/2013 04:03 AM, Axel Lin wrote:
>>
>>> check_gpio() and gpio_is_valid() are both used to check if a gpio is
>>> valid or
>>> not. It looks pointless to have both function because we can just call
>>> gpio_is_valid() instead of check_gpio(). Thus remove check_gpio()
>>> function.
>>>
>>
>> I don't see the benefit in this patch.
>> The functions clearly exist for different reasons: gpio_is_valid() is
>> part of the gpio api, while check_gpio() exists to attach an error
>> message to a failed validity check without causing code duplication all
>> over omap_gpio.c.
>>
>
> How about just showing error in gpio_is_valid() and then remove
> check_gpio()?

It is not an error for gpio_is_valid() to report that a gpio is not
valid. It is however an error to attempt to use an invalid gpio.

>
> int gpio_is_valid(int gpio)
> {
>          if ((gpio >= 0) && (gpio < 192))
>                  return 1;
>
>          printf("ERROR : invalid GPIO %d\n", gpio);
>          return 0;
> }
>
>
>> Essentially what you are doing is removing a helpful error message.
>
> My intention is to remove redundant code.

check_gpio() adds upon gpio_is_valid(). If you want to argue redundancy
you should explain why this addition is unnecessary.

>
> Regards,
> Axel
>


-- 
Regards,
Nikita.


More information about the U-Boot mailing list