diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2021-04-07 10:01:54 +0200 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2021-06-28 13:17:48 +0200 |
commit | bcda91bf86c1ff7647df85029d69f2aed80f210e (patch) | |
tree | f8a137e253d0c4afbfde04f3044c2073b892fe2b /drivers/pwm | |
parent | d233504af7db9f4ddbbc4b04513d5ca657e7ae1f (diff) |
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>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/core.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index a42999f877d2..83db178f16bb 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -335,6 +335,25 @@ out: } EXPORT_SYMBOL_GPL(pwmchip_remove); +static void devm_pwmchip_remove(void *data) +{ + struct pwm_chip *chip = data; + + pwmchip_remove(chip); +} + +int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip) +{ + int ret; + + ret = pwmchip_add(chip); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, devm_pwmchip_remove, chip); +} +EXPORT_SYMBOL_GPL(devm_pwmchip_add); + /** * pwm_request() - request a PWM device * @pwm: global PWM device index |