Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-16 Thread Timur Tabi
Benjamin Herrenschmidt wrote: >> The second example is actually a trick that lets me set some bits and clear >> others in one shot, so for the gumr_h register, all of the above values are >> single bits. I guess that's not a good example. > > Such tricks deserve at least a comment. Would it b

Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-16 Thread Benjamin Herrenschmidt
On Thu, 2007-08-16 at 10:26 -0500, Timur Tabi wrote: > Kumar Gala wrote: > > >> setmaskedbits_be32(&uccp->gumr_l, > >> UCC_SLOW_GUMR_L_MODE_QMC | UCC_SLOW_GUMR_L_TDCR_1 | > >> UCC_SLOW_GUMR_L_RDCR_16, > >> UCC_SLOW_GUMR_L_MODE_MASK | UCC_SLOW_GUMR_L_TDCR_MASK |

Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-16 Thread Timur Tabi
Michael Ellerman wrote: > And if you're going to the trouble of making a macro, why not make it a > bit more useful and have it check that the value and the mask match, ie: > > (v & ~m == 0) What should I do if it fails this check? > Final random thought, you could make the size/endian an argum

Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-16 Thread Timur Tabi
Kumar Gala wrote: >> setmaskedbits_be32(&uccp->gumr_l, >> UCC_SLOW_GUMR_L_MODE_QMC | UCC_SLOW_GUMR_L_TDCR_1 | >> UCC_SLOW_GUMR_L_RDCR_16, >> UCC_SLOW_GUMR_L_MODE_MASK | UCC_SLOW_GUMR_L_TDCR_MASK | >> UCC_SLOW_GUMR_L_RDCR_MASK); >> >> setmaskedbits_be

Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-16 Thread Kumar Gala
On Aug 16, 2007, at 10:18 AM, Timur Tabi wrote: > Kumar Gala wrote: > >> Can you post a driver that uses this. I'm interested in seeing >> what the readability is really like using these macros. > > I do not yet have any drivers ready, but I can give you an example: > > setmaskedbits_be3

Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-16 Thread Timur Tabi
Kumar Gala wrote: > Can you post a driver that uses this. I'm interested in seeing what the > readability is really like using these macros. I do not yet have any drivers ready, but I can give you an example: setmaskedbits_be32(&uccp->gumr_l, UCC_SLOW_GUMR_L_MODE_QMC |

Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-16 Thread Geert Uytterhoeven
On Thu, 16 Aug 2007, Michael Ellerman wrote: > Can you extract the masking logic, rather than repeating it 7 times: > > #define maskbits(a, v, m) ((a) & ~(m) | (v)) > > And if you're going to the trouble of making a macro, why not make it a > bit more useful and have it check that the value a

Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-15 Thread Michael Ellerman
On Wed, 2007-08-15 at 16:30 -0500, 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 a

Re: [PATCH v2] powerpc: add setmaskedbits macros

2007-08-15 Thread Kumar Gala
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-endi