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>
master
Codrin Ciubotariu 9 years ago committed by Tom Rini
parent 4cffbec96a
commit c69abd801b
  1. 2
      include/bitfield.h

@ -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…
Cancel
Save