Skip to content

Commit 55b1e68

Browse files
superm1ij-intel
authored andcommitted
ACPI: platform_profile: Use guard(mutex) for register/unregister
guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Mark Pearson <[email protected]> Tested-by: Matthew Schwartz <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Reviewed-by: Armin Wolf <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent ab431a2 commit 55b1e68

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/acpi/platform_profile.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,32 +184,26 @@ int platform_profile_register(struct platform_profile_handler *pprof)
184184
return -EINVAL;
185185
}
186186

187-
mutex_lock(&profile_lock);
187+
guard(mutex)(&profile_lock);
188188
/* We can only have one active profile */
189-
if (cur_profile) {
190-
mutex_unlock(&profile_lock);
189+
if (cur_profile)
191190
return -EEXIST;
192-
}
193191

194192
err = sysfs_create_group(acpi_kobj, &platform_profile_group);
195-
if (err) {
196-
mutex_unlock(&profile_lock);
193+
if (err)
197194
return err;
198-
}
199195

200196
cur_profile = pprof;
201-
mutex_unlock(&profile_lock);
202197
return 0;
203198
}
204199
EXPORT_SYMBOL_GPL(platform_profile_register);
205200

206201
int platform_profile_remove(struct platform_profile_handler *pprof)
207202
{
208-
sysfs_remove_group(acpi_kobj, &platform_profile_group);
203+
guard(mutex)(&profile_lock);
209204

210-
mutex_lock(&profile_lock);
205+
sysfs_remove_group(acpi_kobj, &platform_profile_group);
211206
cur_profile = NULL;
212-
mutex_unlock(&profile_lock);
213207
return 0;
214208
}
215209
EXPORT_SYMBOL_GPL(platform_profile_remove);

0 commit comments

Comments
 (0)