[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170310154139.GM31469@gate.crashing.org>
Date: Fri, 10 Mar 2017 09:41:39 -0600
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Christophe LEROY <christophe.leroy@....fr>
Cc: Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Scott Wood <oss@...error.net>, linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation
On Fri, Mar 10, 2017 at 03:41:23PM +0100, Christophe LEROY wrote:
> >>>>gpio_get() and gpio_set() are used extensively by some GPIO based
> >>>>drivers like SPI, NAND, so it may be worth it as it doesn't impair
> >>>>readability (if anyone prefers, we could write (1 << 31) >> i instead
> >>>>of 0x80000000 >> i )
> >>>
> >>>1 << 31 is undefined behaviour, of course.
> >>
> >>Shall it be 1U << 31 ?
> >
> >Sure, that works. "1 << (31 - i)" is most readable (but it doesn't yet
> >generate the code you want).
>
> Euh .... I'm a bit lost. Do you mean the form we have today is the
> driver is wrong ?
Heh, yes. But is't okay with GCC, so don't worry about it.
The point is that "0x80000000 >> i" is less readable.
Segher
Powered by blists - more mailing lists