]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
pwm: Add support to remove registered consumer lookup tables
authorShobhit Kumar <shobhit.kumar@intel.com>
Tue, 5 May 2015 09:34:18 +0000 (15:04 +0530)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 6 May 2015 12:19:35 +0000 (14:19 +0200)
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 <sameo@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/core.c
include/linux/pwm.h

index ba34c7d8904232de070b78d4565377c1fab75740..27cd58d16881265e61e6a1c73f15789189040f23 100644 (file)
@@ -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
index e90628cac8fae57e8a88ecd9f93d2a2f1342b9d5..cfe2d8df5be062ee6d63a60f36e6a5ba84356fad 100644 (file)
@@ -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