aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-05-17 06:39:09 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-05-27 07:24:02 -0400
commit2361be23666232dbb4851a527f466c4cbf5340fc (patch)
tree982ed55a3f4b097ddf9cffa7715b5e55db718466 /drivers/cpufreq/cpufreq.c
parent72a4ce340a7ebf39e1c6fdc8f5feb4f974d6c635 (diff)
cpufreq: Don't create empty /sys/devices/system/cpu/cpufreq directory
When we don't have any file in cpu/cpufreq directory we shouldn't create it. Specially with the introduction of per-policy governor instance patchset, even governors are moved to cpu/cpu*/cpufreq/governor-name directory and so this directory is just not required. Lets have it only when required. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index c6ab21880c07..ce9273a7b4e3 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -678,9 +678,6 @@ static struct attribute *default_attrs[] = {
678 NULL 678 NULL
679}; 679};
680 680
681struct kobject *cpufreq_global_kobject;
682EXPORT_SYMBOL(cpufreq_global_kobject);
683
684#define to_policy(k) container_of(k, struct cpufreq_policy, kobj) 681#define to_policy(k) container_of(k, struct cpufreq_policy, kobj)
685#define to_attr(a) container_of(a, struct freq_attr, attr) 682#define to_attr(a) container_of(a, struct freq_attr, attr)
686 683
@@ -751,6 +748,49 @@ static struct kobj_type ktype_cpufreq = {
751 .release = cpufreq_sysfs_release, 748 .release = cpufreq_sysfs_release,
752}; 749};
753 750
751struct kobject *cpufreq_global_kobject;
752EXPORT_SYMBOL(cpufreq_global_kobject);
753
754static int cpufreq_global_kobject_usage;
755
756int cpufreq_get_global_kobject(void)
757{
758 if (!cpufreq_global_kobject_usage++)
759 return kobject_add(cpufreq_global_kobject,
760 &cpu_subsys.dev_root->kobj, "%s", "cpufreq");
761
762 return 0;
763}
764EXPORT_SYMBOL(cpufreq_get_global_kobject);
765
766void cpufreq_put_global_kobject(void)
767{
768 if (!--cpufreq_global_kobject_usage)
769 kobject_del(cpufreq_global_kobject);
770}
771EXPORT_SYMBOL(cpufreq_put_global_kobject);
772
773int cpufreq_sysfs_create_file(const struct attribute *attr)
774{
775 int ret = cpufreq_get_global_kobject();
776
777 if (!ret) {
778 ret = sysfs_create_file(cpufreq_global_kobject, attr);
779 if (ret)
780 cpufreq_put_global_kobject();
781 }
782
783 return ret;
784}
785EXPORT_SYMBOL(cpufreq_sysfs_create_file);
786
787void cpufreq_sysfs_remove_file(const struct attribute *attr)
788{
789 sysfs_remove_file(cpufreq_global_kobject, attr);
790 cpufreq_put_global_kobject();
791}
792EXPORT_SYMBOL(cpufreq_sysfs_remove_file);
793
754/* symlink affected CPUs */ 794/* symlink affected CPUs */
755static int cpufreq_add_dev_symlink(unsigned int cpu, 795static int cpufreq_add_dev_symlink(unsigned int cpu,
756 struct cpufreq_policy *policy) 796 struct cpufreq_policy *policy)
@@ -2020,7 +2060,7 @@ static int __init cpufreq_core_init(void)
2020 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); 2060 init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));
2021 } 2061 }
2022 2062
2023 cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj); 2063 cpufreq_global_kobject = kobject_create();
2024 BUG_ON(!cpufreq_global_kobject); 2064 BUG_ON(!cpufreq_global_kobject);
2025 register_syscore_ops(&cpufreq_syscore_ops); 2065 register_syscore_ops(&cpufreq_syscore_ops);
2026 2066