Use scoped_cond_guard for the interruptible mutex in
platform_profile_show().
Signed-off-by: Mario Limonciello <mario.limonciello@amd.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