Skip to content

Commit 9155399

Browse files
committed
Merge branch 'pci/switchtec'
- Replace manual locks with guard to simplify code (Erick Karanja) * pci/switchtec: PCI: switchtec: Replace manual locks with guard
2 parents 3d56c86 + f2543da commit 9155399

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

drivers/pci/switch/switchtec.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,9 @@ static void mrpc_event_work(struct work_struct *work)
269269

270270
dev_dbg(&stdev->dev, "%s\n", __func__);
271271

272-
mutex_lock(&stdev->mrpc_mutex);
272+
guard(mutex)(&stdev->mrpc_mutex);
273273
cancel_delayed_work(&stdev->mrpc_timeout);
274274
mrpc_complete_cmd(stdev);
275-
mutex_unlock(&stdev->mrpc_mutex);
276275
}
277276

278277
static void mrpc_error_complete_cmd(struct switchtec_dev *stdev)
@@ -1322,18 +1321,18 @@ static void stdev_kill(struct switchtec_dev *stdev)
13221321
cancel_delayed_work_sync(&stdev->mrpc_timeout);
13231322

13241323
/* Mark the hardware as unavailable and complete all completions */
1325-
mutex_lock(&stdev->mrpc_mutex);
1326-
stdev->alive = false;
1327-
1328-
/* Wake up and kill any users waiting on an MRPC request */
1329-
list_for_each_entry_safe(stuser, tmpuser, &stdev->mrpc_queue, list) {
1330-
stuser->cmd_done = true;
1331-
wake_up_interruptible(&stuser->cmd_comp);
1332-
list_del_init(&stuser->list);
1333-
stuser_put(stuser);
1334-
}
1324+
scoped_guard (mutex, &stdev->mrpc_mutex) {
1325+
stdev->alive = false;
1326+
1327+
/* Wake up and kill any users waiting on an MRPC request */
1328+
list_for_each_entry_safe(stuser, tmpuser, &stdev->mrpc_queue, list) {
1329+
stuser->cmd_done = true;
1330+
wake_up_interruptible(&stuser->cmd_comp);
1331+
list_del_init(&stuser->list);
1332+
stuser_put(stuser);
1333+
}
13351334

1336-
mutex_unlock(&stdev->mrpc_mutex);
1335+
}
13371336

13381337
/* Wake up any users waiting on event_wq */
13391338
wake_up_interruptible(&stdev->event_wq);

0 commit comments

Comments
 (0)