From: Codrin Ciubotariu Date: Fri, 24 Jul 2015 13:52:19 +0000 (+0300) Subject: include/bitfield.h: Assure new bitfield value doesn't touch unwanted bits X-Git-Tag: KARO-TX6-2015-09-18~455 X-Git-Url: https://git.kernelconcepts.de/?a=commitdiff_plain;h=f3a70a92fe95ecdfb4a6ae2de4b00fc6cceccfec;p=karo-tx-uboot.git 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 Reviewed-by: Joe Hershberger --- diff --git a/include/bitfield.h b/include/bitfield.h index ec4815c8e0..b884c74600 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); }