diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-14 10:32:07 +0100 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-19 11:04:12 +0100 |
commit | f988b8196322b11c9b49c8df56aa4fada8a6b96a (patch) | |
tree | 3ccc91a993b1984b26d489ea91b3c76a8072cf3e /drivers/pwm/pwm-omap-dmtimer.c | |
parent | 623a9594b2d337818b5c1d44cd2f63280c1178a7 (diff) | |
download | lwn-f988b8196322b11c9b49c8df56aa4fada8a6b96a.tar.gz lwn-f988b8196322b11c9b49c8df56aa4fada8a6b96a.zip |
pwm: omap-dmtimer: Make use of devm_pwmchip_alloc() function
This prepares the pwm-omap-dmtimer driver to further changes of the pwm
core outlined in the commit introducing devm_pwmchip_alloc(). There is
no intended semantical change and the driver should behave as before.
Link: https://lore.kernel.org/r/78d1448b0fd1136b010f629feffb9d89c853e472.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'drivers/pwm/pwm-omap-dmtimer.c')
-rw-r--r-- | drivers/pwm/pwm-omap-dmtimer.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c index 729d3be2a013..cd51c4a938f5 100644 --- a/drivers/pwm/pwm-omap-dmtimer.c +++ b/drivers/pwm/pwm-omap-dmtimer.c @@ -53,13 +53,11 @@ /** * struct pwm_omap_dmtimer_chip - Structure representing a pwm chip * corresponding to omap dmtimer. - * @chip: PWM chip structure representing PWM controller * @dm_timer: Pointer to omap dm timer. * @pdata: Pointer to omap dm timer ops. * @dm_timer_pdev: Pointer to omap dm timer platform device */ struct pwm_omap_dmtimer_chip { - struct pwm_chip chip; /* Mutex to protect pwm apply state */ struct omap_dm_timer *dm_timer; const struct omap_dm_timer_ops *pdata; @@ -69,7 +67,7 @@ struct pwm_omap_dmtimer_chip { static inline struct pwm_omap_dmtimer_chip * to_pwm_omap_dmtimer_chip(struct pwm_chip *chip) { - return container_of(chip, struct pwm_omap_dmtimer_chip, chip); + return pwmchip_get_drvdata(chip); } /** @@ -369,12 +367,12 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev) goto err_request_timer; } - omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL); - if (!omap) { - ret = -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*omap)); + if (IS_ERR(chip)) { + ret = PTR_ERR(chip); goto err_alloc_omap; } - chip = &omap->chip; + omap = to_pwm_omap_dmtimer_chip(chip); omap->pdata = pdata; omap->dm_timer = dm_timer; @@ -394,9 +392,7 @@ 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); - chip->dev = &pdev->dev; chip->ops = &pwm_omap_dmtimer_ops; - chip->npwm = 1; ret = pwmchip_add(chip); if (ret < 0) { |