Skip to content

Commit b17b806

Browse files
luanshi0212rafaeljw
authored andcommitted
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: Liguang Zhang <[email protected]> [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 16fbf79 commit b17b806

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

drivers/acpi/cppc_acpi.c

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,10 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data)
438438
* domain info.
439439
*/
440440
for_each_possible_cpu(i) {
441-
pr = all_cpu_data[i];
442-
if (!pr)
443-
continue;
444-
445441
if (cpumask_test_cpu(i, covered_cpus))
446442
continue;
447443

444+
pr = all_cpu_data[i];
448445
cpc_ptr = per_cpu(cpc_desc_ptr, i);
449446
if (!cpc_ptr) {
450447
retval = -EFAULT;
@@ -495,44 +492,28 @@ int acpi_get_psd_map(struct cppc_cpudata **all_cpu_data)
495492
cpumask_set_cpu(j, pr->shared_cpu_map);
496493
}
497494

498-
for_each_possible_cpu(j) {
495+
for_each_cpu(j, pr->shared_cpu_map) {
499496
if (i == j)
500497
continue;
501498

502499
match_pr = all_cpu_data[j];
503-
if (!match_pr)
504-
continue;
505-
506-
match_cpc_ptr = per_cpu(cpc_desc_ptr, j);
507-
if (!match_cpc_ptr) {
508-
retval = -EFAULT;
509-
goto err_ret;
510-
}
511-
512-
match_pdomain = &(match_cpc_ptr->domain_info);
513-
if (match_pdomain->domain != pdomain->domain)
514-
continue;
515-
516500
match_pr->shared_type = pr->shared_type;
517501
cpumask_copy(match_pr->shared_cpu_map,
518502
pr->shared_cpu_map);
519503
}
520504
}
505+
goto out;
521506

522507
err_ret:
523508
for_each_possible_cpu(i) {
524509
pr = all_cpu_data[i];
525-
if (!pr)
526-
continue;
527510

528511
/* Assume no coordination on any error parsing domain info */
529-
if (retval) {
530-
cpumask_clear(pr->shared_cpu_map);
531-
cpumask_set_cpu(i, pr->shared_cpu_map);
532-
pr->shared_type = CPUFREQ_SHARED_TYPE_ALL;
533-
}
512+
cpumask_clear(pr->shared_cpu_map);
513+
cpumask_set_cpu(i, pr->shared_cpu_map);
514+
pr->shared_type = CPUFREQ_SHARED_TYPE_ALL;
534515
}
535-
516+
out:
536517
free_cpumask_var(covered_cpus);
537518
return retval;
538519
}

0 commit comments

Comments
 (0)