]> Git Repo - J-linux.git/commitdiff
pwm: stm32-lp: Prepare removing pwm_chip from driver data
authorUwe Kleine-König <[email protected]>
Wed, 14 Feb 2024 09:32:46 +0000 (10:32 +0100)
committerUwe Kleine-König <[email protected]>
Thu, 22 Feb 2024 13:39:24 +0000 (14:39 +0100)
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.de
Signed-off-by: Uwe Kleine-König <[email protected]>
drivers/pwm/pwm-stm32-lp.c

index bbab6be314a823d451c5e935c6635178be73a574..b46d8193dd0f4708d979831f91682f9c69776ce5 100644 (file)
@@ -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_pwm_lp *priv;
+       struct pwm_chip *chip;
        int ret;
 
        priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -205,28 +206,29 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev)
 
        priv->regmap = ddata->regmap;
        priv->clk = ddata->clk;
-       priv->chip.dev = &pdev->dev;
-       priv->chip.ops = &stm32_pwm_lp_ops;
-       priv->chip.npwm = 1;
+       chip = &priv->chip;
+       chip->dev = &pdev->dev;
+       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)
                return ret;
 
-       platform_set_drvdata(pdev, priv);
+       platform_set_drvdata(pdev, chip);
 
        return 0;
 }
 
 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;
 
-       pwm_get_state(&priv->chip.pwms[0], &state);
+       pwm_get_state(&chip->pwms[0], &state);
        if (state.enabled) {
                dev_err(dev, "The consumer didn't stop us (%s)\n",
-                       priv->chip.pwms[0].label);
+                       chip->pwms[0].label);
                return -EBUSY;
        }
 
This page took 0.049843 seconds and 4 git commands to generate.