From: Simon Glass Date: Fri, 11 Oct 2019 22:16:49 +0000 (-0600) Subject: dm: regmap: Fix mask in regmap_update_bits() X-Git-Tag: v2020.10~528^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5ca5ec1e3272f40a7ad26a15e3df3bb18e0b11d8;p=platform%2Fkernel%2Fu-boot.git dm: regmap: Fix mask in regmap_update_bits() This function assumes that the 'val' parameter has no masked bits set. This is not defined by the function prototype though. Fix the function to mask the value and update the documentation. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Reviewed-by: Jean-Jacques Hiblot --- diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index d1d12eef38..e9e55c9d16 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -462,5 +462,5 @@ int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val) reg &= ~mask; - return regmap_write(map, offset, reg | val); + return regmap_write(map, offset, reg | (val & mask)); } diff --git a/include/regmap.h b/include/regmap.h index 0854200a9c..9ada1af5ef 100644 --- a/include/regmap.h +++ b/include/regmap.h @@ -295,7 +295,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset, * @map: The map returned by regmap_init_mem*() * @offset: Offset of the memory * @mask: Mask to apply to the read value - * @val: Value to apply to the value to write + * @val: Value to OR with the read value after masking. Note that any + * bits set in @val which are not set in @mask are ignored * Return: 0 if OK, -ve on error */ int regmap_update_bits(struct regmap *map, uint offset, uint mask, uint val);