platform/x86: intel: switch remaining mutex_init() to devm_mutex_init()
Subsystems (7)
cover platform/x86: intel: switch remaining mutex_init() to devm_mutex_init()
From: Chitransh Mandhaniya <[email protected]>
Convert the remaining mutex_init() calls under drivers/platform/x86/intel/ to devm_mutex_init() so the mutex lifecycle is managed by devres. This removes the need for manual mutex_destroy() calls and fixes several drivers that were missing mutex_destroy() on the teardown path entirely.
Each patch converts one driver and is independent of the others.
Build-tested on x86_64 with all eight drivers compiled in.
Chitransh Mandhaniya (8):
platform/x86: isst_if_mmio: switch to devm_mutex_init() platform/x86: isst_if_mbox_pci: switch to devm_mutex_init() platform/x86: pmt_crashlog: switch to devm_mutex_init() platform/x86: crystal_cove_charger: switch to devm_mutex_init() platform/x86: telemetry/pltdrv: switch to devm_mutex_init() platform/x86: ishtp_eclite: switch to devm_mutex_init() platform/x86: punit_ipc: switch to devm_mutex_init() platform/x86: sdsi: switch to devm_mutex_init()
drivers/platform/x86/intel/crystal_cove_charger.c | 4 +++- drivers/platform/x86/intel/ishtp_eclite.c | 4 +++- drivers/platform/x86/intel/pmt/crashlog.c | 6 ++++-- drivers/platform/x86/intel/punit_ipc.c | 4 +++- drivers/platform/x86/intel/sdsi.c | 4 +++- .../x86/intel/speed_select_if/isst_if_mbox_pci.c | 12 ++++-------- .../x86/intel/speed_select_if/isst_if_mmio.c | 11 ++++------- drivers/platform/x86/intel/telemetry/pltdrv.c | 8 ++++++-- 8 files changed, 30 insertions(+), 23 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/8 platform/x86: isst_if_mmio: switch to devm_mutex_init()
From: Chitransh Mandhaniya <[email protected]>
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.
--- .../platform/x86/intel/speed_select_if/isst_if_mmio.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c +4 -7
@@ -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)
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH 1/8] platform/x86: isst_if_mmio: switch to devm_mutex_init()
kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v7.3 next-20261030]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/chitranshmandhaniya-gmail-com/platform-x86-isst_if_mmio-switch-to-devm_mutex_init/20261030-135255 base: linus/master patch link: https://lore.kernel.org/r/20261030082303.284271-2-chitranshmandhaniya%40gmail.com patch subject: [PATCH 1/8] platform/x86: isst_if_mmio: switch to devm_mutex_init() config: x86_64-randconfig-1001-20261031 (https://download.01.org/0day-ci/archive/20261031/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c: In function 'isst_if_remove':
>> drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c:142:32: warning: variable 'punit_dev' set but not used [-Wunused-but-set-variable]
142 | struct isst_if_device *punit_dev;
| ^~~~~~~~~vim +/punit_dev +142 drivers/platform/x86/intel/speed_select_if/isst_if_mmio.c
d3a23584294c1f drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2019-06-26 139
d3a23584294c1f drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2019-06-26 140 static void isst_if_remove(struct pci_dev *pdev)
d3a23584294c1f drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2019-06-26 141 {
d3a23584294c1f drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2019-06-26 @142 struct isst_if_device *punit_dev;
d3a23584294c1f drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2019-06-26 143
d3a23584294c1f drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2019-06-26 144 punit_dev = pci_get_drvdata(pdev);
6cc8f6598978b8 drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2020-03-03 145 isst_if_cdev_unregister(ISST_IF_DEV_MMIO);
d3a23584294c1f drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2019-06-26 146 }
d3a23584294c1f drivers/platform/x86/intel_speed_select_if/isst_if_mmio.c Srinivas Pandruvada 2019-06-26 147 --
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
PATCH 2/8 platform/x86: isst_if_mbox_pci: switch to devm_mutex_init()
In reply to [email protected]From: Chitransh Mandhaniya <[email protected]>
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.
--- .../x86/intel/speed_select_if/isst_if_mbox_pci.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/platform/x86/intel/speed_select_if/isst_if_mbox_pci.c +4 -8
@@ -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)
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH 2/8] platform/x86: isst_if_mbox_pci: switch to devm_mutex_init()
kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v7.3 next-20261030]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/chitranshmandhaniya-gmail-com/platform-x86-isst_if_mmio-switch-to-devm_mutex_init/20261030-135255 base: linus/master patch link: https://lore.kernel.org/r/20261030082303.284271-3-chitranshmandhaniya%40gmail.com patch subject: [PATCH 2/8] platform/x86: isst_if_mbox_pci: switch to devm_mutex_init() config: x86_64-randconfig-1001-20261031 (https://download.01.org/0day-ci/archive/20261031/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/platform/x86/intel/speed_select_if/isst_if_mbox_pci.c: In function 'isst_if_mbox_remove':
>> drivers/platform/x86/intel/speed_select_if/isst_if_mbox_pci.c:198:32: warning: variable 'punit_dev' set but not used [-Wunused-but-set-variable]
198 | struct isst_if_device *punit_dev;
| ^~~~~~~~~vim +/punit_dev +198 drivers/platform/x86/intel/speed_select_if/isst_if_mbox_pci.c
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 195
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 196 static void isst_if_mbox_remove(struct pci_dev *pdev)
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 197 {
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 @198 struct isst_if_device *punit_dev;
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 199
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 200 punit_dev = pci_get_drvdata(pdev);
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 201 isst_if_cdev_unregister(ISST_IF_DEV_MBOX);
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 202 }
31a166fe9c269af drivers/platform/x86/intel_speed_select_if/isst_if_mbox_pci.c Srinivas Pandruvada 2019-06-26 203 --
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
PATCH 3/8 platform/x86: pmt_crashlog: switch to devm_mutex_init()
In reply to [email protected]From: Chitransh Mandhaniya <[email protected]>
Replace mutex_init() with devm_mutex_init() so the mutex lifecycle is managed by devres. This removes the need for the manual mutex_destroy() call in pmt_crashlog_remove().
--- drivers/platform/x86/intel/pmt/crashlog.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/pmt/crashlog.c +4 -2
@@ -591,13 +591,16 @@ static int pmt_crashlog_pre_decode(struct intel_vsec_device *ivdev,struct crashlog_entry *crashlog;u32 version;u32 type; +int ret;if (!pmt_crashlog_supported (entry, &type, &version))return 1 ;/* initialize the crashlog struct */ crashlog = container_of(entry, struct crashlog_entry, entry); -mutex_init (&crashlog->control_mutex); + ret =devm_mutex_init (&ivdev->auxdev.dev, &crashlog->control_mutex); +if (ret) +return ret; crashlog->info =select_crashlog_info (type, version); entry->attr_grp = crashlog->info->attr_grp;
@@ -641,7 +644,6 @@ static void pmt_crashlog_remove(struct auxiliary_device *auxdev)struct crashlog_entry *crashlog = &priv->entry[i];intel_pmt_dev_destroy (&crashlog->entry, &pmt_crashlog_ns); -mutex_destroy (&crashlog->control_mutex); } }
Signature · 1 line
2.43.0
PATCH 4/8 platform/x86: crystal_cove_charger: switch to devm_mutex_init()
In reply to [email protected]From: Chitransh Mandhaniya <[email protected]>
Replace mutex_init() with devm_mutex_init() so the mutex is automatically destroyed on driver removal via devres. The driver was missing a mutex_destroy() call on the teardown path.
--- drivers/platform/x86/intel/crystal_cove_charger.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/crystal_cove_charger.c +3 -1
@@ -94,7 +94,9 @@ static int crystal_cove_charger_probe(struct platform_device *pdev)return -ENOMEM ; charger->regmap = pmic->regmap; -mutex_init (&charger->buslock); + ret =devm_mutex_init (&pdev->dev, &charger->buslock); +if (ret) +return ret; charger->irq =platform_get_irq (pdev,0 );if (charger->irq <0 )
Signature · 1 line
2.43.0
PATCH 5/8 platform/x86: telemetry/pltdrv: switch to devm_mutex_init()
In reply to [email protected]From: Chitransh Mandhaniya <[email protected]>
Replace mutex_init() with devm_mutex_init() for both telem_lock and telem_trace_lock so the mutex lifecycle is managed by devres. The driver was missing mutex_destroy() calls on the teardown path.
--- drivers/platform/x86/intel/telemetry/pltdrv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/telemetry/pltdrv.c +6 -2
@@ -904,8 +904,12 @@ static int telemetry_pltdrv_probe(struct platform_device *pdev) goto out; } -mutex_init (&telm_conf->telem_lock); -mutex_init (&telm_conf->telem_trace_lock); + ret =devm_mutex_init (&pdev->dev, &telm_conf->telem_lock); +if (ret) + goto out; + ret =devm_mutex_init (&pdev->dev, &telm_conf->telem_trace_lock); +if (ret) + goto out; ret =telemetry_setup (pdev);if (ret)
Signature · 1 line
2.43.0
PATCH 6/8 platform/x86: ishtp_eclite: switch to devm_mutex_init()
In reply to [email protected]From: Chitransh Mandhaniya <[email protected]>
Replace mutex_init() with devm_mutex_init() so the mutex is automatically destroyed on driver removal via devres. The driver was missing a mutex_destroy() call on the teardown path.
--- drivers/platform/x86/intel/ishtp_eclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/ishtp_eclite.c +3 -1
@@ -585,7 +585,9 @@ static int ecl_ishtp_cl_probe(struct ishtp_cl_device *cl_device)dev_dbg (cl_data_to_dev (opr_dev),"eclite-ishtp client initialised\n" ); opr_dev->ish_link_ready = true; -mutex_init (&opr_dev->lock); + rv =devm_mutex_init (ishtp_device (cl_device), &opr_dev->lock); +if (rv) + goto err_exit; rv =acpi_find_eclite_device (opr_dev);if (rv) {
Signature · 1 line
2.43.0
PATCH 7/8 platform/x86: punit_ipc: switch to devm_mutex_init()
In reply to [email protected]From: Chitransh Mandhaniya <[email protected]>
Replace mutex_init() with devm_mutex_init() so the mutex is automatically destroyed on driver removal via devres. The driver was missing a mutex_destroy() call on the teardown path.
--- drivers/platform/x86/intel/punit_ipc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/punit_ipc.c +3 -1
@@ -260,7 +260,9 @@ static int intel_punit_ipc_probe(struct platform_device *pdev)return ret; punit_ipcdev->dev = &pdev->dev; -mutex_init (&punit_ipcdev->lock); + ret =devm_mutex_init (&pdev->dev, &punit_ipcdev->lock); +if (ret) +return ret;init_completion (&punit_ipcdev->cmd_complete);return 0 ;
Signature · 1 line
2.43.0
PATCH 8/8 platform/x86: sdsi: switch to devm_mutex_init()
In reply to [email protected]From: Chitransh Mandhaniya <[email protected]>
Replace mutex_init() with devm_mutex_init() so the mutex is automatically destroyed on driver removal via devres. The driver was missing a mutex_destroy() call on the teardown path.
--- drivers/platform/x86/intel/sdsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/sdsi.c +3 -1
@@ -663,7 +663,9 @@ static int sdsi_probe(struct auxiliary_device *auxdev, const struct auxiliary_dereturn -ENOMEM ; priv->dev = &auxdev->dev; -mutex_init (&priv->mb_lock); + ret =devm_mutex_init (&auxdev->dev, &priv->mb_lock); +if (ret) +return ret;auxiliary_set_drvdata (auxdev, priv);/* Get the SDSi discovery table */
Signature · 1 line
2.43.0