diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-14 10:32:48 +0100 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-22 14:39:25 +0100 |
commit | 5d481e0742dde0d94e3facc39a243ed50c6ce948 (patch) | |
tree | 968c0b09be3e582e4a87616e2770f3c365046424 /drivers/pwm/pwm-stm32-lp.c | |
parent | 0e89637a4fb9010cd3f96ddff2f9e466e87fac8e (diff) |
pwm: stm32-lp: Make use of devm_pwmchip_alloc() function
This prepares the pwm-stm32-lp 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/04af7b3d00bc932dd025200a3bf74527c29ca47a.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-stm32-lp.c')
-rw-r--r-- | drivers/pwm/pwm-stm32-lp.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c index 958043bc5c92..989731256f50 100644 --- a/drivers/pwm/pwm-stm32-lp.c +++ b/drivers/pwm/pwm-stm32-lp.c @@ -18,14 +18,13 @@ #include <linux/pwm.h> struct stm32_pwm_lp { - struct pwm_chip chip; struct clk *clk; struct regmap *regmap; }; static inline struct stm32_pwm_lp *to_stm32_pwm_lp(struct pwm_chip *chip) { - return container_of(chip, struct stm32_pwm_lp, chip); + return pwmchip_get_drvdata(chip); } /* STM32 Low-Power Timer is preceded by a configurable power-of-2 prescaler */ @@ -200,16 +199,14 @@ static int stm32_pwm_lp_probe(struct platform_device *pdev) struct pwm_chip *chip; int ret; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*priv)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + priv = to_stm32_pwm_lp(chip); priv->regmap = ddata->regmap; priv->clk = ddata->clk; - chip = &priv->chip; - chip->dev = &pdev->dev; chip->ops = &stm32_pwm_lp_ops; - chip->npwm = 1; ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) |