cpufreq: replace cpumask_weight with cpumask_empty where appropriate
authorYury Norov <yury.norov@gmail.com>
Sun, 23 Jan 2022 18:38:47 +0000 (10:38 -0800)
committerViresh Kumar <viresh.kumar@linaro.org>
Wed, 9 Feb 2022 07:50:03 +0000 (13:20 +0530)
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>
drivers/cpufreq/qcom-cpufreq-hw.c
drivers/cpufreq/scmi-cpufreq.c

index effbb68..c2cda28 100644 (file)
@@ -482,7 +482,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)
        }
 
        qcom_get_related_cpus(index, policy->cpus);
-       if (!cpumask_weight(policy->cpus)) {
+       if (cpumask_empty(policy->cpus)) {
                dev_err(dev, "Domain-%d failed to get related CPUs\n", index);
                ret = -ENOENT;
                goto error;
index 1e0cd4d..919fa6e 100644 (file)
@@ -154,7 +154,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
         * table and opp-shared.
         */
        ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, priv->opp_shared_cpus);
-       if (ret || !cpumask_weight(priv->opp_shared_cpus)) {
+       if (ret || cpumask_empty(priv->opp_shared_cpus)) {
                /*
                 * Either opp-table is not set or no opp-shared was found.
                 * Use the CPU mask from SCMI to designate CPUs sharing an OPP