Skip to contentSkip to conversation

pwm: Fix incorrect variable used in error message

PATCH In review Colin Ian King 2 participants 2 messages Sep 2, 2025 – Sep 9, 2025

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

PATCH 1/1 pwm: Fix incorrect variable used in error message

The dev_err message is reporting the incorrect return value ret_tohw, it should be reporting the value in ret_fromhw. Fix this by using ret_fromhw instead of ret_tohw.

Fixes 6c5126c6406d ("pwm: Provide new consumer API functions for waveforms")
---
 drivers/pwm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/core.c +1 -1
index ec4112e6209a..ea2ccf42e814 100644
@@ -276,7 +276,7 @@ int pwm_round_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *
 
 	if (IS_ENABLED(CONFIG_PWM_DEBUG) && ret_fromhw > 0)
 		dev_err(&chip->dev, "Unexpected return value from __pwm_round_waveform_fromhw: requested %llu/%llu [+%llu], return value %d\n",
-			wf_req.duty_length_ns, wf_req.period_length_ns, wf_req.duty_offset_ns, ret_tohw);
+			wf_req.duty_length_ns, wf_req.period_length_ns, wf_req.duty_offset_ns, ret_fromhw);
 
 	if (IS_ENABLED(CONFIG_PWM_DEBUG) &&
 	    (ret_tohw == 0) != pwm_check_rounding(&wf_req, wf))
Signature · 1 line
2.51.0
#1 lore raw
Quoted 15 lines · Colin Ian King

The dev_err message is reporting the incorrect return value ret_tohw, it should be reporting the value in ret_fromhw. Fix this by using ret_fromhw instead of ret_tohw.

Fixes 6c5126c6406d ("pwm: Provide new consumer API functions for waveforms")
---
 drivers/pwm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/core.c +0 -0
index ec4112e6209a..ea2ccf42e814 100644

drivers/pwm/core.c int pwm_round_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform * · line 282

Quoted 8 lines
drivers/pwm/core.c +1 -1
@@ -276,7 +276,7 @@ int pwm_round_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *
 
 	if (IS_ENABLED(CONFIG_PWM_DEBUG) && ret_fromhw > 0)
 		dev_err(&chip->dev, "Unexpected return value from __pwm_round_waveform_fromhw: requested %llu/%llu [+%llu], return value %d\n",
-			wf_req.duty_length_ns, wf_req.period_length_ns, wf_req.duty_offset_ns, ret_tohw);
+			wf_req.duty_length_ns, wf_req.period_length_ns, wf_req.duty_offset_ns, ret_fromhw);
 
 	if (IS_ENABLED(CONFIG_PWM_DEBUG) &&
 	    (ret_tohw == 0) != pwm_check_rounding(&wf_req, wf))

Indeed, thanks for the fix. I added it to my pwm/fixes branch at
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git. I didn't made my mind up yet if the patches contained in there are relevant enough to send it to Linus before 6.17.

Best regards
Uwe