lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <Pine.LNX.4.64.0612292141440.18171@xanadu.home>
Date:	Fri, 29 Dec 2006 22:15:31 -0500 (EST)
From:	Nicolas Pitre <nico@....org>
To:	David Brownell <david-b@...bell.net>
Cc:	pHilipp Zabel <philipp.zabel@...il.com>,
	Andrew Morton <akpm@...l.org>,
	Linux Kernel list <linux-kernel@...r.kernel.org>,
	Andrew Victor <andrew@...people.com>,
	Bill Gatliff <bgat@...lgatliff.com>,
	Haavard Skinnemoen <hskinnemoen@...el.com>, jamey.hicks@...com,
	Kevin Hilman <khilman@...sta.com>,
	Russell King <rmk@....linux.org.uk>,
	Tony Lindgren <tony@...mide.com>
Subject: Re: [patch 2.6.20-rc1 5/6] SA1100 GPIO wrappers

On Fri, 29 Dec 2006, David Brownell wrote:

> Here's a version that compiles ...

This patch is completely broken.

> Arch-neutral GPIO calls for PXA.

This is not PXA but SA1100 to start with.

> Signed-off-by: David Brownell <dbrownell@...rs.sourceforge.net>
> 
> Index: pxa/include/asm-arm/arch-sa1100/gpio.h
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ pxa/include/asm-arm/arch-sa1100/gpio.h	2006-12-29 
> 18:21:00.000000000 -0800
> @@ -0,0 +1,100 @@

[...]

> +static inline int gpio_direction_input(unsigned gpio)
> +{
> +	if (gpio > GPIO_MAX)
> +		return -EINVAL;
> +	GPDR = (GPDR_In << gpio);

This is crap.  It will expand to GPDR = 0 effectively making _all_ gpios 
as input.

What you want here is:

	GPDR &= ~(1 << gpio);

and you most probably need to protect the implied read-modify-write 
cycle with a spinlock unless the generic gpio API expects this 
protection is the responsibility of the caller.

> +static inline int gpio_direction_output(unsigned gpio)
> +{
> +	if (gpio > GPIO_MAX)
> +		return -EINVAL;
> +	GPDR = (GPDR_Out << gpio);

Same issue, although this would make all gpios as input except for the 
specified one.

What you want is:

	GPDR |= (1 << gpio);

And again spinlock protection is probably needed.

> +static inline int __gpio_get_value(unsigned gpio)
> +{
> +	return GPLR & GPIO_GPIO(gpio);
> +}
> +
> +#define gpio_get_value(gpio)			\
> +	(__builtin_constant_p(gpio)		\
> +	? __gpio_get_value(gpio)		\
> +	: sa1100_gpio_get_value(gpio))
> +

Please drop the out of line version.  It will always be more costly than 
the inline version even for non constant gpio values.  And I think the 
usage of GPIO_GPIO(gpio) is more obfuscating than directly using
(1 << gpio).

> +static inline void __gpio_set_value(unsigned gpio, int value)
> +{
> +	if (value)
> +		GPSR = GPIO_GPIO(gpio);
> +	else
> +		GPCR = GPIO_GPIO(gpio);
> +}
> +
> +#define gpio_set_value(gpio,value)		\
> +	(__builtin_constant_p(gpio)		\
> +	? __gpio_set_value(gpio, value)		\
> +	: sa1100_gpio_set_value(gpio, value))

Same as above.


Nicolas
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ