mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-09 07:14:48 +08:00
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 <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
5be583c695
commit
be5c8a046c
@ -453,7 +453,7 @@ int acpi_processor_pstate_control(void)
|
|||||||
int acpi_processor_notify_smm(struct module *calling_module)
|
int acpi_processor_notify_smm(struct module *calling_module)
|
||||||
{
|
{
|
||||||
static int is_done;
|
static int is_done;
|
||||||
int result;
|
int result = 0;
|
||||||
|
|
||||||
if (!acpi_processor_cpufreq_init)
|
if (!acpi_processor_cpufreq_init)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
@ -461,40 +461,38 @@ int acpi_processor_notify_smm(struct module *calling_module)
|
|||||||
if (!try_module_get(calling_module))
|
if (!try_module_get(calling_module))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* is_done is set to negative if an error occurred,
|
/*
|
||||||
* and to postitive if _no_ error occurred, but SMM
|
* is_done is set to negative if an error occurs and to 1 if no error
|
||||||
* was already notified. This avoids double notification
|
* occurrs, but SMM has been notified already. This avoids repeated
|
||||||
* which might lead to unexpected results...
|
* notification which might lead to unexpected results.
|
||||||
*/
|
*/
|
||||||
if (is_done > 0) {
|
if (is_done != 0) {
|
||||||
module_put(calling_module);
|
if (is_done < 0)
|
||||||
return 0;
|
result = is_done;
|
||||||
} else if (is_done < 0) {
|
|
||||||
module_put(calling_module);
|
|
||||||
return is_done;
|
|
||||||
}
|
|
||||||
|
|
||||||
is_done = -EIO;
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
result = acpi_processor_pstate_control();
|
result = acpi_processor_pstate_control();
|
||||||
if (!result) {
|
if (result <= 0) {
|
||||||
pr_debug("No SMI port or pstate_control\n");
|
if (!result)
|
||||||
module_put(calling_module);
|
pr_debug("No SMI port or pstate_control\n");
|
||||||
return 0;
|
|
||||||
}
|
is_done = -EIO;
|
||||||
if (result < 0) {
|
goto out_put;
|
||||||
module_put(calling_module);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success. If there's no _PPC, we need to fear nothing, so
|
|
||||||
* we can allow the cpufreq driver to be rmmod'ed. */
|
|
||||||
is_done = 1;
|
is_done = 1;
|
||||||
|
/*
|
||||||
|
* Success. If there _PPC, unloading the cpufreq driver would be risky,
|
||||||
|
* so disallow it in that case.
|
||||||
|
*/
|
||||||
|
if (acpi_processor_ppc_in_use)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!acpi_processor_ppc_in_use)
|
out_put:
|
||||||
module_put(calling_module);
|
module_put(calling_module);
|
||||||
|
return result;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(acpi_processor_notify_smm);
|
EXPORT_SYMBOL(acpi_processor_notify_smm);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user