diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-05-08 07:06:38 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-05-08 07:06:38 -0400 |
commit | 37c147948742d34bdc3d9b491f99c77fc48daac0 (patch) | |
tree | c2481b8485e5c47af10114a97ebf5ade616ee285 /drivers/base | |
parent | 89ca3b881987f5a4be4c5dbaa7f0df12bbdde2fd (diff) | |
parent | a0dd7b79657bd6644b914d16ce7f23468c44a7b4 (diff) |
Merge back earlier 'pm-cpufreq' material.
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/power/opp.c | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 25538675d59e..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,96 +595,6 @@ int dev_pm_opp_disable(struct device *dev, unsigned long freq) | |||
596 | } | 595 | } |
597 | EXPORT_SYMBOL_GPL(dev_pm_opp_disable); | 596 | EXPORT_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 | * To simplify the logic, we pretend we are updater and hold relevant mutex here | ||
621 | * Callers should ensure that this function is *NOT* called under RCU protection | ||
622 | * or in contexts where mutex locking cannot be used. | ||
623 | */ | ||
624 | int dev_pm_opp_init_cpufreq_table(struct device *dev, | ||
625 | struct cpufreq_frequency_table **table) | ||
626 | { | ||
627 | struct device_opp *dev_opp; | ||
628 | struct dev_pm_opp *opp; | ||
629 | struct cpufreq_frequency_table *freq_table; | ||
630 | int i = 0; | ||
631 | |||
632 | /* Pretend as if I am an updater */ | ||
633 | mutex_lock(&dev_opp_list_lock); | ||
634 | |||
635 | dev_opp = find_device_opp(dev); | ||
636 | if (IS_ERR(dev_opp)) { | ||
637 | int r = PTR_ERR(dev_opp); | ||
638 | mutex_unlock(&dev_opp_list_lock); | ||
639 | dev_err(dev, "%s: Device OPP not found (%d)\n", __func__, r); | ||
640 | return r; | ||
641 | } | ||
642 | |||
643 | freq_table = kzalloc(sizeof(struct cpufreq_frequency_table) * | ||
644 | (dev_pm_opp_get_opp_count(dev) + 1), GFP_KERNEL); | ||
645 | if (!freq_table) { | ||
646 | mutex_unlock(&dev_opp_list_lock); | ||
647 | dev_warn(dev, "%s: Unable to allocate frequency table\n", | ||
648 | __func__); | ||
649 | return -ENOMEM; | ||
650 | } | ||
651 | |||
652 | list_for_each_entry(opp, &dev_opp->opp_list, node) { | ||
653 | if (opp->available) { | ||
654 | freq_table[i].driver_data = i; | ||
655 | freq_table[i].frequency = opp->rate / 1000; | ||
656 | i++; | ||
657 | } | ||
658 | } | ||
659 | mutex_unlock(&dev_opp_list_lock); | ||
660 | |||
661 | freq_table[i].driver_data = i; | ||
662 | freq_table[i].frequency = CPUFREQ_TABLE_END; | ||
663 | |||
664 | *table = &freq_table[0]; | ||
665 | |||
666 | return 0; | ||
667 | } | ||
668 | EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table); | ||
669 | |||
670 | /** | ||
671 | * dev_pm_opp_free_cpufreq_table() - free the cpufreq table | ||
672 | * @dev: device for which we do this operation | ||
673 | * @table: table to free | ||
674 | * | ||
675 | * Free up the table allocated by dev_pm_opp_init_cpufreq_table | ||
676 | */ | ||
677 | void dev_pm_opp_free_cpufreq_table(struct device *dev, | ||
678 | struct cpufreq_frequency_table **table) | ||
679 | { | ||
680 | if (!table) | ||
681 | return; | ||
682 | |||
683 | kfree(*table); | ||
684 | *table = NULL; | ||
685 | } | ||
686 | EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); | ||
687 | #endif /* CONFIG_CPU_FREQ */ | ||
688 | |||
689 | /** | 598 | /** |
690 | * 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 |
691 | * @dev: device pointer used to lookup device OPPs. | 600 | * @dev: device pointer used to lookup device OPPs. |