From: Huang, Tao Date: Tue, 5 Jul 2016 10:35:00 +0000 (+0800) Subject: Revert "cpufreq: interactive: fix cpufreq object duplicate creatation in sysfs" X-Git-Tag: firefly_0821_release~2232 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6330e362bd8403d69fb2a1caf2d55145771ca66a;p=firefly-linux-kernel-4.4.55.git Revert "cpufreq: interactive: fix cpufreq object duplicate creatation in sysfs" This reverts commit 857ad0187f6259e429df117480490c1fc587bc36. Fixes by LSK commit b42fb9a7101001d14f996fe2e671f3e7eddded3b ("Revert "cpufreq: interactive: build fixes for 4.4"") and commit de5723c8a64e7f7a69662b75d4a789a6e5307dd4 ("cpufreq: interactive: drop cpufreq_{get,put}_global_kobject func calls") Signed-off-by: Huang, Tao --- diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index 1cfbcb8ba75c..bd83be39f17b 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -116,6 +116,28 @@ struct cpufreq_interactive_tunables { bool io_is_busy; }; +/* + * HACK: FIXME: Bring back cpufreq_{get,put}_global_kobject() + * definition removed by upstream commit 8eec1020f0c0 "cpufreq: + * create cpu/cpufreq at boot time" to fix build failures. + */ +static int cpufreq_global_kobject_usage; + +int cpufreq_get_global_kobject(void) +{ + if (!cpufreq_global_kobject_usage++) + return kobject_add(cpufreq_global_kobject, + &cpu_subsys.dev_root->kobj, "%s", "cpufreq"); + + return 0; +} + +void cpufreq_put_global_kobject(void) +{ + if (!--cpufreq_global_kobject_usage) + kobject_del(cpufreq_global_kobject); +} + /* For cases where we have single governor instance for system */ static struct cpufreq_interactive_tunables *common_tunables; @@ -1184,6 +1206,7 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, policy->governor_data = tunables; if (!have_governor_per_policy()) { common_tunables = tunables; + WARN_ON(cpufreq_get_global_kobject()); } rc = sysfs_create_group(get_governor_parent_kobj(policy), @@ -1193,6 +1216,7 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, policy->governor_data = NULL; if (!have_governor_per_policy()) { common_tunables = NULL; + cpufreq_put_global_kobject(); } return rc; } @@ -1216,6 +1240,8 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, sysfs_remove_group(get_governor_parent_kobj(policy), get_sysfs_attr()); + if (!have_governor_per_policy()) + cpufreq_put_global_kobject(); kfree(tunables); common_tunables = NULL;