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

pwm: ab8500: Make use of devm_pwmchip_alloc() function

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

+6 -8
+6 -8
drivers/pwm/pwm-ab8500.c
··· 24 24 #define AB8500_PWM_CLKRATE 9600000 25 25 26 26 struct ab8500_pwm_chip { 27 - struct pwm_chip chip; 28 27 unsigned int hwid; 29 28 }; 30 29 31 30 static struct ab8500_pwm_chip *ab8500_pwm_from_chip(struct pwm_chip *chip) 32 31 { 33 - return container_of(chip, struct ab8500_pwm_chip, chip); 32 + return pwmchip_get_drvdata(chip); 34 33 } 35 34 36 35 static int ab8500_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ··· 195 196 * Nothing to be done in probe, this is required to get the 196 197 * device which is required for ab8500 read and write 197 198 */ 198 - ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL); 199 - if (ab8500 == NULL) 200 - return -ENOMEM; 199 + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*ab8500)); 200 + if (IS_ERR(chip)) 201 + return PTR_ERR(chip); 201 202 202 - chip = &ab8500->chip; 203 - chip->dev = &pdev->dev; 203 + ab8500 = ab8500_pwm_from_chip(chip); 204 + 204 205 chip->ops = &ab8500_pwm_ops; 205 - chip->npwm = 1; 206 206 ab8500->hwid = pdev->id - 1; 207 207 208 208 err = devm_pwmchip_add(&pdev->dev, chip);