Skip to content

Commit

Permalink
PM / OPP: Introduce function to free cpufreq table
Browse files Browse the repository at this point in the history
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 <nm@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Nishanth Menon authored and Rafael J. Wysocki committed Jul 15, 2011
1 parent 3110df8 commit 99f381d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Documentation/power/opp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions drivers/base/power/opp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
8 changes: 8 additions & 0 deletions include/linux/opp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */

0 comments on commit 99f381d

Please sign in to comment.