cpufreq: Drop unnecessary arguments from two functions
PATCH 1/1 cpufreq: Drop unnecessary arguments from two functions
From: Rafael J. Wysocki <[email protected]>
The second sif argument of __cpufreq_remove_dev_prepare() is never used by it, so drop it.
The second sif argument of __cpufreq_remove_dev_finish() is only used for one check that is not necessary if the policy is freed by cpufreq_remove_dev() itself, so make cpufreq_remove_dev() free the policy and drop the __cpufreq_remove_dev_finish()'s second argument too.
--- drivers/cpufreq/cpufreq.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-)
drivers/cpufreq/cpufreq.c +14 -19
@@ -1421,8 +1421,7 @@ out_release_rwsem:return ret; } -static int __cpufreq_remove_dev_prepare (struct device *dev, -struct subsys_interface *sif) +static int __cpufreq_remove_dev_prepare (struct device *dev) {unsigned int cpu = dev->id;int ret =0 ;
@@ -1474,8 +1473,7 @@ static int __cpufreq_remove_dev_prepare(return ret; } -static int __cpufreq_remove_dev_finish (struct device *dev, -struct subsys_interface *sif) +static int __cpufreq_remove_dev_finish (struct device *dev) {unsigned int cpu = dev->id;int ret;
@@ -1507,10 +1505,6 @@ static int __cpufreq_remove_dev_finish(sif (cpufreq_driver->exit) cpufreq_driver->exit (policy); -/* Free the policy only if the driver is getting removed. */ -if (sif) -cpufreq_policy_free (policy, true); -return 0 ; }
@@ -1522,6 +1516,7 @@ static int __cpufreq_remove_dev_finish(sstatic int cpufreq_remove_dev (struct device *dev,struct subsys_interface *sif) {unsigned int cpu = dev->id; +struct cpufreq_policy *policy =per_cpu (cpufreq_cpu_data, cpu);int ret;/*
@@ -1530,7 +1525,6 @@ static int cpufreq_remove_dev(struct dev* link or free policy here. */ if (cpu_is_offline (cpu)) { -struct cpufreq_policy *policy =per_cpu (cpufreq_cpu_data, cpu);struct cpumask mask;if (!policy)
@@ -1547,17 +1541,18 @@ static int cpufreq_remove_dev(struct devremove_cpu_dev_symlink (policy, cpu);return 0 ; } + }else { + ret =__cpufreq_remove_dev_prepare (dev); +if (!ret) + ret =__cpufreq_remove_dev_finish (dev); -cpufreq_policy_free (policy, true); -return 0 ; +/* The CPU is online, so the policy cannot be inactive here. */ +if (ret) +return ret; } - ret =__cpufreq_remove_dev_prepare (dev, sif); - -if (!ret) - ret =__cpufreq_remove_dev_finish (dev, sif); - -return ret; +cpufreq_policy_free (policy, true); +return 0 ; }static void handle_update (struct work_struct *work)
@@ -2396,11 +2391,11 @@ static int cpufreq_cpu_callback(struct nbreak ;case CPU_DOWN_PREPARE : -__cpufreq_remove_dev_prepare (dev,NULL ); +__cpufreq_remove_dev_prepare (dev);break ;case CPU_POST_DEAD : -__cpufreq_remove_dev_finish (dev,NULL ); +__cpufreq_remove_dev_finish (dev);break ;case CPU_DOWN_FAILED :
Viresh Kumar
maintainerQuoted 28 lines · Rafael J. Wysocki
static int
cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif){drivers/cpufreq/cpufreq.c +7
-3unsigned int cpu = dev->id; +struct cpufreq_policy *policy =per_cpu (cpufreq_cpu_data, cpu);int ret;/* @@ -1530,7 +1525,6 @@ static int cpufreq_remove_dev(struct dev* link or free policy here. */ if (cpu_is_offline (cpu)) { -struct cpufreq_policy *policy =per_cpu (cpufreq_cpu_data, cpu);struct cpumask mask;if (!policy)@@ -1547,17 +1541,18 @@ static int cpufreq_remove_dev(struct devremove_cpu_dev_symlink (policy, cpu);return 0 ; } + }else { + ret =__cpufreq_remove_dev_prepare (dev); +if (!ret) + ret =__cpufreq_remove_dev_finish (dev); -cpufreq_policy_free (policy, true); -return 0 ; +/* The CPU is online, so the policy cannot be inactive here. */ +if (ret)
drivers/cpufreq/cpufreq.c static int cpufreq_remove_dev(struct dev · line 1554
Quoted 10 lines
drivers/cpufreq/cpufreq.c +2
-6+return ret; } - ret =__cpufreq_remove_dev_prepare (dev, sif); - -if (!ret) - ret =__cpufreq_remove_dev_finish (dev, sif); - -return ret; +cpufreq_policy_free (policy, true);
You need to check for policy_is_inactive(policy) before freeing policy. cpufreq_remove_dev() will be called one by one for all CPUs of a policy ..
Signature · 1 line
viresh
PATCH v2 1/1 cpufreq: Drop unnecessary arguments from two functions
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Subject: cpufreq: Drop unnecessary arguments from two functions
After commit 9b07109f06a1 (cpufreq: Fix double addition of sysfs links) The second sif argument of __cpufreq_remove_dev_prepare() and __cpufreq_remove_dev_finish() is not used by them any more, so drop it.
---
Rebased on top of:
http://git.kernel.org/cgit/linux/kernel/git/rafael/linux-pm.git/commit/?h=bleeding-edge&id=9b07109f06a1edd6e636b1e7397157eae0e6baa4
Note: The above commit is on a testing branch only at the moment.
--- drivers/cpufreq/cpufreq.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq.c +6 -8
@@ -1376,8 +1376,7 @@ out_release_rwsem:return ret; } -static int __cpufreq_remove_dev_prepare (struct device *dev, -struct subsys_interface *sif) +static int __cpufreq_remove_dev_prepare (struct device *dev) {unsigned int cpu = dev->id;int ret =0 ;
@@ -1429,8 +1428,7 @@ static int __cpufreq_remove_dev_prepare(return ret; } -static int __cpufreq_remove_dev_finish (struct device *dev, -struct subsys_interface *sif) +static int __cpufreq_remove_dev_finish (struct device *dev) {unsigned int cpu = dev->id;int ret;
@@ -1480,9 +1478,9 @@ static int cpufreq_remove_dev(struct devreturn 0 ;if (cpu_online (cpu)) { - ret =__cpufreq_remove_dev_prepare (dev, sif); + ret =__cpufreq_remove_dev_prepare (dev);if (!ret) - ret =__cpufreq_remove_dev_finish (dev, sif); + ret =__cpufreq_remove_dev_finish (dev);if (ret)return ret; }
@@ -2376,11 +2374,11 @@ static int cpufreq_cpu_callback(struct nbreak ;case CPU_DOWN_PREPARE : -__cpufreq_remove_dev_prepare (dev,NULL ); +__cpufreq_remove_dev_prepare (dev);break ;case CPU_POST_DEAD : -__cpufreq_remove_dev_finish (dev,NULL ); +__cpufreq_remove_dev_finish (dev);break ;case CPU_DOWN_FAILED :
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Subject: cpufreq: Drop unnecessary arguments from two functionsAfter commit
9b07109f06a1(cpufreq: Fix double addition of sysfs links) The second sif argument of__cpufreq_remove_dev_prepare()and__cpufreq_remove_dev_finish()is not used by them any more, so drop it.
Quoted 7 lines
Signed-off-by Rafael J. Wysocki <[email protected]>---
Rebased on top of:
http://git.kernel.org/cgit/linux/kernel/git/rafael/linux-pm.git/commit/?h=bleeding-edge&id=9b07109f06a1edd6e636b1e7397157eae0e6baa4Note: The above commit is on a testing branch only at the moment.
Actually, scratch this one. We can address the removal issue mentioned in the other thread along with this.
I'll send a replacement patch to do that shortly.
Thanks,
Rafael