[PATCH v2] powerpc: add setmaskedbits macros

Kumar Gala galak at kernel.crashing.org
Thu Aug 16 13:22:36 EST 2007


On Aug 15, 2007, at 4:30 PM, Timur Tabi wrote:

> This patch adds the setmaskedbits_xxx() macros, which are used to  
> set a
> multiple-bit bit pattern in a register.  The macros include a mask,  
> which
> zeros the respective bits before applying the value via a bitwise-OR.
> There are big-endian and little-endian versions for 8, 16, 32, and  
> 64 bits.
>
> These new macros are useful because the setbits macros can only be  
> used
> to set single-bit fields.  For example, if you have a 32-bit register
> where bits 17-20 need to be set to 0100, you would do
> setmaskedbits_be32(p, 4 << 11, 0xF << 11).
>
> Signed-off-by: Timur Tabi <timur at freescale.com>
> ---
>
> Updated the changelog to include a reason why you'd want these macros.
> I have a number of new SOC device drivers coming up that will use  
> these
> macros, if this patch is accepted.

Can you post a driver that uses this.  I'm interested in seeing what  
the readability is really like using these macros.

- k






More information about the Linuxppc-dev mailing list