Skip to content

Commit b48cd0d

Browse files
YuryNorovvireshk
authored andcommitted
cpufreq: replace cpumask_weight with cpumask_empty where appropriate
drivers/cpufreq calls cpumask_weight() to check if any bit of a given cpumask is set. We can do it more efficiently with cpumask_empty() because cpumask_empty() stops traversing the cpumask as soon as it finds first set bit, while cpumask_weight() counts all bits unconditionally. Signed-off-by: Yury Norov <yury.norov@gmail.com> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> (for SCMI cpufreq driver) Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent ef8ee1c commit b48cd0d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/cpufreq/qcom-cpufreq-hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
482482
}
483483

484484
qcom_get_related_cpus(index, policy->cpus);
485-
if (!cpumask_weight(policy->cpus)) {
485+
if (cpumask_empty(policy->cpus)) {
486486
dev_err(dev, "Domain-%d failed to get related CPUs\n", index);
487487
ret = -ENOENT;
488488
goto error;

drivers/cpufreq/scmi-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
154154
* table and opp-shared.
155155
*/
156156
ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->opp_shared_cpus);
157-
if (ret || !cpumask_weight(priv->opp_shared_cpus)) {
157+
if (ret || cpumask_empty(priv->opp_shared_cpus)) {
158158
/*
159159
* Either opp-table is not set or no opp-shared was found.
160160
* Use the CPU mask from SCMI to designate CPUs sharing an OPP

0 commit comments

Comments
 (0)