|
9 | 9 | */
|
10 | 10 |
|
11 | 11 | #include <linux/auxiliary_bus.h>
|
| 12 | +#include <linux/cleanup.h> |
12 | 13 | #include <linux/intel_vsec.h>
|
13 | 14 | #include <linux/kernel.h>
|
14 | 15 | #include <linux/module.h>
|
@@ -156,9 +157,9 @@ enable_store(struct device *dev, struct device_attribute *attr,
|
156 | 157 | if (result)
|
157 | 158 | return result;
|
158 | 159 |
|
159 |
| - mutex_lock(&entry->control_mutex); |
| 160 | + guard(mutex)(&entry->control_mutex); |
| 161 | + |
160 | 162 | pmt_crashlog_set_disable(&entry->entry, !enabled);
|
161 |
| - mutex_unlock(&entry->control_mutex); |
162 | 163 |
|
163 | 164 | return count;
|
164 | 165 | }
|
@@ -190,26 +191,24 @@ trigger_store(struct device *dev, struct device_attribute *attr,
|
190 | 191 | if (result)
|
191 | 192 | return result;
|
192 | 193 |
|
193 |
| - mutex_lock(&entry->control_mutex); |
| 194 | + guard(mutex)(&entry->control_mutex); |
194 | 195 |
|
195 | 196 | if (!trigger) {
|
196 | 197 | 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; |
207 | 199 | }
|
208 | 200 |
|
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; |
213 | 212 | }
|
214 | 213 | static DEVICE_ATTR_RW(trigger);
|
215 | 214 |
|
|
0 commit comments