mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00: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
1 changed files with 1 additions and 1 deletions
|
@ -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 a new issue