[U-Boot] [PATCH V4 1/2] GPIO: Tegra2: add GPIO driver for Tegra2

Tom Warren twarren.nvidia at gmail.com
Fri Jun 17 02:09:26 CEST 2011


Mike,

On Thu, Jun 16, 2011 at 5:06 PM, Mike Frysinger <vapier at gentoo.org> wrote:
> On Thursday, June 16, 2011 19:51:33 Tom Warren wrote:
>> +int gpio_request(int gp, const char *label)
>> +{
>> +     if (gp >= MAX_NUM_GPIOS)
>> +             return -1;
>> +
>> +     strncpy(gpio_names[gp].name, label, GPIO_NAME_SIZE);
>
> if the label is >=GPIO_NAME_SIZE, the result will not be NUL terminated.  i'd
> suggest you add something like this to after the strncpy call:
>        gpio_names[gp].name[GPIO_NAME_SIZE - 1] = '\0';
Will do. Thanks for the quick response!

>
>> +     return (val >> GPIO_BIT(gp)) & 1;
>
> could be written as !!(val >> GPIO_BIT(gp)), but up to you, or see how the
> code size works out
I'll check it and update if your way is smaller. Thanks.

>
> otherwise, looks fine.  not that i looked too closely as i dont know anything
> about Tegra2 parts.
> -mike
>
Thanks,

Tom


More information about the U-Boot mailing list