Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a794d613 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

cpufreq: Rearrange cpufreq_add_dev()



Reorganize the code in cpufreq_add_dev() to avoid using the ret
variable and reduce the indentation level in it.

No functional changes.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent cd73e9b0
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -1320,26 +1320,24 @@ static int cpufreq_online(unsigned int cpu)
 */
static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
{
	struct cpufreq_policy *policy;
	unsigned cpu = dev->id;
	int ret;

	dev_dbg(dev, "%s: adding CPU%u\n", __func__, cpu);

	if (cpu_online(cpu)) {
		ret = cpufreq_online(cpu);
	} else {
	if (cpu_online(cpu))
		return cpufreq_online(cpu);

	/*
		 * A hotplug notifier will follow and we will handle it as CPU
		 * online then.  For now, just create the sysfs link, unless
		 * there is no policy or the link is already present.
	 * A hotplug notifier will follow and we will handle it as CPU online
	 * then.  For now, just create the sysfs link, unless there is no policy
	 * or the link is already present.
	 */
		struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);

		ret = policy && !cpumask_test_and_set_cpu(cpu, policy->real_cpus)
			? add_cpu_dev_symlink(policy, cpu) : 0;
	}
	policy = per_cpu(cpufreq_cpu_data, cpu);
	if (!policy || cpumask_test_and_set_cpu(cpu, policy->real_cpus))
		return 0;

	return ret;
	return add_cpu_dev_symlink(policy, cpu);
}

static void cpufreq_offline(unsigned int cpu)