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

pwm: sifive: Make use of devm_pwmchip_alloc() function

This prepares the pwm-sifive 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/30a4cacafe2c323f2531dd1c1126f0bf0fe5e03c.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-sifive.c
··· 41 41 #define PWM_SIFIVE_DEFAULT_PERIOD 10000000 42 42 43 43 struct pwm_sifive_ddata { 44 - struct pwm_chip chip; 45 44 struct device *parent; 46 45 struct mutex lock; /* lock to protect user_count and approx_period */ 47 46 struct notifier_block notifier; ··· 54 55 static inline 55 56 struct pwm_sifive_ddata *pwm_sifive_chip_to_ddata(struct pwm_chip *chip) 56 57 { 57 - return container_of(chip, struct pwm_sifive_ddata, chip); 58 + return pwmchip_get_drvdata(chip); 58 59 } 59 60 60 61 static int pwm_sifive_request(struct pwm_chip *chip, struct pwm_device *pwm) ··· 230 231 u32 val; 231 232 unsigned int enabled_pwms = 0, enabled_clks = 1; 232 233 233 - ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); 234 - if (!ddata) 235 - return -ENOMEM; 234 + chip = devm_pwmchip_alloc(dev, 4, sizeof(*ddata)); 235 + if (IS_ERR(chip)) 236 + return PTR_ERR(chip); 236 237 238 + ddata = pwm_sifive_chip_to_ddata(chip); 239 + ddata->parent = dev; 237 240 mutex_init(&ddata->lock); 238 - chip = &ddata->chip; 239 - chip->dev = ddata->parent = dev; 240 241 chip->ops = &pwm_sifive_ops; 241 - chip->npwm = 4; 242 242 243 243 ddata->regs = devm_platform_ioremap_resource(pdev, 0); 244 244 if (IS_ERR(ddata->regs))