pwm: omap-dmtimer: Prepare removing pwm_chip from driver data
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 14 Feb 2024 09:32:06 +0000 (10:32 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 19 Feb 2024 10:04:12 +0000 (11:04 +0100)
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct pwm_omap_dmtimer_chip. Use the pwm_chip as
driver data instead of the pwm_omap_dmtimer_chip to get access to the
pwm_chip in pwm_omap_dmtimer_remove() without using omap->chip.

Link: https://lore.kernel.org/r/809672026f3d583ba4fc4bd92b525951df172106.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
drivers/pwm/pwm-omap-dmtimer.c

index 527a7aa0ce613c7ce0fcc7fecf1345e49b64207b..729d3be2a0134729c4c9c06a688b54eb35fae5ef 100644 (file)
@@ -311,6 +311,7 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
        struct dmtimer_platform_data *timer_pdata;
        const struct omap_dm_timer_ops *pdata;
        struct platform_device *timer_pdev;
+       struct pwm_chip *chip;
        struct pwm_omap_dmtimer_chip *omap;
        struct omap_dm_timer *dm_timer;
        struct device_node *timer;
@@ -373,6 +374,7 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
                ret = -ENOMEM;
                goto err_alloc_omap;
        }
+       chip = &omap->chip;
 
        omap->pdata = pdata;
        omap->dm_timer = dm_timer;
@@ -392,11 +394,11 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
        if (!of_property_read_u32(pdev->dev.of_node, "ti,clock-source", &v))
                omap->pdata->set_source(omap->dm_timer, v);
 
-       omap->chip.dev = &pdev->dev;
-       omap->chip.ops = &pwm_omap_dmtimer_ops;
-       omap->chip.npwm = 1;
+       chip->dev = &pdev->dev;
+       chip->ops = &pwm_omap_dmtimer_ops;
+       chip->npwm = 1;
 
-       ret = pwmchip_add(&omap->chip);
+       ret = pwmchip_add(chip);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed to register PWM\n");
                goto err_pwmchip_add;
@@ -404,7 +406,7 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 
        of_node_put(timer);
 
-       platform_set_drvdata(pdev, omap);
+       platform_set_drvdata(pdev, chip);
 
        return 0;
 
@@ -432,9 +434,10 @@ err_find_timer_pdev:
 
 static void pwm_omap_dmtimer_remove(struct platform_device *pdev)
 {
-       struct pwm_omap_dmtimer_chip *omap = platform_get_drvdata(pdev);
+       struct pwm_chip *chip = platform_get_drvdata(pdev);
+       struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip);
 
-       pwmchip_remove(&omap->chip);
+       pwmchip_remove(chip);
 
        if (pm_runtime_active(&omap->dm_timer_pdev->dev))
                omap->pdata->stop(omap->dm_timer);