diff options
author | Codrin Ciubotariu <codrin.ciubotariu@freescale.com> | 2015-07-24 16:52:19 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2015-08-12 20:47:44 -0400 |
commit | c69abd801b3600252726948e0763b2b3c3fe9e19 (patch) | |
tree | 00c53f06a74d154a79c469df26e11116e6fdca02 /include/bitfield.h | |
parent | 4cffbec96a3cf95ec3f4774229712d647f603541 (diff) |
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>
Diffstat (limited to 'include/bitfield.h')
-rw-r--r-- | include/bitfield.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/bitfield.h b/include/bitfield.h index ec4815c8e05..b884c746001 100644 --- a/include/bitfield.h +++ b/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); } |