Skip to content

Commit aa71e28

Browse files
committed
firewire: ohci: use devres for IT, IR, AT/receive, and AT/request contexts
The 1394 OHCI driver allocates DMA coherent buffer for descriptors of IT, IR, AT receive, and AT request contexts by the same way. This commit utilizes managed device resource to maintain the lifetime of buffers. Link: https://lore.kernel.org/r/20230604054451.161076-8-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent 30d97fd commit aa71e28

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

drivers/firewire/ohci.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,7 @@ static int context_add_buffer(struct context *ctx)
11051105
if (ctx->total_allocation >= 16*1024*1024)
11061106
return -ENOMEM;
11071107

1108-
desc = dma_alloc_coherent(ctx->ohci->card.device, PAGE_SIZE,
1109-
&bus_addr, GFP_ATOMIC);
1108+
desc = dmam_alloc_coherent(ctx->ohci->card.device, PAGE_SIZE, &bus_addr, GFP_ATOMIC);
11101109
if (!desc)
11111110
return -ENOMEM;
11121111

@@ -1165,10 +1164,10 @@ static void context_release(struct context *ctx)
11651164
struct fw_card *card = &ctx->ohci->card;
11661165
struct descriptor_buffer *desc, *tmp;
11671166

1168-
list_for_each_entry_safe(desc, tmp, &ctx->buffer_list, list)
1169-
dma_free_coherent(card->device, PAGE_SIZE, desc,
1170-
desc->buffer_bus -
1171-
((void *)&desc->buffer - (void *)desc));
1167+
list_for_each_entry_safe(desc, tmp, &ctx->buffer_list, list) {
1168+
dmam_free_coherent(card->device, PAGE_SIZE, desc,
1169+
desc->buffer_bus - ((void *)&desc->buffer - (void *)desc));
1170+
}
11721171
}
11731172

11741173
/* Must be called with ohci->lock held */
@@ -3657,7 +3656,7 @@ static int pci_probe(struct pci_dev *dev,
36573656
err = context_init(&ohci->at_response_ctx, ohci,
36583657
OHCI1394_AsRspTrContextControlSet, handle_at_packet);
36593658
if (err < 0)
3660-
goto fail_atreq_ctx;
3659+
goto fail_arrsp_ctx;
36613660

36623661
reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0);
36633662
ohci->ir_context_channels = ~0ULL;
@@ -3669,7 +3668,7 @@ static int pci_probe(struct pci_dev *dev,
36693668
ohci->ir_context_list = devm_kzalloc(&dev->dev, size, GFP_KERNEL);
36703669
if (!ohci->ir_context_list) {
36713670
err = -ENOMEM;
3672-
goto fail_atresp_ctx;
3671+
goto fail_arrsp_ctx;
36733672
}
36743673

36753674
reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0);
@@ -3686,7 +3685,7 @@ static int pci_probe(struct pci_dev *dev,
36863685
ohci->it_context_list = devm_kzalloc(&dev->dev, size, GFP_KERNEL);
36873686
if (!ohci->it_context_list) {
36883687
err = -ENOMEM;
3689-
goto fail_atresp_ctx;
3688+
goto fail_arrsp_ctx;
36903689
}
36913690

36923691
ohci->self_id = ohci->misc_buffer + PAGE_SIZE/2;
@@ -3724,10 +3723,6 @@ static int pci_probe(struct pci_dev *dev,
37243723

37253724
fail_msi:
37263725
pci_disable_msi(dev);
3727-
fail_atresp_ctx:
3728-
context_release(&ohci->at_response_ctx);
3729-
fail_atreq_ctx:
3730-
context_release(&ohci->at_request_ctx);
37313726
fail_arrsp_ctx:
37323727
ar_context_release(&ohci->ar_response_ctx);
37333728
fail_arreq_ctx:
@@ -3766,8 +3761,6 @@ static void pci_remove(struct pci_dev *dev)
37663761
ohci->config_rom, ohci->config_rom_bus);
37673762
ar_context_release(&ohci->ar_request_ctx);
37683763
ar_context_release(&ohci->ar_response_ctx);
3769-
context_release(&ohci->at_request_ctx);
3770-
context_release(&ohci->at_response_ctx);
37713764
pci_disable_msi(dev);
37723765

37733766
dev_notice(&dev->dev, "removing fw-ohci device\n");

0 commit comments

Comments
 (0)