Commit 336e5128 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki
Browse files

cpufreq: Optimize cpufreq_show_cpus()



Instead of specially adding a space for each CPU, except the first one,
lets add space for each of them and remove it at the end.

Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent b13baccc
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -843,12 +843,14 @@ ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf)
	unsigned int cpu;

	for_each_cpu(cpu, mask) {
		if (i)
			i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " ");
		i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u ", cpu);
		if (i >= (PAGE_SIZE - 5))
			break;
	}

	/* Remove the extra space at the end */
	i--;

	i += sprintf(&buf[i], "\n");
	return i;
}