From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966227AbbD2OAs (ORCPT ); Wed, 29 Apr 2015 10:00:48 -0400 Received: from mga14.intel.com ([192.55.52.115]:40820 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423169AbbD2OAl (ORCPT ); Wed, 29 Apr 2015 10:00:41 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,671,1422950400"; d="scan'208";a="717790962" From: Shobhit Kumar To: intel-gfx , linux-kernel , linux-gpio , linux-pwm , dri-devel Cc: Linus Walleij , Alexandre Courbot , Daniel Vetter , David Airlie , Samuel Ortiz , Thierry Reding , Jani Nikula , Lee Jones , Povilas Staniulis , Chih-Wei Huang , Shobhit Kumar Subject: [PATCH 2/8] drivers/pwm/core: Add support to remove registered consumer lookup tables Date: Wed, 29 Apr 2015 19:29:59 +0530 Message-Id: <1430316005-16480-3-git-send-email-shobhit.kumar@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430316005-16480-1-git-send-email-shobhit.kumar@intel.com> References: <1430316005-16480-1-git-send-email-shobhit.kumar@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case some drivers are unloading, they can remove lookup tables which they would have registered during their load time to avoid redundant entries if loaded again v2: Ccing maintainers CC: Samuel Ortiz Cc: Linus Walleij Cc: Alexandre Courbot Cc: Thierry Reding Signed-off-by: Shobhit Kumar --- drivers/pwm/core.c | 17 +++++++++++++++++ include/linux/pwm.h | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index ba34c7d..d2fe7c8d 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -586,6 +586,23 @@ void pwm_add_table(struct pwm_lookup *table, size_t num) } /** + * pwm_remove_table() - un-register PWM device consumers + * @table: array of consumers to un-register + * @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 * @con_id: consumer name diff --git a/include/linux/pwm.h b/include/linux/pwm.h index e90628c..cfe2d8d 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 -- 2.1.0