summaryrefslogtreecommitdiff
path: root/include/bitfield.h
diff options
context:
space:
mode:
authorCodrin Ciubotariu <codrin.ciubotariu@freescale.com>2015-07-24 16:52:19 +0300
committerTom Rini <trini@konsulko.com>2015-08-12 20:47:44 -0400
commitc69abd801b3600252726948e0763b2b3c3fe9e19 (patch)
tree00c53f06a74d154a79c469df26e11116e6fdca02 /include/bitfield.h
parent4cffbec96a3cf95ec3f4774229712d647f603541 (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.h2
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);
}