diff mbox series

[v1,092/101] pwm: stmpe: Store parent device in driver data

Message ID 20230808171931.944154-93-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-stmpe.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-stmpe.c b/drivers/pwm/pwm-stmpe.c
index 9c0f96b77c42..3efa28a5a9a3 100644
--- a/drivers/pwm/pwm-stmpe.c
+++ b/drivers/pwm/pwm-stmpe.c
@@ -26,6 +26,7 @@ 
 #define STMPE_PWM_24XX_PINBASE	21
 
 struct stmpe_pwm {
+	struct device *parent;
 	struct stmpe *stmpe;
 	u8 last_duty;
 };
@@ -43,7 +44,7 @@  static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 
 	ret = stmpe_reg_read(stmpe_pwm->stmpe, STMPE24XX_PWMCS);
 	if (ret < 0) {
-		dev_err(chip->dev, "error reading PWM#%u control\n",
+		dev_err(stmpe_pwm->parent, "error reading PWM#%u control\n",
 			pwm->hwpwm);
 		return ret;
 	}
@@ -52,7 +53,7 @@  static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 
 	ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value);
 	if (ret) {
-		dev_err(chip->dev, "error writing PWM#%u control\n",
+		dev_err(stmpe_pwm->parent, "error writing PWM#%u control\n",
 			pwm->hwpwm);
 		return ret;
 	}
@@ -69,7 +70,7 @@  static int stmpe_24xx_pwm_disable(struct pwm_chip *chip,
 
 	ret = stmpe_reg_read(stmpe_pwm->stmpe, STMPE24XX_PWMCS);
 	if (ret < 0) {
-		dev_err(chip->dev, "error reading PWM#%u control\n",
+		dev_err(stmpe_pwm->parent, "error reading PWM#%u control\n",
 			pwm->hwpwm);
 		return ret;
 	}
@@ -78,7 +79,7 @@  static int stmpe_24xx_pwm_disable(struct pwm_chip *chip,
 
 	ret = stmpe_reg_write(stmpe_pwm->stmpe, STMPE24XX_PWMCS, value);
 	if (ret)
-		dev_err(chip->dev, "error writing PWM#%u control\n",
+		dev_err(stmpe_pwm->parent, "error writing PWM#%u control\n",
 			pwm->hwpwm);
 	return ret;
 }
@@ -124,7 +125,7 @@  static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 		ret = stmpe_set_altfunc(stmpe_pwm->stmpe, BIT(pin),
 					STMPE_BLOCK_PWM);
 		if (ret) {
-			dev_err(chip->dev, "unable to connect PWM#%u to pin\n",
+			dev_err(stmpe_pwm->parent, "unable to connect PWM#%u to pin\n",
 				pwm->hwpwm);
 			return ret;
 		}
@@ -149,7 +150,7 @@  static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 		return -ENODEV;
 	}
 
-	dev_dbg(chip->dev, "PWM#%u: config duty %d ns, period %d ns\n",
+	dev_dbg(stmpe_pwm->parent, "PWM#%u: config duty %d ns, period %d ns\n",
 		pwm->hwpwm, duty_ns, period_ns);
 
 	if (duty_ns == 0) {
@@ -215,7 +216,7 @@  static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 			program[1] = BRANCH;
 		}
 
-		dev_dbg(chip->dev,
+		dev_dbg(stmpe_pwm->parent,
 			"PWM#%u: value = %02x, last_duty = %02x, program=%04x,%04x,%04x\n",
 			pwm->hwpwm, value, last, program[0], program[1],
 			program[2]);
@@ -232,7 +233,7 @@  static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 
 		ret = stmpe_reg_write(stmpe_pwm->stmpe, offset, value);
 		if (ret) {
-			dev_err(chip->dev, "error writing register %02x: %d\n",
+			dev_err(stmpe_pwm->parent, "error writing register %02x: %d\n",
 				offset, ret);
 			return ret;
 		}
@@ -241,7 +242,7 @@  static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 
 		ret = stmpe_reg_write(stmpe_pwm->stmpe, offset, value);
 		if (ret) {
-			dev_err(chip->dev, "error writing register %02x: %d\n",
+			dev_err(stmpe_pwm->parent, "error writing register %02x: %d\n",
 				offset, ret);
 			return ret;
 		}
@@ -254,7 +255,7 @@  static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	/* Sleep for 200ms so we're sure it will take effect */
 	msleep(200);
 
-	dev_dbg(chip->dev, "programmed PWM#%u, %u bytes\n", pwm->hwpwm, i);
+	dev_dbg(stmpe_pwm->parent, "programmed PWM#%u, %u bytes\n", pwm->hwpwm, i);
 
 	return 0;
 }
@@ -312,6 +313,7 @@  static int __init stmpe_pwm_probe(struct platform_device *pdev)
 		return PTR_ERR(chip);
 	stmpe_pwm = to_stmpe_pwm(chip);
 
+	stmpe_pwm->parent = &pdev->dev;
 	stmpe_pwm->stmpe = stmpe;
 
 	chip->ops = &stmpe_24xx_pwm_ops;