Commit c69abd801b3600252726948e0763b2b3c3fe9e19

Authored by Codrin Ciubotariu
Committed by Tom Rini
1 parent 4cffbec96a

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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -54,6 +54,6 @@
54 54 {
55 55 uint mask = bitfield_mask(shift, width);
56 56  
57   - return (reg_val & ~mask) | (bitfield_val << shift);
  57 + return (reg_val & ~mask) | ((bitfield_val << shift) & mask);
58 58 }