public inbox for linux-i3c@lists.infradead.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: alexandre.belloni@bootlin.com
Cc: Frank.Li@nxp.com, linux-i3c@lists.infradead.org
Subject: [PATCH V5 10/12] i3c: mipi-i3c-hci-pci: Add exit callback
Date: Fri, 28 Nov 2025 08:40:36 +0200	[thread overview]
Message-ID: <20251128064038.55158-11-adrian.hunter@intel.com> (raw)
In-Reply-To: <20251128064038.55158-1-adrian.hunter@intel.com>

Prepare to add device-specific features that require cleanup
upon driver removal.  Add ->exit() callback as a counterpart to ->init().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---


Changes in V5:

	Add missing call to ->exit() on error path

Changes in V4:

	Add Frank's Rev'd-by

Changes in V3:

	Improve commit message.

Changes in V2:

	Re-based


 .../i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c  | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
index 7bfb9fe337b6..7a91efbd3e54 100644
--- a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
+++ b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
@@ -17,10 +17,12 @@
 struct mipi_i3c_hci_pci {
 	struct pci_dev *pci;
 	struct platform_device *pdev;
+	const struct mipi_i3c_hci_pci_info *info;
 };
 
 struct mipi_i3c_hci_pci_info {
 	int (*init)(struct mipi_i3c_hci_pci *hci);
+	void (*exit)(struct mipi_i3c_hci_pci *hci);
 };
 
 static DEFINE_IDA(mipi_i3c_hci_pci_ida);
@@ -72,7 +74,6 @@ static const struct mipi_i3c_hci_pci_info intel_info = {
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 				  const struct pci_device_id *id)
 {
-	const struct mipi_i3c_hci_pci_info *info;
 	struct mipi_i3c_hci_pci *hci;
 	struct resource res[2];
 	int dev_id, ret;
@@ -114,21 +115,24 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (ret)
 		goto err;
 
-	info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
-	if (info && info->init) {
-		ret = info->init(hci);
+	hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
+	if (hci->info && hci->info->init) {
+		ret = hci->info->init(hci);
 		if (ret)
 			goto err;
 	}
 
 	ret = platform_device_add(hci->pdev);
 	if (ret)
-		goto err;
+		goto err_exit;
 
 	pci_set_drvdata(pci, hci);
 
 	return 0;
 
+err_exit:
+	if (hci->info && hci->info->exit)
+		hci->info->exit(hci);
 err:
 	platform_device_put(hci->pdev);
 	ida_free(&mipi_i3c_hci_pci_ida, dev_id);
@@ -141,6 +145,9 @@ static void mipi_i3c_hci_pci_remove(struct pci_dev *pci)
 	struct platform_device *pdev = hci->pdev;
 	int dev_id = pdev->id;
 
+	if (hci->info && hci->info->exit)
+		hci->info->exit(hci);
+
 	platform_device_unregister(pdev);
 	ida_free(&mipi_i3c_hci_pci_ida, dev_id);
 }
-- 
2.51.0


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  parent reply	other threads:[~2025-11-28  6:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-28  6:40 [PATCH V5 00/12] i3c: mipi-i3c-hci-pci: Add LTR support for Intel controllers Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 01/12] i3c: mipi-i3c-hci-pci: Set 64-bit DMA mask " Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 02/12] i3c: mipi-i3c-hci-pci: Move all Intel-related definitions together Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 03/12] i3c: mipi-i3c-hci-pci: Rename some Intel-related identifiers Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 04/12] i3c: mipi-i3c-hci-pci: Use readl_poll_timeout() Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 05/12] i3c: mipi-i3c-hci-pci: Constify driver data Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 06/12] i3c: mipi-i3c-hci-pci: Factor out private registers ioremapping Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 07/12] i3c: mipi-i3c-hci-pci: Factor out intel_reset() Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 08/12] i3c: mipi-i3c-hci-pci: Allocate a structure for mipi_i3c_hci_pci device information Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 09/12] i3c: mipi-i3c-hci-pci: Change callback parameter Adrian Hunter
2025-11-28  6:40 ` Adrian Hunter [this message]
2025-11-28  6:40 ` [PATCH V5 11/12] i3c: mipi-i3c-hci-pci: Add LTR support for Intel controllers Adrian Hunter
2025-11-28  6:40 ` [PATCH V5 12/12] i3c: mipi-i3c-hci-pci: Set d3cold_delay to 0 " Adrian Hunter
2025-11-28 23:17 ` [PATCH V5 00/12] i3c: mipi-i3c-hci-pci: Add LTR support " Alexandre Belloni

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=20251128064038.55158-11-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=Frank.Li@nxp.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-i3c@lists.infradead.org \
    /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