[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241031040952.109057-10-mario.limonciello@amd.com>
Date: Wed, 30 Oct 2024 23:09:39 -0500
From: Mario Limonciello <mario.limonciello@....com>
To: Hans de Goede <hdegoede@...hat.com>, Ilpo Järvinen
<ilpo.jarvinen@...ux.intel.com>
CC: "Rafael J . Wysocki" <rafael@...nel.org>, Len Brown <lenb@...nel.org>,
Maximilian Luz <luzmaximilian@...il.com>, Lee Chun-Yi <jlee@...e.com>, "Shyam
Sundar S K" <Shyam-sundar.S-k@....com>, Corentin Chary
<corentin.chary@...il.com>, "Luke D . Jones" <luke@...nes.dev>, Ike Panhc
<ike.pan@...onical.com>, Henrique de Moraes Holschuh <hmh@....eng.br>,
"Alexis Belmonte" <alexbelm48@...il.com>, Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>, Ai Chao <aichao@...inos.cn>, Gergo Koteles
<soyer@....hu>, open list <linux-kernel@...r.kernel.org>, "open list:ACPI"
<linux-acpi@...r.kernel.org>, "open list:MICROSOFT SURFACE PLATFORM PROFILE
DRIVER" <platform-driver-x86@...r.kernel.org>, "open list:THINKPAD ACPI
EXTRAS DRIVER" <ibm-acpi-devel@...ts.sourceforge.net>, Mark Pearson
<mpearson-lenovo@...ebb.ca>, Matthew Schwartz <matthew.schwartz@...ux.dev>,
Mario Limonciello <mario.limonciello@....com>
Subject: [PATCH v3 09/22] ACPI: platform_profile: Use `scoped_cond_guard` for platform_profile_show()
Use scoped_cond_guard for the interruptible mutex in
platform_profile_show().
Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
drivers/acpi/platform_profile.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 79feb273c1def..b48dd34301f13 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -53,20 +53,15 @@ static ssize_t platform_profile_show(struct device *dev,
enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
int err;
- err = mutex_lock_interruptible(&profile_lock);
- if (err)
- return err;
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ if (!cur_profile)
+ return -ENODEV;
- if (!cur_profile) {
- mutex_unlock(&profile_lock);
- return -ENODEV;
+ err = cur_profile->profile_get(cur_profile, &profile);
+ if (err)
+ return err;
}
- err = cur_profile->profile_get(cur_profile, &profile);
- mutex_unlock(&profile_lock);
- if (err)
- return err;
-
/* Check that profile is valid index */
if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names))))
return -EIO;
--
2.43.0
Powered by blists - more mailing lists