diff mbox series

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

Message ID 20201204125213.3426567-1-thierry.reding@gmail.com
State Accepted
Headers show
Series pwm: sl28cpld: Set driver data before registering the PWM chip | expand

Commit Message

Thierry Reding Dec. 4, 2020, 12:52 p.m. UTC
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.

Reported-by: Michael Walle <michael@walle.cc>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 drivers/pwm/pwm-sl28cpld.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lee Jones Dec. 4, 2020, 1:38 p.m. UTC | #1
On Fri, 04 Dec 2020, Thierry Reding wrote:

> 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.
> 
> Reported-by: Michael Walle <michael@walle.cc>
> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> ---
>  drivers/pwm/pwm-sl28cpld.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Lee Jones <lee.jones@linaro.org>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-sl28cpld.c b/drivers/pwm/pwm-sl28cpld.c
index 5046b6b7fd35..c5866a2b47b5 100644
--- a/drivers/pwm/pwm-sl28cpld.c
+++ b/drivers/pwm/pwm-sl28cpld.c
@@ -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;
 }