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

pwm: sl28cpld: Make use of devm_pwmchip_alloc() function

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

Reviewed-by: Michael Walle <mwalle@kernel.org>
Link: https://lore.kernel.org/r/ee687086f7fc78264fac723f65ddc96cb7518c03.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-sl28cpld.c
··· 81 81 regmap_write((priv)->regmap, (priv)->offset + (reg), (val)) 82 82 83 83 struct sl28cpld_pwm { 84 - struct pwm_chip chip; 85 84 struct regmap *regmap; 86 85 u32 offset; 87 86 }; 88 87 89 88 static inline struct sl28cpld_pwm *sl28cpld_pwm_from_chip(struct pwm_chip *chip) 90 89 { 91 - return container_of(chip, struct sl28cpld_pwm, chip); 90 + return pwmchip_get_drvdata(chip); 92 91 } 93 92 94 93 static int sl28cpld_pwm_get_state(struct pwm_chip *chip, ··· 212 213 return -ENODEV; 213 214 } 214 215 215 - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 216 - if (!priv) 217 - return -ENOMEM; 216 + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*priv)); 217 + if (IS_ERR(chip)) 218 + return PTR_ERR(chip); 219 + priv = sl28cpld_pwm_from_chip(chip); 218 220 219 221 priv->regmap = dev_get_regmap(pdev->dev.parent, NULL); 220 222 if (!priv->regmap) { ··· 231 231 } 232 232 233 233 /* Initialize the pwm_chip structure */ 234 - chip = &priv->chip; 235 - chip->dev = &pdev->dev; 236 234 chip->ops = &sl28cpld_pwm_ops; 237 - chip->npwm = 1; 238 235 239 236 ret = devm_pwmchip_add(&pdev->dev, chip); 240 237 if (ret) {