diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2013-05-17 06:39:09 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-05-27 07:24:02 -0400 |
commit | 2361be23666232dbb4851a527f466c4cbf5340fc (patch) | |
tree | 982ed55a3f4b097ddf9cffa7715b5e55db718466 | |
parent | 72a4ce340a7ebf39e1c6fdc8f5feb4f974d6c635 (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>
-rw-r--r-- | drivers/cpufreq/acpi-cpufreq.c | 4 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 48 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_governor.c | 6 | ||||
-rw-r--r-- | include/linux/cpufreq.h | 4 |
4 files changed, 56 insertions, 6 deletions
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 11b8b4b54ceb..8c02622b35a4 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
@@ -947,7 +947,7 @@ static void __init acpi_cpufreq_boost_init(void) | |||
947 | /* We create the boost file in any case, though for systems without | 947 | /* We create the boost file in any case, though for systems without |
948 | * hardware support it will be read-only and hardwired to return 0. | 948 | * hardware support it will be read-only and hardwired to return 0. |
949 | */ | 949 | */ |
950 | if (sysfs_create_file(cpufreq_global_kobject, &(global_boost.attr))) | 950 | if (cpufreq_sysfs_create_file(&(global_boost.attr))) |
951 | pr_warn(PFX "could not register global boost sysfs file\n"); | 951 | pr_warn(PFX "could not register global boost sysfs file\n"); |
952 | else | 952 | else |
953 | pr_debug("registered global boost sysfs file\n"); | 953 | pr_debug("registered global boost sysfs file\n"); |
@@ -955,7 +955,7 @@ static void __init acpi_cpufreq_boost_init(void) | |||
955 | 955 | ||
956 | static void __exit acpi_cpufreq_boost_exit(void) | 956 | static void __exit acpi_cpufreq_boost_exit(void) |
957 | { | 957 | { |
958 | sysfs_remove_file(cpufreq_global_kobject, &(global_boost.attr)); | 958 | cpufreq_sysfs_remove_file(&(global_boost.attr)); |
959 | 959 | ||
960 | if (msrs) { | 960 | if (msrs) { |
961 | unregister_cpu_notifier(&boost_nb); | 961 | unregister_cpu_notifier(&boost_nb); |
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 | ||
681 | struct kobject *cpufreq_global_kobject; | ||
682 | EXPORT_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 | ||
751 | struct kobject *cpufreq_global_kobject; | ||
752 | EXPORT_SYMBOL(cpufreq_global_kobject); | ||
753 | |||
754 | static int cpufreq_global_kobject_usage; | ||
755 | |||
756 | int 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 | } | ||
764 | EXPORT_SYMBOL(cpufreq_get_global_kobject); | ||
765 | |||
766 | void cpufreq_put_global_kobject(void) | ||
767 | { | ||
768 | if (!--cpufreq_global_kobject_usage) | ||
769 | kobject_del(cpufreq_global_kobject); | ||
770 | } | ||
771 | EXPORT_SYMBOL(cpufreq_put_global_kobject); | ||
772 | |||
773 | int 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 | } | ||
785 | EXPORT_SYMBOL(cpufreq_sysfs_create_file); | ||
786 | |||
787 | void cpufreq_sysfs_remove_file(const struct attribute *attr) | ||
788 | { | ||
789 | sysfs_remove_file(cpufreq_global_kobject, attr); | ||
790 | cpufreq_put_global_kobject(); | ||
791 | } | ||
792 | EXPORT_SYMBOL(cpufreq_sysfs_remove_file); | ||
793 | |||
754 | /* symlink affected CPUs */ | 794 | /* symlink affected CPUs */ |
755 | static int cpufreq_add_dev_symlink(unsigned int cpu, | 795 | static 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 | ||
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index b6cfd55d8266..7532570c42b4 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
@@ -231,6 +231,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
231 | return rc; | 231 | return rc; |
232 | } | 232 | } |
233 | 233 | ||
234 | if (!have_governor_per_policy()) | ||
235 | WARN_ON(cpufreq_get_global_kobject()); | ||
236 | |||
234 | rc = sysfs_create_group(get_governor_parent_kobj(policy), | 237 | rc = sysfs_create_group(get_governor_parent_kobj(policy), |
235 | get_sysfs_attr(dbs_data)); | 238 | get_sysfs_attr(dbs_data)); |
236 | if (rc) { | 239 | if (rc) { |
@@ -269,6 +272,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
269 | sysfs_remove_group(get_governor_parent_kobj(policy), | 272 | sysfs_remove_group(get_governor_parent_kobj(policy), |
270 | get_sysfs_attr(dbs_data)); | 273 | get_sysfs_attr(dbs_data)); |
271 | 274 | ||
275 | if (!have_governor_per_policy()) | ||
276 | cpufreq_put_global_kobject(); | ||
277 | |||
272 | if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && | 278 | if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && |
273 | (policy->governor->initialized == 1)) { | 279 | (policy->governor->initialized == 1)) { |
274 | struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; | 280 | struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index fbf392aaa02e..1b5b5efa3e3a 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -71,6 +71,10 @@ struct cpufreq_governor; | |||
71 | 71 | ||
72 | /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ | 72 | /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ |
73 | extern struct kobject *cpufreq_global_kobject; | 73 | extern struct kobject *cpufreq_global_kobject; |
74 | int cpufreq_get_global_kobject(void); | ||
75 | void cpufreq_put_global_kobject(void); | ||
76 | int cpufreq_sysfs_create_file(const struct attribute *attr); | ||
77 | void cpufreq_sysfs_remove_file(const struct attribute *attr); | ||
74 | 78 | ||
75 | #define CPUFREQ_ETERNAL (-1) | 79 | #define CPUFREQ_ETERNAL (-1) |
76 | struct cpufreq_cpuinfo { | 80 | struct cpufreq_cpuinfo { |