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.9040...@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
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to