All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (mr75203) Fix maximum clock divider
@ 2026-10-21 10:23 wuliwen
  2026-10-21 10:26 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: wuliwen @ 2026-10-21 10:23 UTC (permalink / raw)
  To: jdelvare, linux; +Cc: linux-hwmon, wuliwen

The MR75203 hardware documentation specifies that the clk_sys to
clk_ip frequency ratio must be between 2:1 and 512:1. This limit
is also explicitly documented in the existing pvt_init() comment,
but CLK_SYS_CYCLES_MAX is incorrectly defined as 514.

As a result, both the divider selection check and the final clamp
allow values beyond the supported range. At a divider of 514,
subtracting 2 yields a key of 512, causing the 8-bit CLK_SYNTH
LO, HI, and HOLD fields to overflow into adjacent bits.

Correct CLK_SYS_CYCLES_MAX to 512 to enforce the documented limit
and prevent invalid clock synthesizer configurations.

Fixes: 9d823351a337 ("hwmon: Add hardware monitoring driver for Moortec MR75203 PVT controller")
Signed-off-by: wuliwen <liwen.wu@spacemit.com>
---
 drivers/hwmon/mr75203.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
index 7848198f8996..8afc4f6ef0aa 100644
--- a/drivers/hwmon/mr75203.c
+++ b/drivers/hwmon/mr75203.c
@@ -41,7 +41,7 @@
 #define CLK_SYNTH_HI_SFT	8
 #define CLK_SYNTH_HOLD_SFT	16
 #define CLK_SYNTH_EN		BIT(24)
-#define CLK_SYS_CYCLES_MAX	514
+#define CLK_SYS_CYCLES_MAX	512
 #define CLK_SYS_CYCLES_MIN	2
 
 #define SDIF_DISABLE	0x04
-- 
2.34.1

This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not an intended recipient of this message, please delete it and any attachment from your system and notify the sender immediately by reply e-mail. Unintended recipients should not use, copy, disclose or take any action based on this message or any information contained in this message. Emails cannot be guaranteed to be secure or error free as they can be intercepted, amended, lost or destroyed, and you should take full responsibility for security checking. 
 
本邮件及其任何附件具有保密性质,并可能受其他保护或不允许被披露给第三方。如阁下误收到本邮件,敬请立即以回复电子邮件的方式通知发件人,并将本邮件及其任何附件从阁下系统中予以删除。如阁下并非本邮件写明之收件人,敬请切勿使用、复制、披露本邮件或其任何内容,亦请切勿依本邮件或其任何内容而采取任何行动。电子邮件无法保证是一种安全和不会出现任何差错的通信方式,可能会被拦截、修改、丢失或损坏,收件人需自行负责做好安全检查。

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: (mr75203) Fix maximum clock divider
  2026-10-21 10:23 [PATCH] hwmon: (mr75203) Fix maximum clock divider wuliwen
@ 2026-10-21 10:26 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-21 10:26 UTC (permalink / raw)
  To: wuliwen; +Cc: linux-hwmon

> The MR75203 hardware documentation specifies that the clk_sys to
> clk_ip frequency ratio must be between 2:1 and 512:1. This limit
> is also explicitly documented in the existing pvt_init() comment,
> but CLK_SYS_CYCLES_MAX is incorrectly defined as 514.
> 
> As a result, both the divider selection check and the final clamp
> allow values beyond the supported range. At a divider of 514,
> subtracting 2 yields a key of 512, causing the 8-bit CLK_SYNTH
> LO, HI, and HOLD fields to overflow into adjacent bits.
> 
> Correct CLK_SYS_CYCLES_MAX to 512 to enforce the documented limit
> and prevent invalid clock synthesizer configurations.
> 
> Fixes: 9d823351a337 ("hwmon: Add hardware monitoring driver for Moortec MR75203 PVT controller")
> Signed-off-by: wuliwen <liwen.wu@spacemit.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021102327.2619070-1-liwen.wu@spacemit.com?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-21 10:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 10:23 [PATCH] hwmon: (mr75203) Fix maximum clock divider wuliwen
2026-10-21 10:26 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.