cpufreq: Clear real_cpus mask from remove_cpu_dev_symlink()
authorViresh Kumar <viresh.kumar@linaro.org>
Wed, 11 May 2022 09:06:24 +0000 (14:36 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 11 May 2022 17:23:10 +0000 (19:23 +0200)
add_cpu_dev_symlink() is responsible for setting the CPUs in the
real_cpus mask, the reverse of which should be done from
remove_cpu_dev_symlink() to make it look clean and avoid any breakage
later on.

Move the call to clear the mask to remove_cpu_dev_symlink().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c

index fbaa8e6c7d2323c2cc48554b7986d3ebf15abad3..c8bf6c68597cb2c25179e7def85f25c278fb2eed 100644 (file)
@@ -1020,11 +1020,12 @@ static void add_cpu_dev_symlink(struct cpufreq_policy *policy, unsigned int cpu,
                dev_err(dev, "cpufreq symlink creation failed\n");
 }
 
-static void remove_cpu_dev_symlink(struct cpufreq_policy *policy,
+static void remove_cpu_dev_symlink(struct cpufreq_policy *policy, int cpu,
                                   struct device *dev)
 {
        dev_dbg(dev, "%s: Removing symlink\n", __func__);
        sysfs_remove_link(&dev->kobj, "cpufreq");
+       cpumask_clear_cpu(cpu, policy->real_cpus);
 }
 
 static int cpufreq_add_dev_interface(struct cpufreq_policy *policy)
@@ -1532,7 +1533,7 @@ static int cpufreq_online(unsigned int cpu)
 
 out_destroy_policy:
        for_each_cpu(j, policy->real_cpus)
-               remove_cpu_dev_symlink(policy, get_cpu_device(j));
+               remove_cpu_dev_symlink(policy, j, get_cpu_device(j));
 
        up_write(&policy->rwsem);
 
@@ -1657,8 +1658,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
        if (cpu_online(cpu))
                cpufreq_offline(cpu);
 
-       cpumask_clear_cpu(cpu, policy->real_cpus);
-       remove_cpu_dev_symlink(policy, dev);
+       remove_cpu_dev_symlink(policy, cpu, dev);
 
        if (cpumask_empty(policy->real_cpus)) {
                /* We did light-weight exit earlier, do full tear down now */