[PATCH] mxc/gpio: make _set_value work with values != 0/1

Peter Korsgaard jacmet at sunsite.dk
Mon Oct 11 08:21:30 EDT 2010


>>>>> "Uwe" == Uwe Kleine-König <u.kleine-koenig at pengutronix.de> writes:

Hi,

 Uwe> On Mon, Oct 11, 2010 at 01:59:05PM +0200, Peter Korsgaard wrote:
 >> @@ -234,8 +234,13 @@ static void mxc_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 >> u32 l;
 >> unsigned long flags;
 >> 
 >> +

Ups, that extra line shouldn't have been there.

 >> spin_lock_irqsave(&port->lock, flags);
 >> -	l = (__raw_readl(reg) & (~(1 << offset))) | (value << offset);
 >> +	l = __raw_readl(reg);
 >> +	if (value)
 >> +		l |= 1 << offset;
 >> +	else
 >> +		l &= ~(1 << offset);
 Uwe> Why not just

 Uwe> 	l = (__raw_readl(reg) & (~(1 << offset))) | (!!value << offset);

Se my other reply. I don't feel strongly about it, but I for one don't
remember the precedence rules for !! and << offhand.

-- 
Bye, Peter Korsgaard



More information about the linux-arm-kernel mailing list