diff options
author | Michael J. Ruhl <michael.j.ruhl@intel.com> | 2025-07-13 13:29:36 -0400 |
---|---|---|
committer | Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> | 2025-07-22 17:38:56 +0300 |
commit | 4f8fa22d108006b8ec0b94bb67a1bd537a2bf141 (patch) | |
tree | f1138c442b89db2ef9a767d8b5a7ddc7faa00b24 /drivers/platform/x86/intel/pmt/crashlog.c | |
parent | 75a496aa054326d9ebf27b39e1af8b5b770311ba (diff) |
platform/x86/intel/pmt: use guard(mutex)
Update the mutex paths to use the new guard() mechanism.
With the removal of goto, do some minor cleanup of the current logic
path.
Reviewed-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Link: https://lore.kernel.org/r/20250713172943.7335-7-michael.j.ruhl@intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86/intel/pmt/crashlog.c')
-rw-r--r-- | drivers/platform/x86/intel/pmt/crashlog.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/platform/x86/intel/pmt/crashlog.c b/drivers/platform/x86/intel/pmt/crashlog.c index 6e32fc1f8f1d..c3ca95854aba 100644 --- a/drivers/platform/x86/intel/pmt/crashlog.c +++ b/drivers/platform/x86/intel/pmt/crashlog.c @@ -9,6 +9,7 @@ */ #include <linux/auxiliary_bus.h> +#include <linux/cleanup.h> #include <linux/intel_vsec.h> #include <linux/kernel.h> #include <linux/module.h> @@ -156,9 +157,9 @@ enable_store(struct device *dev, struct device_attribute *attr, if (result) return result; - mutex_lock(&entry->control_mutex); + guard(mutex)(&entry->control_mutex); + pmt_crashlog_set_disable(&entry->entry, !enabled); - mutex_unlock(&entry->control_mutex); return count; } @@ -190,26 +191,24 @@ trigger_store(struct device *dev, struct device_attribute *attr, if (result) return result; - mutex_lock(&entry->control_mutex); + guard(mutex)(&entry->control_mutex); if (!trigger) { pmt_crashlog_set_clear(&entry->entry); - } else if (pmt_crashlog_complete(&entry->entry)) { - /* we cannot trigger a new crash if one is still pending */ - result = -EEXIST; - goto err; - } else if (pmt_crashlog_disabled(&entry->entry)) { - /* if device is currently disabled, return busy */ - result = -EBUSY; - goto err; - } else { - pmt_crashlog_set_execute(&entry->entry); + return count; } - result = count; -err: - mutex_unlock(&entry->control_mutex); - return result; + /* we cannot trigger a new crash if one is still pending */ + if (pmt_crashlog_complete(&entry->entry)) + return -EEXIST; + + /* if device is currently disabled, return busy */ + if (pmt_crashlog_disabled(&entry->entry)) + return -EBUSY; + + pmt_crashlog_set_execute(&entry->entry); + + return count; } static DEVICE_ATTR_RW(trigger); |