From 15527ec2527b50f653f734d329d9f78d6a0081db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Wed, 14 Feb 2024 10:31:45 +0100 Subject: [PATCH] pwm: keembay: Make use of devm_pwmchip_alloc() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prepares the pwm-keembay 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/f65c27bf0a1f9ba4e5dbb115ff628860163ff8e0.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-keembay.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-keembay.c b/drivers/pwm/pwm-keembay.c index ac824ecc3f64..35b641f3f6ed 100644 --- a/drivers/pwm/pwm-keembay.c +++ b/drivers/pwm/pwm-keembay.c @@ -36,7 +36,6 @@ #define KMB_PWM_HIGHLOW_OFFSET(ch) (0x20 + 4 * (ch)) struct keembay_pwm { - struct pwm_chip chip; struct device *dev; struct clk *clk; void __iomem *base; @@ -44,7 +43,7 @@ struct keembay_pwm { static inline struct keembay_pwm *to_keembay_pwm_dev(struct pwm_chip *chip) { - return container_of(chip, struct keembay_pwm, chip); + return pwmchip_get_drvdata(chip); } static void keembay_clk_unprepare(void *data) @@ -185,12 +184,14 @@ static const struct pwm_ops keembay_pwm_ops = { static int keembay_pwm_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct pwm_chip *chip; struct keembay_pwm *priv; int ret; - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; + chip = devm_pwmchip_alloc(dev, KMB_TOTAL_PWM_CHANNELS, sizeof(*priv)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + priv = to_keembay_pwm_dev(chip); priv->clk = devm_clk_get(dev, NULL); if (IS_ERR(priv->clk)) @@ -204,11 +205,9 @@ static int keembay_pwm_probe(struct platform_device *pdev) if (ret) return ret; - priv->chip.dev = dev; - priv->chip.ops = &keembay_pwm_ops; - priv->chip.npwm = KMB_TOTAL_PWM_CHANNELS; + chip->ops = &keembay_pwm_ops; - ret = devm_pwmchip_add(dev, &priv->chip); + ret = devm_pwmchip_add(dev, chip); if (ret) return dev_err_probe(dev, ret, "Failed to add PWM chip\n");