Skip to contentSkip to conversation

pwm: sl28cpld: Set driver data before registering the PWM chip

PATCH In review Thierry Reding 2 participants 2 messages Dec 4, 2020

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

PATCH 1/1 pwm: sl28cpld: Set driver data before registering the PWM chip

The PWM core code can call back into the PWM chip's implementation at any time after the chip has been registered. Since the driver uses driver data to store contextual information, registration must happen after the driver data has been set.

---
 drivers/pwm/pwm-sl28cpld.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-sl28cpld.c +2 -2
index 5046b6b7fd35..c5866a2b47b5 100644
@@ -230,6 +230,8 @@ static int sl28cpld_pwm_probe(struct platform_device *pdev)
 	chip->base = -1;
 	chip->npwm = 1;
 
+	platform_set_drvdata(pdev, priv);
+
 	ret = pwmchip_add(&priv->pwm_chip);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add PWM chip (%pe)",
@@ -237,8 +239,6 @@ static int sl28cpld_pwm_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	platform_set_drvdata(pdev, priv);
-
 	return 0;
 }
 
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Thierry Reding

The PWM core code can call back into the PWM chip's implementation at any time after the chip has been registered. Since the driver uses driver data to store contextual information, registration must happen after the driver data has been set.

---
 drivers/pwm/pwm-sl28cpld.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog