Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

i3c: mipi-i3c-hci-pci: Add exit callback

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>
Link: https://patch.msgid.link/20251128064038.55158-11-adrian.hunter@intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Adrian Hunter and committed by
Alexandre Belloni
040dcd76 0f9ef14b

+12 -5
+12 -5
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
··· 17 17 struct mipi_i3c_hci_pci { 18 18 struct pci_dev *pci; 19 19 struct platform_device *pdev; 20 + const struct mipi_i3c_hci_pci_info *info; 20 21 }; 21 22 22 23 struct mipi_i3c_hci_pci_info { 23 24 int (*init)(struct mipi_i3c_hci_pci *hci); 25 + void (*exit)(struct mipi_i3c_hci_pci *hci); 24 26 }; 25 27 26 28 static DEFINE_IDA(mipi_i3c_hci_pci_ida); ··· 74 72 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci, 75 73 const struct pci_device_id *id) 76 74 { 77 - const struct mipi_i3c_hci_pci_info *info; 78 75 struct mipi_i3c_hci_pci *hci; 79 76 struct resource res[2]; 80 77 int dev_id, ret; ··· 115 114 if (ret) 116 115 goto err; 117 116 118 - info = (const struct mipi_i3c_hci_pci_info *)id->driver_data; 119 - if (info && info->init) { 120 - ret = info->init(hci); 117 + hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data; 118 + if (hci->info && hci->info->init) { 119 + ret = hci->info->init(hci); 121 120 if (ret) 122 121 goto err; 123 122 } 124 123 125 124 ret = platform_device_add(hci->pdev); 126 125 if (ret) 127 - goto err; 126 + goto err_exit; 128 127 129 128 pci_set_drvdata(pci, hci); 130 129 131 130 return 0; 132 131 132 + err_exit: 133 + if (hci->info && hci->info->exit) 134 + hci->info->exit(hci); 133 135 err: 134 136 platform_device_put(hci->pdev); 135 137 ida_free(&mipi_i3c_hci_pci_ida, dev_id); ··· 144 140 struct mipi_i3c_hci_pci *hci = pci_get_drvdata(pci); 145 141 struct platform_device *pdev = hci->pdev; 146 142 int dev_id = pdev->id; 143 + 144 + if (hci->info && hci->info->exit) 145 + hci->info->exit(hci); 147 146 148 147 platform_device_unregister(pdev); 149 148 ida_free(&mipi_i3c_hci_pci_ida, dev_id);