Skip to content

Commit 4f8fa22

Browse files
mjruhlij-intel
authored andcommitted
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 <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Michael J. Ruhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 75a496a commit 4f8fa22

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

drivers/platform/x86/intel/pmt/crashlog.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/auxiliary_bus.h>
12+
#include <linux/cleanup.h>
1213
#include <linux/intel_vsec.h>
1314
#include <linux/kernel.h>
1415
#include <linux/module.h>
@@ -156,9 +157,9 @@ enable_store(struct device *dev, struct device_attribute *attr,
156157
if (result)
157158
return result;
158159

159-
mutex_lock(&entry->control_mutex);
160+
guard(mutex)(&entry->control_mutex);
161+
160162
pmt_crashlog_set_disable(&entry->entry, !enabled);
161-
mutex_unlock(&entry->control_mutex);
162163

163164
return count;
164165
}
@@ -190,26 +191,24 @@ trigger_store(struct device *dev, struct device_attribute *attr,
190191
if (result)
191192
return result;
192193

193-
mutex_lock(&entry->control_mutex);
194+
guard(mutex)(&entry->control_mutex);
194195

195196
if (!trigger) {
196197
pmt_crashlog_set_clear(&entry->entry);
197-
} else if (pmt_crashlog_complete(&entry->entry)) {
198-
/* we cannot trigger a new crash if one is still pending */
199-
result = -EEXIST;
200-
goto err;
201-
} else if (pmt_crashlog_disabled(&entry->entry)) {
202-
/* if device is currently disabled, return busy */
203-
result = -EBUSY;
204-
goto err;
205-
} else {
206-
pmt_crashlog_set_execute(&entry->entry);
198+
return count;
207199
}
208200

209-
result = count;
210-
err:
211-
mutex_unlock(&entry->control_mutex);
212-
return result;
201+
/* we cannot trigger a new crash if one is still pending */
202+
if (pmt_crashlog_complete(&entry->entry))
203+
return -EEXIST;
204+
205+
/* if device is currently disabled, return busy */
206+
if (pmt_crashlog_disabled(&entry->entry))
207+
return -EBUSY;
208+
209+
pmt_crashlog_set_execute(&entry->entry);
210+
211+
return count;
213212
}
214213
static DEVICE_ATTR_RW(trigger);
215214

0 commit comments

Comments
 (0)