[PATCH 1/8] platform/x86: isst_if_mmio: switch to devm_mutex_init()

From: chitranshmandhaniya

Date: Fri Oct 30 2026 - 04:23:53 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>
---
.../platform/x86/intel/speed_select_if/isst_if_mmio.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c b/drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c
index 950ede5eab76..0a3fdf6b8bca 100644
--- a/drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c
+++ b/drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c
@@ -124,7 +124,9 @@ static int isst_if_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (IS_ERR(punit_dev->punit_mmio))
return PTR_ERR(punit_dev->punit_mmio);

- 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));
@@ -132,11 +134,7 @@ static int isst_if_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
cb.offset = offsetof(struct isst_if_io_regs, io_reg);
cb.cmd_callback = isst_if_mmio_rd_wr;
cb.owner = THIS_MODULE;
- ret = isst_if_cdev_register(ISST_IF_DEV_MMIO, &cb);
- if (ret)
- mutex_destroy(&punit_dev->mutex);
-
- return ret;
+ return isst_if_cdev_register(ISST_IF_DEV_MMIO, &cb);
}

static void isst_if_remove(struct pci_dev *pdev)
@@ -145,7 +143,6 @@ static void isst_if_remove(struct pci_dev *pdev)

punit_dev = pci_get_drvdata(pdev);
isst_if_cdev_unregister(ISST_IF_DEV_MMIO);
- mutex_destroy(&punit_dev->mutex);
}

static int __maybe_unused isst_if_suspend(struct device *device)
--
2.43.0