[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-3.0 / pm-wip / cpufreq / 0001-PM-OPP-introduce-function-to-free-cpufreq-table.patch
1 From 90787bd0d3828d29cf41137d61409afcbb7e3cef Mon Sep 17 00:00:00 2001
2 From: Nishanth Menon <nm@ti.com>
3 Date: Wed, 25 May 2011 00:43:26 -0700
4 Subject: [PATCH 01/19] PM: OPP: introduce function to free cpufreq table
6 cpufreq table allocated by opp_init_cpufreq_table is better
7 freed by OPP layer itself. This allows future modifications to
8 the table handling to be transparent to the users.
10 Signed-off-by: Nishanth Menon <nm@ti.com>
11 Acked-by: Kevin Hilman <khilman@ti.com>
12 ---
13 Documentation/power/opp.txt | 2 ++
14 drivers/base/power/opp.c | 17 +++++++++++++++++
15 include/linux/opp.h | 8 ++++++++
16 3 files changed, 27 insertions(+), 0 deletions(-)
18 diff --git a/Documentation/power/opp.txt b/Documentation/power/opp.txt
19 index 5ae70a1..3035d00 100644
20 --- a/Documentation/power/opp.txt
21 +++ b/Documentation/power/opp.txt
22 @@ -321,6 +321,8 @@ opp_init_cpufreq_table - cpufreq framework typically is initialized with
23 addition to CONFIG_PM as power management feature is required to
24 dynamically scale voltage and frequency in a system.
26 +opp_free_cpufreq_table - Free up the table allocated by opp_init_cpufreq_table
27 +
28 7. Data Structures
29 ==================
30 Typically an SoC contains multiple voltage domains which are variable. Each
31 diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
32 index 56a6899..5cc1232 100644
33 --- a/drivers/base/power/opp.c
34 +++ b/drivers/base/power/opp.c
35 @@ -625,4 +625,21 @@ int opp_init_cpufreq_table(struct device *dev,
37 return 0;
38 }
39 +
40 +/**
41 + * opp_free_cpufreq_table() - free the cpufreq table
42 + * @dev: device for which we do this operation
43 + * @table: table to free
44 + *
45 + * Free up the table allocated by opp_init_cpufreq_table
46 + */
47 +void opp_free_cpufreq_table(struct device *dev,
48 + struct cpufreq_frequency_table **table)
49 +{
50 + if (!table)
51 + return;
52 +
53 + kfree(*table);
54 + *table = NULL;
55 +}
56 #endif /* CONFIG_CPU_FREQ */
57 diff --git a/include/linux/opp.h b/include/linux/opp.h
58 index 5449945..7020e97 100644
59 --- a/include/linux/opp.h
60 +++ b/include/linux/opp.h
61 @@ -94,12 +94,20 @@ static inline int opp_disable(struct device *dev, unsigned long freq)
62 #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
63 int opp_init_cpufreq_table(struct device *dev,
64 struct cpufreq_frequency_table **table);
65 +void opp_free_cpufreq_table(struct device *dev,
66 + struct cpufreq_frequency_table **table);
67 #else
68 static inline int opp_init_cpufreq_table(struct device *dev,
69 struct cpufreq_frequency_table **table)
70 {
71 return -EINVAL;
72 }
73 +
74 +static inline
75 +void opp_free_cpufreq_table(struct device *dev,
76 + struct cpufreq_frequency_table **table)
77 +{
78 +}
79 #endif /* CONFIG_CPU_FREQ */
81 #endif /* __LINUX_OPP_H__ */
82 --
83 1.6.6.1