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

Mike Frysinger vapier at gentoo.org
Fri Jun 17 02:06:20 CEST 2011


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';

> +	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

otherwise, looks fine.  not that i looked too closely as i dont know anything 
about Tegra2 parts.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110616/8fd28e78/attachment.pgp 


More information about the U-Boot mailing list