mirror of https://github.com/torvalds/linux.git
PCI: switchtec: Replace manual locks with guard
Replace lock/unlock pairs with guards to simplify and tidy up the code. Generated-by: Coccinelle SmPL Signed-off-by: Erick Karanja <karanja99erick@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Link: https://patch.msgid.link/20250828093556.810911-1-karanja99erick@gmail.com
This commit is contained in:
parent
8f5ae30d69
commit
f2543da14d
|
|
@ -269,10 +269,9 @@ static void mrpc_event_work(struct work_struct *work)
|
||||||
|
|
||||||
dev_dbg(&stdev->dev, "%s\n", __func__);
|
dev_dbg(&stdev->dev, "%s\n", __func__);
|
||||||
|
|
||||||
mutex_lock(&stdev->mrpc_mutex);
|
guard(mutex)(&stdev->mrpc_mutex);
|
||||||
cancel_delayed_work(&stdev->mrpc_timeout);
|
cancel_delayed_work(&stdev->mrpc_timeout);
|
||||||
mrpc_complete_cmd(stdev);
|
mrpc_complete_cmd(stdev);
|
||||||
mutex_unlock(&stdev->mrpc_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mrpc_error_complete_cmd(struct switchtec_dev *stdev)
|
static void mrpc_error_complete_cmd(struct switchtec_dev *stdev)
|
||||||
|
|
@ -1322,7 +1321,7 @@ static void stdev_kill(struct switchtec_dev *stdev)
|
||||||
cancel_delayed_work_sync(&stdev->mrpc_timeout);
|
cancel_delayed_work_sync(&stdev->mrpc_timeout);
|
||||||
|
|
||||||
/* Mark the hardware as unavailable and complete all completions */
|
/* Mark the hardware as unavailable and complete all completions */
|
||||||
mutex_lock(&stdev->mrpc_mutex);
|
scoped_guard (mutex, &stdev->mrpc_mutex) {
|
||||||
stdev->alive = false;
|
stdev->alive = false;
|
||||||
|
|
||||||
/* Wake up and kill any users waiting on an MRPC request */
|
/* Wake up and kill any users waiting on an MRPC request */
|
||||||
|
|
@ -1333,7 +1332,7 @@ static void stdev_kill(struct switchtec_dev *stdev)
|
||||||
stuser_put(stuser);
|
stuser_put(stuser);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&stdev->mrpc_mutex);
|
}
|
||||||
|
|
||||||
/* Wake up any users waiting on event_wq */
|
/* Wake up any users waiting on event_wq */
|
||||||
wake_up_interruptible(&stdev->event_wq);
|
wake_up_interruptible(&stdev->event_wq);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue