Skip to contentSkip to conversation

clk: microchip: mpfs: fix regmap_update_bits() mask/val order

PATCH Applied Pedro Kopper 3 participants 3 messages Aug 14 – Aug 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: microchip: mpfs: fix regmap_update_bits() mask/val order

mpfs_cfg_clk_set_rate() passes the mask and value arguments to regmap_update_bits() in the wrong order. The resulting write becomes reg = orig_reg | val, causing bits to not be cleared if the clock divider changes.

Pass the arguments in the correct order so the divider field is updated as intended.

Fixes c6f2dddfa7f9 ("clk: microchip: mpfs: use regmap for clocks")
---
 drivers/clk/microchip/clk-mpfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/microchip/clk-mpfs.c +1 -1
index ee58304913ef..7f044775aea8 100644
@@ -285,7 +285,7 @@ static int mpfs_cfg_clk_set_rate(struct clk_hw *hw, unsigned long rate, unsigned
 
 	mask = clk_div_mask(cfg->width) << cfg->shift;
 	val = divider_setting << cfg->shift;
-	regmap_update_bits(cfg->map, cfg->map_offset, val, mask);
+	regmap_update_bits(cfg->map, cfg->map_offset, mask, val);
 
 	return 0;
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Pedro Kopper

mpfs_cfg_clk_set_rate() passes the mask and value arguments to regmap_update_bits() in the wrong order. The resulting write becomes reg = orig_reg | val, causing bits to not be cleared if the clock divider changes.

Pass the arguments in the correct order so the divider field is updated as intended.

Fixes c6f2dddfa7f9 ("clk: microchip: mpfs: use regmap for clocks")

Cheers,
Conor.

Quoted 20 lines
---
 drivers/clk/microchip/clk-mpfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/microchip/clk-mpfs.c +1 -1
index ee58304913ef..7f044775aea8 100644
@@ -285,7 +285,7 @@ static int mpfs_cfg_clk_set_rate(struct clk_hw *hw, unsigned long rate, unsigned
 
 	mask = clk_div_mask(cfg->width) << cfg->shift;
 	val = divider_setting << cfg->shift;
-	regmap_update_bits(cfg->map, cfg->map_offset, val, mask);
+	regmap_update_bits(cfg->map, cfg->map_offset, mask, val);
 
 	return 0;
 }
Signature · 1 line
2.43.0
maintainer Applied
#2 lore raw
In reply to Pedro Kopper

Quoting Pedro Kopper (2026-08-14 02:22:13)

Quoted 11 lines

mpfs_cfg_clk_set_rate() passes the mask and value arguments to regmap_update_bits() in the wrong order. The resulting write becomes reg = orig_reg | val, causing bits to not be cleared if the clock divider changes.

Pass the arguments in the correct order so the divider field is updated as intended.

Fixes c6f2dddfa7f9 ("clk: microchip: mpfs: use regmap for clocks")

---

Applied to clk-next