Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161107AbbEEJef (ORCPT ); Tue, 5 May 2015 05:34:35 -0400 Received: from mga14.intel.com ([192.55.52.115]:11446 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030978AbbEEJe0 (ORCPT ); Tue, 5 May 2015 05:34:26 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,372,1427785200"; d="scan'208";a="690092940" 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] pwm: core: Add support to remove registered consumer lookup tables Date: Tue, 5 May 2015 15:04:18 +0530 Message-Id: <1430818458-26922-1-git-send-email-shobhit.kumar@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430316005-16480-3-git-send-email-shobhit.kumar@intel.com> References: <1430316005-16480-3-git-send-email-shobhit.kumar@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2048 Lines: 73 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 v3: Correct the subject line (Lee jones) 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/