aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2014-05-05 09:33:50 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-06 18:39:03 -0400
commita0dd7b79657bd6644b914d16ce7f23468c44a7b4 (patch)
tree471993f62816ed76d5cb7f96b32659f5bed439a6 /drivers/base/power
parent0f5c890e9b9754d9aa5bf6ae2fc00cae65780d23 (diff)
PM / OPP: Move cpufreq specific OPP functions out of generic OPP library
CPUFreq specific helper functions for OPP (Operating Performance Points) now use generic OPP functions that allow CPUFreq to be be moved back into CPUFreq framework. This allows for independent modifications or future enhancements as needed isolated to just CPUFreq framework alone. Here, we just move relevant code and documentation to make this part of CPUFreq infrastructure. Cc: Kevin Hilman <khilman@deeprootsystems.com> Signed-off-by: Nishanth Menon <nm@ti.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/power')
-rw-r--r--drivers/base/power/opp.c92
1 files changed, 0 insertions, 92 deletions
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 38b43bb20878..d9e376a6d19d 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -15,7 +15,6 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/cpufreq.h>
19#include <linux/device.h> 18#include <linux/device.h>
20#include <linux/list.h> 19#include <linux/list.h>
21#include <linux/rculist.h> 20#include <linux/rculist.h>
@@ -596,97 +595,6 @@ int dev_pm_opp_disable(struct device *dev, unsigned long freq)
596} 595}
597EXPORT_SYMBOL_GPL(dev_pm_opp_disable); 596EXPORT_SYMBOL_GPL(dev_pm_opp_disable);
598 597
599#ifdef CONFIG_CPU_FREQ
600/**
601 * dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device
602 * @dev: device for which we do this operation
603 * @table: Cpufreq table returned back to caller
604 *
605 * Generate a cpufreq table for a provided device- this assumes that the
606 * opp list is already initialized and ready for usage.
607 *
608 * This function allocates required memory for the cpufreq table. It is
609 * expected that the caller does the required maintenance such as freeing
610 * the table as required.
611 *
612 * Returns -EINVAL for bad pointers, -ENODEV if the device is not found, -ENOMEM
613 * if no memory available for the operation (table is not populated), returns 0
614 * if successful and table is populated.
615 *
616 * WARNING: It is important for the callers to ensure refreshing their copy of
617 * the table if any of the mentioned functions have been invoked in the interim.
618 *
619 * Locking: The internal device_opp and opp structures are RCU protected.
620 * Since we just use the regular accessor functions to access the internal data
621 * structures, we use RCU read lock inside this function. As a result, users of
622 * this function DONOT need to use explicit locks for invoking.
623 */
624int dev_pm_opp_init_cpufreq_table(struct device *dev,
625 struct cpufreq_frequency_table **table)
626{
627 struct dev_pm_opp *opp;
628 struct cpufreq_frequency_table *freq_table = NULL;
629 int i, max_opps, ret = 0;
630 unsigned long rate;
631
632 rcu_read_lock();
633
634 max_opps = dev_pm_opp_get_opp_count(dev);
635 if (max_opps <= 0) {
636 ret = max_opps ? max_opps : -ENODATA;
637 goto out;
638 }
639
640 freq_table = kzalloc(sizeof(*freq_table) * (max_opps + 1), GFP_KERNEL);
641 if (!freq_table) {
642 ret = -ENOMEM;
643 goto out;
644 }
645
646 for (i = 0, rate = 0; i < max_opps; i++, rate++) {
647 /* find next rate */
648 opp = dev_pm_opp_find_freq_ceil(dev, &rate);
649 if (IS_ERR(opp)) {
650 ret = PTR_ERR(opp);
651 goto out;
652 }
653 freq_table[i].driver_data = i;
654 freq_table[i].frequency = rate / 1000;
655 }
656
657 freq_table[i].driver_data = i;
658 freq_table[i].frequency = CPUFREQ_TABLE_END;
659
660 *table = &freq_table[0];
661
662out:
663 rcu_read_unlock();
664 if (ret)
665 kfree(freq_table);
666
667 return ret;
668}
669EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table);
670
671/**
672 * dev_pm_opp_free_cpufreq_table() - free the cpufreq table
673 * @dev: device for which we do this operation
674 * @table: table to free
675 *
676 * Free up the table allocated by dev_pm_opp_init_cpufreq_table
677 */
678void dev_pm_opp_free_cpufreq_table(struct device *dev,
679 struct cpufreq_frequency_table **table)
680{
681 if (!table)
682 return;
683
684 kfree(*table);
685 *table = NULL;
686}
687EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
688#endif /* CONFIG_CPU_FREQ */
689
690/** 598/**
691 * dev_pm_opp_get_notifier() - find notifier_head of the device with opp 599 * dev_pm_opp_get_notifier() - find notifier_head of the device with opp
692 * @dev: device pointer used to lookup device OPPs. 600 * @dev: device pointer used to lookup device OPPs.