Skip to contentSkip to conversation

pwm: tiehrpwm: fix copy-paste error in obsolete DT binding fallback

PATCH In review Manush Prajwal 2 participants 4 messages Sep 28 – Nov 23 PWM

lore
Share & tools
lore
#0 lore raw

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
index 3a53489f0..40166c5c8 100644
@@ -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
#1 lore raw

Hello,

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 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".

Quoted 3 lines

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

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

#2 lore raw

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

#3 lore raw

Hello,

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 ae5200d22716 was 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