From: Shobhit Kumar Date: Tue, 5 May 2015 09:34:18 +0000 (+0530) Subject: pwm: Add support to remove registered consumer lookup tables X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=efb0de55b6a2ec15fc424e660601f22ae2fa487a;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git pwm: Add support to remove registered consumer lookup tables In case some drivers are unloading, they can remove lookup tables which they had registered during their load time to avoid redundant entries if loaded again. CC: Samuel Ortiz Cc: Linus Walleij Cc: Alexandre Courbot Cc: Thierry Reding Signed-off-by: Shobhit Kumar Signed-off-by: Thierry Reding --- diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index ba34c7d89042..27cd58d16881 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -585,6 +585,23 @@ void pwm_add_table(struct pwm_lookup *table, size_t num) mutex_unlock(&pwm_lookup_lock); } +/** + * pwm_remove_table() - unregister PWM device consumers + * @table: array of consumers to unregister + * @num: number of consumers in table + */ +void pwm_remove_table(struct pwm_lookup *table, size_t num) +{ + mutex_lock(&pwm_lookup_lock); + + while (num--) { + list_del(&table->list); + table++; + } + + mutex_unlock(&pwm_lookup_lock); +} + /** * pwm_get() - look up and request a PWM device * @dev: device for PWM consumer diff --git a/include/linux/pwm.h b/include/linux/pwm.h index e90628cac8fa..cfe2d8df5be0 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -290,10 +290,15 @@ struct pwm_lookup { #if IS_ENABLED(CONFIG_PWM) void pwm_add_table(struct pwm_lookup *table, size_t num); +void pwm_remove_table(struct pwm_lookup *table, size_t num); #else static inline void pwm_add_table(struct pwm_lookup *table, size_t num) { } + +static inline void pwm_remove_table(struct pwm_lookup *table, size_t num) +{ +} #endif #ifdef CONFIG_PWM_SYSFS