From patchwork Wed May 25 07:43:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 815182 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4P7hZ94027041 for ; Wed, 25 May 2011 07:43:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755913Ab1EYHnd (ORCPT ); Wed, 25 May 2011 03:43:33 -0400 Received: from na3sys009aog104.obsmtp.com ([74.125.149.73]:53813 "EHLO na3sys009aog104.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755235Ab1EYHnc (ORCPT ); Wed, 25 May 2011 03:43:32 -0400 Received: from mail-px0-f175.google.com ([209.85.212.175]) (using TLSv1) by na3sys009aob104.postini.com ([74.125.148.12]) with SMTP ID DSNKTdyzJMmU4LtKlQ8ZEzyi7yKaZ+ds0dI4@postini.com; Wed, 25 May 2011 00:43:32 PDT Received: by mail-px0-f175.google.com with SMTP id 17so4995157pxi.20 for ; Wed, 25 May 2011 00:43:32 -0700 (PDT) Received: by 10.68.66.69 with SMTP id d5mr3303320pbt.387.1306309412090; Wed, 25 May 2011 00:43:32 -0700 (PDT) Received: from localhost (h-66-166-73-10.snvacaid.static.covad.net [66.166.73.10]) by mx.google.com with ESMTPS id u10sm5521264pbt.69.2011.05.25.00.43.29 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 00:43:30 -0700 (PDT) From: Nishanth Menon To: linux-pm Cc: Todd , Rafael , linux-omap , Nishanth Menon Subject: [PATCH V2] PM: OPP: introduce function to free cpufreq table Date: Wed, 25 May 2011 00:43:26 -0700 Message-Id: <1306309406-3299-1-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <[PATCH] PM: OPP: introduce function to free cpufreq table> References: <[PATCH] PM: OPP: introduce function to free cpufreq table> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 25 May 2011 07:43:36 +0000 (UTC) cpufreq table allocated by opp_init_cpufreq_table is better freed by OPP layer itself. This allows future modifications to the table handling to be transparent to the users. Signed-off-by: Nishanth Menon Acked-by: Kevin Hilman --- V2: removed lock of free. V1: http://marc.info/?t=130619241700001&r=1&w=2 Example discussion: http://marc.info/?t=130570440600005&r=1&w=2 Documentation/power/opp.txt | 2 ++ drivers/base/power/opp.c | 17 +++++++++++++++++ include/linux/opp.h | 8 ++++++++ 3 files changed, 27 insertions(+), 0 deletions(-) diff --git a/Documentation/power/opp.txt b/Documentation/power/opp.txt index 5ae70a1..3035d00 100644 --- a/Documentation/power/opp.txt +++ b/Documentation/power/opp.txt @@ -321,6 +321,8 @@ opp_init_cpufreq_table - cpufreq framework typically is initialized with addition to CONFIG_PM as power management feature is required to dynamically scale voltage and frequency in a system. +opp_free_cpufreq_table - Free up the table allocated by opp_init_cpufreq_table + 7. Data Structures ================== Typically an SoC contains multiple voltage domains which are variable. Each diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 56a6899..5cc1232 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -625,4 +625,21 @@ int opp_init_cpufreq_table(struct device *dev, return 0; } + +/** + * opp_free_cpufreq_table() - free the cpufreq table + * @dev: device for which we do this operation + * @table: table to free + * + * Free up the table allocated by opp_init_cpufreq_table + */ +void opp_free_cpufreq_table(struct device *dev, + struct cpufreq_frequency_table **table) +{ + if (!table) + return; + + kfree(*table); + *table = NULL; +} #endif /* CONFIG_CPU_FREQ */ diff --git a/include/linux/opp.h b/include/linux/opp.h index 5449945..7020e97 100644 --- a/include/linux/opp.h +++ b/include/linux/opp.h @@ -94,12 +94,20 @@ static inline int opp_disable(struct device *dev, unsigned long freq) #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) int opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table); +void opp_free_cpufreq_table(struct device *dev, + struct cpufreq_frequency_table **table); #else static inline int opp_init_cpufreq_table(struct device *dev, struct cpufreq_frequency_table **table) { return -EINVAL; } + +static inline +void opp_free_cpufreq_table(struct device *dev, + struct cpufreq_frequency_table **table) +{ +} #endif /* CONFIG_CPU_FREQ */ #endif /* __LINUX_OPP_H__ */