mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: chitranshmandhaniya@gmail.com
To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, Chitransh_Mandhaniya@dell.com,
	srinivas.pandruvada@linux.intel.com, david.e.box@linux.intel.com,
	irenic.rajneesh@gmail.com, qipeng.zha@intel.com
Subject: [PATCH 1/8] platform/x86: isst_if_mmio: switch to devm_mutex_init()
Date: Fri, 30 Oct 2026 13:52:55 +0530	[thread overview]
Message-ID: <20261030082303.284271-2-chitranshmandhaniya@gmail.com> (raw)
In-Reply-To: <20261030082303.284271-1-chitranshmandhaniya@gmail.com>

From: Chitransh Mandhaniya <Chitransh_Mandhaniya@dell.com>

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@dell.com>
---
 .../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


  reply	other threads:[~2026-10-30  8:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30  8:22 [PATCH 0/8] platform/x86: intel: switch remaining mutex_init() " chitranshmandhaniya
2026-10-30  8:22 ` chitranshmandhaniya [this message]
2026-10-30  8:22 ` [PATCH 2/8] platform/x86: isst_if_mbox_pci: switch " chitranshmandhaniya
2026-10-30  8:22 ` [PATCH 3/8] platform/x86: pmt_crashlog: " chitranshmandhaniya
2026-10-30  8:22 ` [PATCH 4/8] platform/x86: crystal_cove_charger: " chitranshmandhaniya
2026-10-30  8:22 ` [PATCH 5/8] platform/x86: telemetry/pltdrv: " chitranshmandhaniya
2026-10-30  8:23 ` [PATCH 6/8] platform/x86: ishtp_eclite: " chitranshmandhaniya
2026-10-30  8:23 ` [PATCH 7/8] platform/x86: punit_ipc: " chitranshmandhaniya
2026-10-30  8:23 ` [PATCH 8/8] platform/x86: sdsi: " chitranshmandhaniya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261030082303.284271-2-chitranshmandhaniya@gmail.com \
    --to=chitranshmandhaniya@gmail.com \
    --cc=Chitransh_Mandhaniya@dell.com \
    --cc=david.e.box@linux.intel.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=irenic.rajneesh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=qipeng.zha@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®