Skip to content

Commit 30d97fd

Browse files
committed
firewire: ohci: use devres for list of isochronous contexts
The 1394 OHCI driver allocates the list of isochronous contexts as much as the hardware supports. This commit utilizes managed device resource to maintain the lifetime of list. Link: https://lore.kernel.org/r/20230604054451.161076-7-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent 5a95f1d commit 30d97fd

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

drivers/firewire/ohci.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,7 +3666,11 @@ static int pci_probe(struct pci_dev *dev,
36663666
ohci->ir_context_mask = ohci->ir_context_support;
36673667
ohci->n_ir = hweight32(ohci->ir_context_mask);
36683668
size = sizeof(struct iso_context) * ohci->n_ir;
3669-
ohci->ir_context_list = kzalloc(size, GFP_KERNEL);
3669+
ohci->ir_context_list = devm_kzalloc(&dev->dev, size, GFP_KERNEL);
3670+
if (!ohci->ir_context_list) {
3671+
err = -ENOMEM;
3672+
goto fail_atresp_ctx;
3673+
}
36703674

36713675
reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0);
36723676
ohci->it_context_support = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet);
@@ -3679,11 +3683,10 @@ static int pci_probe(struct pci_dev *dev,
36793683
ohci->it_context_mask = ohci->it_context_support;
36803684
ohci->n_it = hweight32(ohci->it_context_mask);
36813685
size = sizeof(struct iso_context) * ohci->n_it;
3682-
ohci->it_context_list = kzalloc(size, GFP_KERNEL);
3683-
3684-
if (ohci->it_context_list == NULL || ohci->ir_context_list == NULL) {
3686+
ohci->it_context_list = devm_kzalloc(&dev->dev, size, GFP_KERNEL);
3687+
if (!ohci->it_context_list) {
36853688
err = -ENOMEM;
3686-
goto fail_contexts;
3689+
goto fail_atresp_ctx;
36873690
}
36883691

36893692
ohci->self_id = ohci->misc_buffer + PAGE_SIZE/2;
@@ -3721,9 +3724,7 @@ static int pci_probe(struct pci_dev *dev,
37213724

37223725
fail_msi:
37233726
pci_disable_msi(dev);
3724-
fail_contexts:
3725-
kfree(ohci->ir_context_list);
3726-
kfree(ohci->it_context_list);
3727+
fail_atresp_ctx:
37273728
context_release(&ohci->at_response_ctx);
37283729
fail_atreq_ctx:
37293730
context_release(&ohci->at_request_ctx);
@@ -3767,8 +3768,6 @@ static void pci_remove(struct pci_dev *dev)
37673768
ar_context_release(&ohci->ar_response_ctx);
37683769
context_release(&ohci->at_request_ctx);
37693770
context_release(&ohci->at_response_ctx);
3770-
kfree(ohci->it_context_list);
3771-
kfree(ohci->ir_context_list);
37723771
pci_disable_msi(dev);
37733772

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

0 commit comments

Comments
 (0)