Commit b17b8064 authored by Liguang Zhang's avatar Liguang Zhang Committed by Rafael J. Wysocki

ACPI: CPPC: clean up acpi_get_psd_map()

In acpi_get_psd_map() variable all_cpu_data[] can't be NULL and variable
match_cpc_ptr has been checked before, no need check again at the end of
the funchtion.

Some additional optimizations can be made on top of that.
Signed-off-by: default avatarLiguang Zhang <zhangliguang@linux.alibaba.com>
[ rjw: Subject & changelog ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 16fbf79b
...@@ -438,13 +438,10 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data) ...@@ -438,13 +438,10 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data)
* domain info. * domain info.
*/ */
for_each_possible_cpu(i) { for_each_possible_cpu(i) {
pr = all_cpu_data[i];
if (!pr)
continue;
if (cpumask_test_cpu(i, covered_cpus)) if (cpumask_test_cpu(i, covered_cpus))
continue; continue;
pr = all_cpu_data[i];
cpc_ptr = per_cpu(cpc_desc_ptr, i); cpc_ptr = per_cpu(cpc_desc_ptr, i);
if (!cpc_ptr) { if (!cpc_ptr) {
retval = -EFAULT; retval = -EFAULT;
...@@ -495,44 +492,28 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data) ...@@ -495,44 +492,28 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data)
cpumask_set_cpu(j, pr->shared_cpu_map); cpumask_set_cpu(j, pr->shared_cpu_map);
} }
for_each_possible_cpu(j) { for_each_cpu(j, pr->shared_cpu_map) {
if (i == j) if (i == j)
continue; continue;
match_pr = all_cpu_data[j]; match_pr = all_cpu_data[j];
if (!match_pr)
continue;
match_cpc_ptr = per_cpu(cpc_desc_ptr, j);
if (!match_cpc_ptr) {
retval = -EFAULT;
goto err_ret;
}
match_pdomain = &(match_cpc_ptr->domain_info);
if (match_pdomain->domain != pdomain->domain)
continue;
match_pr->shared_type = pr->shared_type; match_pr->shared_type = pr->shared_type;
cpumask_copy(match_pr->shared_cpu_map, cpumask_copy(match_pr->shared_cpu_map,
pr->shared_cpu_map); pr->shared_cpu_map);
} }
} }
goto out;
err_ret: err_ret:
for_each_possible_cpu(i) { for_each_possible_cpu(i) {
pr = all_cpu_data[i]; pr = all_cpu_data[i];
if (!pr)
continue;
/* Assume no coordination on any error parsing domain info */ /* Assume no coordination on any error parsing domain info */
if (retval) {
cpumask_clear(pr->shared_cpu_map); cpumask_clear(pr->shared_cpu_map);
cpumask_set_cpu(i, pr->shared_cpu_map); cpumask_set_cpu(i, pr->shared_cpu_map);
pr->shared_type = CPUFREQ_SHARED_TYPE_ALL; pr->shared_type = CPUFREQ_SHARED_TYPE_ALL;
} }
} out:
free_cpumask_var(covered_cpus); free_cpumask_var(covered_cpus);
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment