mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-29 07:33:29 +08:00
include/bitfield.h: Assure new bitfield value doesn't touch unwanted bits
The new bitfield value must not be higher than its mask. Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@freescale.com> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
4cffbec96a
commit
c69abd801b
@ -54,5 +54,5 @@ static inline uint bitfield_replace(uint reg_val, uint shift, uint width,
|
||||
{
|
||||
uint mask = bitfield_mask(shift, width);
|
||||
|
||||
return (reg_val & ~mask) | (bitfield_val << shift);
|
||||
return (reg_val & ~mask) | ((bitfield_val << shift) & mask);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user