Skip to content

Commit 8320442

Browse files
committed
firewire: ohci: use devres for misc DMA buffer
The 1394 OHCI driver allocates a DMA coherent buffer for multi-purposes. The buffer is split into three region for specific purposes; i.e. 1/4 for context descriptors of AR request and response as well as 1/2 for self ID handling. This commit uses managed device resource to maintain the lifetime of buffer. Link: https://lore.kernel.org/r/20230604054451.161076-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent 086a0af commit 8320442

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

drivers/firewire/ohci.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,17 +3634,15 @@ static int pci_probe(struct pci_dev *dev,
36343634
*/
36353635
BUILD_BUG_ON(AR_BUFFERS * sizeof(struct descriptor) > PAGE_SIZE/4);
36363636
BUILD_BUG_ON(SELF_ID_BUF_SIZE > PAGE_SIZE/2);
3637-
ohci->misc_buffer = dma_alloc_coherent(ohci->card.device,
3638-
PAGE_SIZE,
3639-
&ohci->misc_buffer_bus,
3640-
GFP_KERNEL);
3637+
ohci->misc_buffer = dmam_alloc_coherent(&dev->dev, PAGE_SIZE, &ohci->misc_buffer_bus,
3638+
GFP_KERNEL);
36413639
if (!ohci->misc_buffer)
36423640
return -ENOMEM;
36433641

36443642
err = ar_context_init(&ohci->ar_request_ctx, ohci, 0,
36453643
OHCI1394_AsReqRcvContextControlSet);
36463644
if (err < 0)
3647-
goto fail_misc_buf;
3645+
return err;
36483646

36493647
err = ar_context_init(&ohci->ar_response_ctx, ohci, PAGE_SIZE/4,
36503648
OHCI1394_AsRspRcvContextControlSet);
@@ -3736,9 +3734,6 @@ static int pci_probe(struct pci_dev *dev,
37363734
ar_context_release(&ohci->ar_response_ctx);
37373735
fail_arreq_ctx:
37383736
ar_context_release(&ohci->ar_request_ctx);
3739-
fail_misc_buf:
3740-
dma_free_coherent(ohci->card.device, PAGE_SIZE,
3741-
ohci->misc_buffer, ohci->misc_buffer_bus);
37423737

37433738
return err;
37443739
}
@@ -3774,8 +3769,6 @@ static void pci_remove(struct pci_dev *dev)
37743769
ohci->config_rom, ohci->config_rom_bus);
37753770
ar_context_release(&ohci->ar_request_ctx);
37763771
ar_context_release(&ohci->ar_response_ctx);
3777-
dma_free_coherent(ohci->card.device, PAGE_SIZE,
3778-
ohci->misc_buffer, ohci->misc_buffer_bus);
37793772
context_release(&ohci->at_request_ctx);
37803773
context_release(&ohci->at_response_ctx);
37813774
kfree(ohci->it_context_list);

0 commit comments

Comments
 (0)