[PATCH 2/8] platform/x86: isst_if_mbox_pci: switch to devm_mutex_init()
From: chitranshmandhaniya
Date: Fri Oct 30 2026 - 04:24:03 EST
From: Chitransh Mandhaniya <Chitransh_Mandhaniya@xxxxxxxx>
Replace mutex_init() with devm_mutex_init() so the mutex lifecycle is
managed by devres. This removes the need for manual mutex_destroy()
calls in both the error path and the remove callback.
Since the only action on cdev_register failure was mutex_destroy(),
simplify the tail of the probe function to return the registration
result directly.
Signed-off-by: Chitransh Mandhaniya <Chitransh_Mandhaniya@xxxxxxxx>
---
.../x86/intel/speed_select_if/isst_if_mbox_pci.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/intel/speed_select_if/isst_if_mbox_pci.c b/drivers/platform/x86/intel/speed_select_if/isst_if_mbox_pci.c
index df1fc6c719f3..ea0b396d35cf 100644
--- a/drivers/platform/x86/intel/speed_select_if/isst_if_mbox_pci.c
+++ b/drivers/platform/x86/intel/speed_select_if/isst_if_mbox_pci.c
@@ -180,7 +180,9 @@ static int isst_if_mbox_probe(struct pci_dev *pdev,
if (ret)
return ret;
- mutex_init(&punit_dev->mutex);
+ ret = devm_mutex_init(&pdev->dev, &punit_dev->mutex);
+ if (ret)
+ return ret;
pci_set_drvdata(pdev, punit_dev);
memset(&cb, 0, sizeof(cb));
@@ -188,12 +190,7 @@ static int isst_if_mbox_probe(struct pci_dev *pdev,
cb.offset = offsetof(struct isst_if_mbox_cmds, mbox_cmd);
cb.cmd_callback = isst_if_mbox_proc_cmd;
cb.owner = THIS_MODULE;
- ret = isst_if_cdev_register(ISST_IF_DEV_MBOX, &cb);
-
- if (ret)
- mutex_destroy(&punit_dev->mutex);
-
- return ret;
+ return isst_if_cdev_register(ISST_IF_DEV_MBOX, &cb);
}
static void isst_if_mbox_remove(struct pci_dev *pdev)
@@ -202,7 +199,6 @@ static void isst_if_mbox_remove(struct pci_dev *pdev)
punit_dev = pci_get_drvdata(pdev);
isst_if_cdev_unregister(ISST_IF_DEV_MBOX);
- mutex_destroy(&punit_dev->mutex);
}
static int __maybe_unused isst_if_resume(struct device *device)
--
2.43.0