diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-14 12:31:33 +0300 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-19 13:04:09 +0300 |
commit | 12ca0c331a5f4d2f412c02f7a5a498e58f8b225f (patch) | |
tree | a5bae63b4c4de311f6c64a88f35a8c8f56f13527 | |
parent | b097d28e3319d059173a3b44b4438dd033a23c56 (diff) | |
download | linux-12ca0c331a5f4d2f412c02f7a5a498e58f8b225f.tar.xz |
pwm: img: Make use of devm_pwmchip_alloc() function
This prepares the pwm-img 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/d99e00af2ff09cd3587d9a7c51dc8e0e13f85208.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-rw-r--r-- | drivers/pwm/pwm-img.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c index e99d5bc979c2..d79a96679a26 100644 --- a/drivers/pwm/pwm-img.c +++ b/drivers/pwm/pwm-img.c @@ -59,7 +59,6 @@ struct img_pwm_soc_data { }; struct img_pwm_chip { - struct pwm_chip chip; struct clk *pwm_clk; struct clk *sys_clk; void __iomem *base; @@ -73,7 +72,7 @@ struct img_pwm_chip { static inline struct img_pwm_chip *to_img_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct img_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static inline void img_pwm_writel(struct img_pwm_chip *imgchip, @@ -263,10 +262,10 @@ static int img_pwm_probe(struct platform_device *pdev) struct pwm_chip *chip; struct img_pwm_chip *imgchip; - imgchip = devm_kzalloc(&pdev->dev, sizeof(*imgchip), GFP_KERNEL); - if (!imgchip) - return -ENOMEM; - chip = &imgchip->chip; + chip = devm_pwmchip_alloc(&pdev->dev, IMG_PWM_NPWM, sizeof(*imgchip)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + imgchip = to_img_pwm_chip(chip); imgchip->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(imgchip->base)) @@ -318,9 +317,7 @@ static int img_pwm_probe(struct platform_device *pdev) do_div(val, clk_rate); imgchip->min_period_ns = val; - chip->dev = &pdev->dev; chip->ops = &img_pwm_ops; - chip->npwm = IMG_PWM_NPWM; ret = pwmchip_add(chip); if (ret < 0) { |