mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pwm: tiehrpwm: fix copy-paste error in obsolete DT binding fallback
@ 2026-09-28 17:55 Manush Prajwal
  2026-09-29  6:00 ` Uwe Kleine-König
  0 siblings, 1 reply; 3+ messages in thread
From: Manush Prajwal @ 2026-09-28 17:55 UTC (permalink / raw)
  To: ukleinek; +Cc: linux-pwm, linux-kernel

ehrpwm_pwm_probe() attempts to provide backward compatibility for older
device trees where the functional clock "fck" was supplied by the parent
PWMSS device rather than within the PWM child node itself.

However, when devm_clk_get() for "fck" fails, the fallback checks:

	if (of_device_is_compatible(np, "ti,am33xx-ecap")) {
		dev_warn(&pdev->dev, "Binding is obsolete.\n");
		clk = devm_clk_get(pdev->dev.parent, "fck");
	}

Because this logic was copied from pwm-tiecap.c, it mistakenly checks for
"ti,am33xx-ecap" instead of "ti,am33xx-ehrpwm". An eHRPWM node matches
ehrpwm_of_match ("ti,am3352-ehrpwm" or "ti,am33xx-ehrpwm") and will never
be compatible with "ti,am33xx-ecap". Consequently, for any device tree
using the obsolete "ti,am33xx-ehrpwm" binding, the fallback never triggers
and probe fails with "Failed to get fck".

Fix the check to test for "ti,am33xx-ehrpwm" as intended.

Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>
---
 drivers/pwm/pwm-tiehrpwm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 3a53489f0..40166c5c8 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -426,7 +426,7 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
 
 	clk = devm_clk_get(&pdev->dev, "fck");
 	if (IS_ERR(clk)) {
-		if (of_device_is_compatible(np, "ti,am33xx-ecap")) {
+		if (of_device_is_compatible(np, "ti,am33xx-ehrpwm")) {
 			dev_warn(&pdev->dev, "Binding is obsolete.\n");
 			clk = devm_clk_get(pdev->dev.parent, "fck");
 		}
-- 
2.46.2.windows.1



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

* Re: [PATCH] pwm: tiehrpwm: fix copy-paste error in obsolete DT binding fallback
  2026-09-28 17:55 [PATCH] pwm: tiehrpwm: fix copy-paste error in obsolete DT binding fallback Manush Prajwal
@ 2026-09-29  6:00 ` Uwe Kleine-König
  0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2026-09-29  6:00 UTC (permalink / raw)
  To: Manush Prajwal; +Cc: linux-pwm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1414 bytes --]

Hello,

On Mon, Sep 28, 2026 at 11:25:09PM +0530, Manush Prajwal wrote:
> ehrpwm_pwm_probe() attempts to provide backward compatibility for older
> device trees where the functional clock "fck" was supplied by the parent
> PWMSS device rather than within the PWM child node itself.
> 
> However, when devm_clk_get() for "fck" fails, the fallback checks:
> 
> 	if (of_device_is_compatible(np, "ti,am33xx-ecap")) {
> 		dev_warn(&pdev->dev, "Binding is obsolete.\n");
> 		clk = devm_clk_get(pdev->dev.parent, "fck");
> 	}
> 
> Because this logic was copied from pwm-tiecap.c, it mistakenly checks for
> "ti,am33xx-ecap" instead of "ti,am33xx-ehrpwm". An eHRPWM node matches
> ehrpwm_of_match ("ti,am3352-ehrpwm" or "ti,am33xx-ehrpwm") and will never
> be compatible with "ti,am33xx-ecap". Consequently, for any device tree
> using the obsolete "ti,am33xx-ehrpwm" binding, the fallback never triggers
> and probe fails with "Failed to get fck".
> 
> Fix the check to test for "ti,am33xx-ehrpwm" as intended.
> 
> Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>

Looks right, I guess it needs:
Fixes: ae5200d22716 ("pwm: pwm-ti*: Get the clock from the PWMSS parent when using old bindings")
.

I wonder: Did you find this because you still use the old bindings, or
by code inspection somehow? If the latter, maybe it's time to drop the
handling instead?

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] pwm: tiehrpwm: fix copy-paste error in obsolete DT binding fallback
@ 2026-09-29 10:06 Manush Prajwal
  0 siblings, 0 replies; 3+ messages in thread
From: Manush Prajwal @ 2026-09-29 10:06 UTC (permalink / raw)
  To: ukleinek; +Cc: linux-pwm, linux-kernel

Hi Uwe,

Thanks for the quick review and for digging up the Fixes commit.

> Looks right, I guess it needs:
> Fixes: ae5200d22716 ("pwm: pwm-ti*: Get the clock from the PWMSS parent when using old bindings")
> 
> I wonder: Did you find this because you still use the old bindings, or
> by code inspection somehow? If the latter, maybe it's time to drop the
> handling instead?

This was found purely by code inspection during a review of the PWM
drivers, not from running older bindings on actual hardware.

Given that this fallback in pwm-tiehrpwm has been effectively broken ever
since commit ae5200d22716 was merged in 2014 without anyone noticing or
reporting it, it seems very likely that nobody relies on this obsolete
binding anymore.

I would be happy to send a patch dropping the obsolete binding handling
instead (from pwm-tiehrpwm, or from both pwm-tiehrpwm and pwm-tiecap if
you prefer keeping them consistent).

Or if you'd rather keep backward compatibility, I can send a v2 of this
fix with the Fixes: tag included.

Which direction would you prefer?

Best regards,
Manush


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

end of thread, other threads:[~2026-09-29 10:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 17:55 [PATCH] pwm: tiehrpwm: fix copy-paste error in obsolete DT binding fallback Manush Prajwal
2026-09-29  6:00 ` Uwe Kleine-König
2026-09-29 10:06 Manush Prajwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®