[U-Boot] [PATCH V4 1/6] io: add and* and or* operation api to set and clear bit

Lei Wen adrian.wenl at gmail.com
Tue Mar 29 04:47:04 CEST 2011


Hi Scott,

On Tue, Mar 29, 2011 at 12:05 AM, Scott Wood <scottwood at freescale.com> wrote:
> On Sun, 27 Mar 2011 22:48:50 -0700
> Lei Wen <leiwen at marvell.com> wrote:
>
>> Those api take use of read*/write* to align the current dmb usage.
>> Also this could short the code length in one line.
>>
>> Signed-off-by: Lei Wen <leiwen at marvell.com>
>> ---
>>  arch/arm/include/asm/io.h |    8 ++++++++
>>  1 files changed, 8 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
>> index 1fbc531..71e85e8 100644
>> --- a/arch/arm/include/asm/io.h
>> +++ b/arch/arm/include/asm/io.h
>> @@ -141,6 +141,14 @@ extern inline void __raw_readsl(unsigned int addr, void *data, int longlen)
>>  #define readw(c)     ({ u16 __v = __arch_getw(c); __iormb(); __v; })
>>  #define readl(c)     ({ u32 __v = __arch_getl(c); __iormb(); __v; })
>>
>> +#define orb(v,c)       writeb(readb(c) | v, c)
>> +#define orw(v,c)       writew(readw(c) | v, c)
>> +#define orl(v,c)       writel(readl(c) | v, c)
>> +
>> +#define andb(v,c)      writeb(readb(c) & v, c)
>> +#define andw(v,c)      writew(readw(c) & v, c)
>> +#define andl(v,c)      writel(readl(c) & v, c)
>> +
>>  /*
>>   * The compiler seems to be incapable of optimising constants
>>   * properly.  Spell it out to the compiler in some cases.
>
> What does this do that setbits*/clrbits* don't?

Those and*/or* include the dmb() operation included in the read*/write*, which
is not included in the __raw_read*/__raw_write* that setbits*/clrbits* refer to.
I think it's better to keep another instance to set the bit, since
there is read* and __raw_read*
exist and have difference.

>
> Other than be missing parentheses aro und "v", causing problems if a
> complex expression is passed in.

Yep, that make sense. Thanks for pionting it out, I would make a
update for this patch.

Best regards,
Lei


More information about the U-Boot mailing list