[PATCH 07/17] i3c: mipi-i3c-hci: Manage DMA deallocation via devres action
Adrian Hunter
adrian.hunter at intel.com
Thu Jan 8 00:04:22 PST 2026
On 19/12/2025 18:32, Frank Li wrote:
> On Fri, Dec 19, 2025 at 04:45:24PM +0200, Adrian Hunter wrote:
>> 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 at intel.com>
>> ---
>> drivers/i3c/master/mipi-i3c-hci/dma.c | 53 ++++++++++++++++++---------
>> 1 file changed, 36 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c
>> index 54849aa98fad..703d5cf79d5e 100644
>> --- a/drivers/i3c/master/mipi-i3c-hci/dma.c
>> +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c
...
>> static int hci_dma_init(struct i3c_hci *hci)
>> {
>> struct hci_rings_data *rings;
>> @@ -359,10 +373,15 @@ static int hci_dma_init(struct i3c_hci *hci)
>> RING_CTRL_RUN_STOP);
>> }
>>
>> + ret = devm_add_action(hci->master.dev.parent, hci_dma_free, hci);
>> + if (ret)
>> + goto err_out;
>> +
>
> use devm_add_action_or_reset(), so needn't goto
It doesn't work because the error path needs to call hci_dma_cleanup()
before hci_dma_free()
>
> Frank
>> return 0;
>>
>> err_out:
>> hci_dma_cleanup(hci);
>> + hci_dma_free(hci);
>> return ret;
>> }
>>
>> --
>> 2.51.0
>>
>>
>> --
>> linux-i3c mailing list
>> linux-i3c at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-i3c
More information about the linux-i3c
mailing list