pwm: tiehrpwm: fix copy-paste error in obsolete DT binding fallback
PATCH 1/1 pwm: tiehrpwm: fix copy-paste error in obsolete DT binding fallback
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.
--- drivers/pwm/pwm-tiehrpwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-tiehrpwm.c +1 -1
@@ -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" ); }
Signature · 1 line
2.46.2.windows.1
Uwe Kleine-König
maintainerHello,
Quoted 18 lines · Manush Prajwal
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 matchesehrpwm_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".
Quoted 3 lines
Fix the check to test for "ti,am33xx-ehrpwm" as intended.
Signed-off-by Manush Prajwal <[email protected]>
Looks right, I guess it needs:
.
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
Hi Uwe,
Thanks for the quick review and for digging up the Fixes commit.
Quoted 6 lines
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
Uwe Kleine-König
maintainerHello,
Quoted 19 lines · Manush Prajwal
Hi Uwe,
Thanks for the quick review and for digging up the Fixes commit.
Quoted 6 lines
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
ae5200d22716was merged in 2014 without anyone noticing or reporting it, it seems very likely that nobody relies on this obsolete binding anymore.
Quoted 8 lines
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?
I think dropping the compat handling is fine. I didn't check if according to the binding, this compat handling is still ok. If yes, this needs deprecation, too. I wouldn't touch the tiecap driver for now, as (AFAIU) there is no such breakage and keeping the compat handling there isn't a burden.
Best regards
Uwe