diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-14 10:32:16 +0100 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2024-02-19 11:04:13 +0100 |
commit | f0d907605d421a36af3e8a6274b2a560557e0db6 (patch) | |
tree | da23c3b54b03bc46e9a61c2879337f5417c8d1f3 /drivers/pwm/pwm-rcar.c | |
parent | pwm: rcar: Prepare removing pwm_chip from driver data (diff) | |
download | linux-f0d907605d421a36af3e8a6274b2a560557e0db6.tar.xz linux-f0d907605d421a36af3e8a6274b2a560557e0db6.zip |
pwm: rcar: Make use of devm_pwmchip_alloc() function
This prepares the pwm-rcar 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/a37a167364366b6cbe2dd299dce02731706213b2.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to '')
-rw-r--r-- | drivers/pwm/pwm-rcar.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c index 1dfcc74efcfd..4cfecd88ede0 100644 --- a/drivers/pwm/pwm-rcar.c +++ b/drivers/pwm/pwm-rcar.c @@ -38,14 +38,13 @@ #define RCAR_PWMCNT_PH0_SHIFT 0 struct rcar_pwm_chip { - struct pwm_chip chip; void __iomem *base; struct clk *clk; }; static inline struct rcar_pwm_chip *to_rcar_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct rcar_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static void rcar_pwm_write(struct rcar_pwm_chip *rp, u32 data, @@ -206,9 +205,10 @@ static int rcar_pwm_probe(struct platform_device *pdev) struct rcar_pwm_chip *rcar_pwm; int ret; - rcar_pwm = devm_kzalloc(&pdev->dev, sizeof(*rcar_pwm), GFP_KERNEL); - if (rcar_pwm == NULL) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*rcar_pwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + rcar_pwm = to_rcar_pwm_chip(chip); rcar_pwm->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rcar_pwm->base)) @@ -220,10 +220,7 @@ static int rcar_pwm_probe(struct platform_device *pdev) return PTR_ERR(rcar_pwm->clk); } - chip = &rcar_pwm->chip; - chip->dev = &pdev->dev; chip->ops = &rcar_pwm_ops; - chip->npwm = 1; platform_set_drvdata(pdev, chip); |