Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pwm: berlin: Make use of devm_pwmchip_alloc() function

This prepares the pwm-berlin 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/52866502c96a80d1c30be003dc1f5a89a4d230cc.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

+5 -8
+5 -8
drivers/pwm/pwm-berlin.c
··· 49 49 }; 50 50 51 51 struct berlin_pwm_chip { 52 - struct pwm_chip chip; 53 52 struct clk *clk; 54 53 void __iomem *base; 55 54 struct berlin_pwm_channel channel[BERLIN_PWM_NUMPWMS]; ··· 56 57 57 58 static inline struct berlin_pwm_chip *to_berlin_pwm_chip(struct pwm_chip *chip) 58 59 { 59 - return container_of(chip, struct berlin_pwm_chip, chip); 60 + return pwmchip_get_drvdata(chip); 60 61 } 61 62 62 63 static inline u32 berlin_pwm_readl(struct berlin_pwm_chip *bpc, ··· 201 202 struct berlin_pwm_chip *bpc; 202 203 int ret; 203 204 204 - bpc = devm_kzalloc(&pdev->dev, sizeof(*bpc), GFP_KERNEL); 205 - if (!bpc) 206 - return -ENOMEM; 205 + chip = devm_pwmchip_alloc(&pdev->dev, BERLIN_PWM_NUMPWMS, sizeof(*bpc)); 206 + if (IS_ERR(chip)) 207 + return PTR_ERR(chip); 208 + bpc = to_berlin_pwm_chip(chip); 207 209 208 210 bpc->base = devm_platform_ioremap_resource(pdev, 0); 209 211 if (IS_ERR(bpc->base)) ··· 214 214 if (IS_ERR(bpc->clk)) 215 215 return PTR_ERR(bpc->clk); 216 216 217 - chip = &bpc->chip; 218 - chip->dev = &pdev->dev; 219 217 chip->ops = &berlin_pwm_ops; 220 - chip->npwm = BERLIN_PWM_NUMPWMS; 221 218 222 219 ret = devm_pwmchip_add(&pdev->dev, chip); 223 220 if (ret < 0)