diff mbox series

[v1,093/101] pwm: sun4i: Store parent device in driver data

Message ID 20230808171931.944154-94-u.kleine-koenig@pengutronix.de
State Superseded
Headers show
Series pwm: Fix lifetime issues for pwm_chips | expand

Commit Message

Uwe Kleine-König Aug. 8, 2023, 5:19 p.m. UTC
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, store a pointer to
the parent device in driver data.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-sun4i.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index 4251807e496b..f2e85484f397 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -81,6 +81,7 @@  struct sun4i_pwm_data {
 };
 
 struct sun4i_pwm_chip {
+	struct device *parent;
 	struct clk *bus_clk;
 	struct clk *clk;
 	struct reset_control *rst;
@@ -244,7 +245,7 @@  static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	if (!cstate.enabled) {
 		ret = clk_prepare_enable(sun4i_pwm->clk);
 		if (ret) {
-			dev_err(chip->dev, "failed to enable PWM clock\n");
+			dev_err(sun4i_pwm->parent, "failed to enable PWM clock\n");
 			return ret;
 		}
 	}
@@ -252,7 +253,7 @@  static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	ret = sun4i_pwm_calculate(sun4i_pwm, state, &duty, &period, &prescaler,
 				  &bypass);
 	if (ret) {
-		dev_err(chip->dev, "period exceeds the maximum value\n");
+		dev_err(sun4i_pwm->parent, "period exceeds the maximum value\n");
 		if (!cstate.enabled)
 			clk_disable_unprepare(sun4i_pwm->clk);
 		return ret;
@@ -397,6 +398,7 @@  static int sun4i_pwm_probe(struct platform_device *pdev)
 		return PTR_ERR(chip);
 	sun4ichip = to_sun4i_pwm_chip(chip);
 
+	sun4ichip->parent = &pdev->dev;
 	sun4ichip->data = data;
 	sun4ichip->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(sun4ichip->base))