[U-Boot] [PATCH v3 02/10] armv7: add miscellaneous utility macros

Aneesh V aneesh at ti.com
Thu Jun 16 07:39:55 CEST 2011


Hi Grame,

On Wednesday 15 June 2011 06:12 PM, Graeme Russ wrote:
> On 15/06/11 22:04, Wolfgang Denk wrote:
>> Dear Aneesh V,
>>
>> In message<4DF89102.9040508 at ti.com>  you wrote:
>>>
>>> Will you accept something like this?
>>>
>>> a_val = (reg&  a_mask)>>  a_shift;
>>
>> Yes, of course (that's what seems most natural to me).
>>
>
> Me too - The code is obvious - the desired value is being masked out of a
> larger composite value and then shifted right to bit 0
>
> And to set the value then you have:
>
> 	reg&= ~a_mask;				/* Clear a_val */
> 	reg |= (a_val<<  a_shift)&  a_mask;	/* Set new a_val */
>
> AND'ing with a_mask is required to prevent accidental clobbering when a_val
> is out-of-range. May give undesirable results by setting an illegal a_val,
> but at least you don't clobber unrelated bit fields

These are exactly what my helper functions were doing. Are you
suggesting that doing these directly is better than doing them
using helper functions?

best regards,
Aneesh


More information about the U-Boot mailing list