public inbox for linux-pwm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pwm: sl28cpld: Set driver data before registering the PWM chip
@ 2020-12-04 12:52 Thierry Reding
  2020-12-04 13:38 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2020-12-04 12:52 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Uwe Kleine-König, Lee Jones, linux-pwm, Michael Walle

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(-)

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;
 }
 
-- 
2.29.2


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

end of thread, other threads:[~2020-12-04 13:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-04 12:52 [PATCH] pwm: sl28cpld: Set driver data before registering the PWM chip Thierry Reding
2020-12-04 13:38 ` Lee Jones

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