diff options
author | Codrin Ciubotariu <codrin.ciubotariu@freescale.com> | 2015-07-24 13:52:19 (GMT) |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2015-08-13 00:47:44 (GMT) |
commit | c69abd801b3600252726948e0763b2b3c3fe9e19 (patch) | |
tree | 00c53f06a74d154a79c469df26e11116e6fdca02 /include | |
parent | 4cffbec96a3cf95ec3f4774229712d647f603541 (diff) | |
download | u-boot-fsl-qoriq-c69abd801b3600252726948e0763b2b3c3fe9e19.tar.xz |
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')
-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 ec4815c..b884c74 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); } |