cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()
authorViresh Kumar <viresh.kumar@linaro.org>
Sat, 21 Nov 2015 03:36:49 +0000 (09:06 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 23 Nov 2015 21:49:42 +0000 (22:49 +0100)
commitf344dae0fe9f88d3c7ec45f2d7bba84d6ce1ac00
treec2dac58bfd7504fcbf141dc62fb92d9bae04a6ec
parent3bf7f56e70c9f0edb4f91cbb73a393c3b1d24801
cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()

Subsys interface's ->remove_dev() is called when the cpufreq driver is
unregistering or the CPU is getting physically removed. We keep removing
the cpuX/cpufreq link for all CPUs except the last one, which is a
mistake as all CPUs contain a link now.

Because of this, one CPU from each policy will still contain a link (to
an already removed policyX directory), after the cpufreq driver is
unregistered.

Fix that by removing the link first and then only see if the policy is
required to be freed. That will make sure that no links are left out.

Fixes: 96bdda61f58b ("cpufreq: create cpu/cpufreq/policyX directories")
Reported-and-tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c