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

pwm: Add a device-managed function to add PWM chips

This potentially simplifies low-level PWM drivers.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>

authored by

Uwe Kleine-König and committed by
Thierry Reding
bcda91bf d233504a

+22
+19
drivers/pwm/core.c
··· 335 335 } 336 336 EXPORT_SYMBOL_GPL(pwmchip_remove); 337 337 338 + static void devm_pwmchip_remove(void *data) 339 + { 340 + struct pwm_chip *chip = data; 341 + 342 + pwmchip_remove(chip); 343 + } 344 + 345 + int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip) 346 + { 347 + int ret; 348 + 349 + ret = pwmchip_add(chip); 350 + if (ret) 351 + return ret; 352 + 353 + return devm_add_action_or_reset(dev, devm_pwmchip_remove, chip); 354 + } 355 + EXPORT_SYMBOL_GPL(devm_pwmchip_add); 356 + 338 357 /** 339 358 * pwm_request() - request a PWM device 340 359 * @pwm: global PWM device index
+3
include/linux/pwm.h
··· 405 405 406 406 int pwmchip_add(struct pwm_chip *chip); 407 407 int pwmchip_remove(struct pwm_chip *chip); 408 + 409 + int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip); 410 + 408 411 struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, 409 412 unsigned int index, 410 413 const char *label);