summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_perflib.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-12-05 20:07:08 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-12-07 18:09:39 +0100
commitbe5c8a046caaa295b6151b7a6653070ff8119ac2 (patch)
treee0929b49f8ecb6786ef9c89aea188d1e43a5bd19 /drivers/acpi/processor_perflib.c
parent5be583c695ed4d94211cc28282a42092b137f988 (diff)
downloadlinux-stable-be5c8a046caaa295b6151b7a6653070ff8119ac2.tar.gz
linux-stable-be5c8a046caaa295b6151b7a6653070ff8119ac2.tar.bz2
linux-stable-be5c8a046caaa295b6151b7a6653070ff8119ac2.zip
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>
Diffstat (limited to 'drivers/acpi/processor_perflib.c')
-rw-r--r--drivers/acpi/processor_perflib.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 10d2999a5773..7b6fa1b27afb 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -453,7 +453,7 @@ int acpi_processor_pstate_control(void)
int acpi_processor_notify_smm(struct module *calling_module)
{
static int is_done;
- int result;
+ int result = 0;
if (!acpi_processor_cpufreq_init)
return -EBUSY;
@@ -461,40 +461,38 @@ int acpi_processor_notify_smm(struct module *calling_module)
if (!try_module_get(calling_module))
return -EINVAL;
- /* is_done is set to negative if an error occurred,
- * and to postitive if _no_ error occurred, but SMM
- * was already notified. This avoids double notification
- * which might lead to unexpected results...
+ /*
+ * is_done is set to negative if an error occurs and to 1 if no error
+ * occurrs, but SMM has been notified already. This avoids repeated
+ * notification which might lead to unexpected results.
*/
- if (is_done > 0) {
- module_put(calling_module);
- return 0;
- } else if (is_done < 0) {
- module_put(calling_module);
- return is_done;
- }
+ if (is_done != 0) {
+ if (is_done < 0)
+ result = is_done;
- is_done = -EIO;
+ goto out_put;
+ }
result = acpi_processor_pstate_control();
- if (!result) {
- pr_debug("No SMI port or pstate_control\n");
- module_put(calling_module);
- return 0;
- }
- if (result < 0) {
- module_put(calling_module);
- return result;
+ if (result <= 0) {
+ if (!result)
+ pr_debug("No SMI port or pstate_control\n");
+
+ is_done = -EIO;
+ goto out_put;
}
- /* 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;
+ /*
+ * 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)
- module_put(calling_module);
-
- return 0;
+out_put:
+ module_put(calling_module);
+ return result;
}
EXPORT_SYMBOL(acpi_processor_notify_smm);