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

pwm: samsung: Make use of devm_pwmchip_alloc() function

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

+5 -9
+5 -9
drivers/pwm/pwm-samsung.c
··· 69 69 70 70 /** 71 71 * struct samsung_pwm_chip - private data of PWM chip 72 - * @chip: generic PWM chip 73 72 * @variant: local copy of hardware variant data 74 73 * @inverter_mask: inverter status for all channels - one bit per channel 75 74 * @disabled_mask: disabled status for all channels - one bit per channel ··· 79 80 * @channel: per channel driver data 80 81 */ 81 82 struct samsung_pwm_chip { 82 - struct pwm_chip chip; 83 83 struct samsung_pwm_variant variant; 84 84 u8 inverter_mask; 85 85 u8 disabled_mask; ··· 108 110 static inline 109 111 struct samsung_pwm_chip *to_samsung_pwm_chip(struct pwm_chip *chip) 110 112 { 111 - return container_of(chip, struct samsung_pwm_chip, chip); 113 + return pwmchip_get_drvdata(chip); 112 114 } 113 115 114 116 static inline unsigned int to_tcon_channel(unsigned int channel) ··· 547 549 unsigned int chan; 548 550 int ret; 549 551 550 - our_chip = devm_kzalloc(&pdev->dev, sizeof(*our_chip), GFP_KERNEL); 551 - if (our_chip == NULL) 552 - return -ENOMEM; 552 + chip = devm_pwmchip_alloc(&pdev->dev, SAMSUNG_PWM_NUM, sizeof(*our_chip)); 553 + if (IS_ERR(chip)) 554 + return PTR_ERR(chip); 555 + our_chip = to_samsung_pwm_chip(chip); 553 556 554 - chip = &our_chip->chip; 555 - chip->dev = &pdev->dev; 556 557 chip->ops = &pwm_samsung_ops; 557 - chip->npwm = SAMSUNG_PWM_NUM; 558 558 our_chip->inverter_mask = BIT(SAMSUNG_PWM_NUM) - 1; 559 559 560 560 if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {