summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2026-01-13 09:26:48 +0200
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2026-01-14 17:21:09 +0100
commit29bf98a6346ad7a80136ba58116c2a0f8a3cb03f (patch)
tree6d64df7924af6efad69ddc97f0ddc815515aef44 /drivers
parent11d17c2855bfc04550557017eae02e92f3eeab1c (diff)
i3c: mipi-i3c-hci: Manage DMA deallocation via devres action
The driver already uses devres for resource management, but the standard resource-managed DMA allocation helpers cannot be used because they assume the DMA device matches the managed device. To address this, factor out the deallocation logic from hci_dma_cleanup() into a new helper, hci_dma_free(), and register it as a devres action. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20260113072702.16268-8-adrian.hunter@intel.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i3c/master/mipi-i3c-hci/dma.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c
index 54849aa98fad..4999cf3d9674 100644
--- a/drivers/i3c/master/mipi-i3c-hci/dma.c
+++ b/drivers/i3c/master/mipi-i3c-hci/dma.c
@@ -169,6 +169,22 @@ static void hci_dma_cleanup(struct i3c_hci *hci)
rh_reg_write(CR_SETUP, 0);
rh_reg_write(IBI_SETUP, 0);
+ }
+
+ rhs_reg_write(CONTROL, 0);
+}
+
+static void hci_dma_free(void *data)
+{
+ struct i3c_hci *hci = data;
+ struct hci_rings_data *rings = hci->io_data;
+ struct hci_rh_data *rh;
+
+ if (!rings)
+ return;
+
+ for (int i = 0; i < rings->total; i++) {
+ rh = &rings->headers[i];
if (rh->xfer)
dma_free_coherent(rings->sysdev,
@@ -190,8 +206,6 @@ static void hci_dma_cleanup(struct i3c_hci *hci)
kfree(rh->ibi_data);
}
- rhs_reg_write(CONTROL, 0);
-
kfree(rings);
hci->io_data = NULL;
}
@@ -359,10 +373,15 @@ ring_ready:
RING_CTRL_RUN_STOP);
}
+ ret = devm_add_action(hci->master.dev.parent, hci_dma_free, hci);
+ if (ret)
+ goto err_out;
+
return 0;
err_out:
hci_dma_cleanup(hci);
+ hci_dma_free(hci);
return ret;
}