Skip to content

Commit be5c8a0

Browse files
committed
ACPI: processor: perflib: Rearrange acpi_processor_notify_smm()
Rearrange the code in acpi_processor_notify_smm() to consolidate error handling in it and improve the comments in there while at it. No expected functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 5be583c commit be5c8a0

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

drivers/acpi/processor_perflib.c

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -453,48 +453,46 @@ int acpi_processor_pstate_control(void)
453453
int acpi_processor_notify_smm(struct module *calling_module)
454454
{
455455
static int is_done;
456-
int result;
456+
int result = 0;
457457

458458
if (!acpi_processor_cpufreq_init)
459459
return -EBUSY;
460460

461461
if (!try_module_get(calling_module))
462462
return -EINVAL;
463463

464-
/* is_done is set to negative if an error occurred,
465-
* and to postitive if _no_ error occurred, but SMM
466-
* was already notified. This avoids double notification
467-
* which might lead to unexpected results...
464+
/*
465+
* is_done is set to negative if an error occurs and to 1 if no error
466+
* occurrs, but SMM has been notified already. This avoids repeated
467+
* notification which might lead to unexpected results.
468468
*/
469-
if (is_done > 0) {
470-
module_put(calling_module);
471-
return 0;
472-
} else if (is_done < 0) {
473-
module_put(calling_module);
474-
return is_done;
475-
}
469+
if (is_done != 0) {
470+
if (is_done < 0)
471+
result = is_done;
476472

477-
is_done = -EIO;
473+
goto out_put;
474+
}
478475

479476
result = acpi_processor_pstate_control();
480-
if (!result) {
481-
pr_debug("No SMI port or pstate_control\n");
482-
module_put(calling_module);
483-
return 0;
484-
}
485-
if (result < 0) {
486-
module_put(calling_module);
487-
return result;
477+
if (result <= 0) {
478+
if (!result)
479+
pr_debug("No SMI port or pstate_control\n");
480+
481+
is_done = -EIO;
482+
goto out_put;
488483
}
489484

490-
/* Success. If there's no _PPC, we need to fear nothing, so
491-
* we can allow the cpufreq driver to be rmmod'ed. */
492485
is_done = 1;
486+
/*
487+
* Success. If there _PPC, unloading the cpufreq driver would be risky,
488+
* so disallow it in that case.
489+
*/
490+
if (acpi_processor_ppc_in_use)
491+
return 0;
493492

494-
if (!acpi_processor_ppc_in_use)
495-
module_put(calling_module);
496-
497-
return 0;
493+
out_put:
494+
module_put(calling_module);
495+
return result;
498496
}
499497
EXPORT_SYMBOL(acpi_processor_notify_smm);
500498

0 commit comments

Comments
 (0)