Commit 8f5e2dcb authored by Uwe Kleine-König's avatar Uwe Kleine-König

pwm: stm32-lp: Prepare removing pwm_chip from driver data

This prepares the driver for further changes that will drop struct
pwm_chip chip from struct stm32_pwm_lp. Use the pwm_chip as driver
data instead of the stm32_pwm_lp to get access to the pwm_chip in
stm32_pwm_lp_suspend() without using priv->chip.

Link: https://lore.kernel.org/r/df47d1aff9b529c9a4762b6ba339a18cecba1497.1707900770.git.u.kleine-koenig@pengutronix.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 3e4224a9
...@@ -197,6 +197,7 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev) ...@@ -197,6 +197,7 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev)
{ {
struct stm32_lptimer *ddata = dev_get_drvdata(pdev->dev.parent); struct stm32_lptimer *ddata = dev_get_drvdata(pdev->dev.parent);
struct stm32_pwm_lp *priv; struct stm32_pwm_lp *priv;
struct pwm_chip *chip;
int ret; int ret;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
...@@ -205,28 +206,29 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev) ...@@ -205,28 +206,29 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev)
priv->regmap = ddata->regmap; priv->regmap = ddata->regmap;
priv->clk = ddata->clk; priv->clk = ddata->clk;
priv->chip.dev = &pdev->dev; chip = &priv->chip;
priv->chip.ops = &stm32_pwm_lp_ops; chip->dev = &pdev->dev;
priv->chip.npwm = 1; chip->ops = &stm32_pwm_lp_ops;
chip->npwm = 1;
ret = devm_pwmchip_add(&pdev->dev, &priv->chip); ret = devm_pwmchip_add(&pdev->dev, chip);
if (ret < 0) if (ret < 0)
return ret; return ret;
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, chip);
return 0; return 0;
} }
static int stm32_pwm_lp_suspend(struct device *dev) static int stm32_pwm_lp_suspend(struct device *dev)
{ {
struct stm32_pwm_lp *priv = dev_get_drvdata(dev); struct pwm_chip *chip = dev_get_drvdata(dev);
struct pwm_state state; struct pwm_state state;
pwm_get_state(&priv->chip.pwms[0], &state); pwm_get_state(&chip->pwms[0], &state);
if (state.enabled) { if (state.enabled) {
dev_err(dev, "The consumer didn't stop us (%s)\n", dev_err(dev, "The consumer didn't stop us (%s)\n",
priv->chip.pwms[0].label); chip->pwms[0].label);
return -EBUSY; return -EBUSY;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment