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

pwm: vt8500: Make use of devm_pwmchip_alloc() function

This prepares the pwm-vt8500 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.

Also convert the to_vt8500_chip() helper macro to a static inline to
get some type safety.

Link: https://lore.kernel.org/r/b203c4448db23ebad1165b7bce43ac41468c4e89.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

+8 -8
+8 -8
drivers/pwm/pwm-vt8500.c
··· 45 45 #define STATUS_ALL_UPDATE 0x0F 46 46 47 47 struct vt8500_chip { 48 - struct pwm_chip chip; 49 48 void __iomem *base; 50 49 struct clk *clk; 51 50 }; 52 51 53 - #define to_vt8500_chip(chip) container_of(chip, struct vt8500_chip, chip) 52 + static inline struct vt8500_chip *to_vt8500_chip(struct pwm_chip *chip) 53 + { 54 + return pwmchip_get_drvdata(chip); 55 + } 54 56 55 57 #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) 56 58 static inline void vt8500_pwm_busy_wait(struct pwm_chip *chip, int nr, u8 bitmask) ··· 242 240 if (!np) 243 241 return dev_err_probe(&pdev->dev, -EINVAL, "invalid devicetree node\n"); 244 242 245 - vt8500 = devm_kzalloc(&pdev->dev, sizeof(*vt8500), GFP_KERNEL); 246 - if (vt8500 == NULL) 247 - return -ENOMEM; 243 + chip = devm_pwmchip_alloc(&pdev->dev, VT8500_NR_PWMS, sizeof(*vt8500)); 244 + if (IS_ERR(chip)) 245 + return PTR_ERR(chip); 246 + vt8500 = to_vt8500_chip(chip); 248 247 249 - chip = &vt8500->chip; 250 - chip->dev = &pdev->dev; 251 248 chip->ops = &vt8500_pwm_ops; 252 - chip->npwm = VT8500_NR_PWMS; 253 249 254 250 vt8500->clk = devm_clk_get_prepared(&pdev->dev, NULL); 255 251 if (IS_ERR(vt8500->clk))