Skip to content

Commit 086a0af

Browse files
committed
firewire: ohci: use devres for MMIO region mapping
The PCI framework has the convenient helper function to check and map MMIO region with managed device resource. This commit elaborates 1394 OHCI driver to use the function. Link: https://lore.kernel.org/r/20230604054451.161076-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent 14f6ca5 commit 086a0af

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

drivers/firewire/ohci.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3608,18 +3608,12 @@ static int pci_probe(struct pci_dev *dev,
36083608
return -ENXIO;
36093609
}
36103610

3611-
err = pci_request_region(dev, 0, ohci_driver_name);
3611+
err = pcim_iomap_regions(dev, 1 << 0, ohci_driver_name);
36123612
if (err) {
3613-
ohci_err(ohci, "MMIO resource unavailable\n");
3614-
return err;
3615-
}
3616-
3617-
ohci->registers = pci_iomap(dev, 0, OHCI1394_REGISTER_SIZE);
3618-
if (ohci->registers == NULL) {
3619-
ohci_err(ohci, "failed to remap registers\n");
3620-
err = -ENXIO;
3621-
goto fail_iomem;
3613+
ohci_err(ohci, "request and map MMIO resource unavailable\n");
3614+
return -ENXIO;
36223615
}
3616+
ohci->registers = pcim_iomap_table(dev)[0];
36233617

36243618
for (i = 0; i < ARRAY_SIZE(ohci_quirks); i++)
36253619
if ((ohci_quirks[i].vendor == dev->vendor) &&
@@ -3644,10 +3638,8 @@ static int pci_probe(struct pci_dev *dev,
36443638
PAGE_SIZE,
36453639
&ohci->misc_buffer_bus,
36463640
GFP_KERNEL);
3647-
if (!ohci->misc_buffer) {
3648-
err = -ENOMEM;
3649-
goto fail_iounmap;
3650-
}
3641+
if (!ohci->misc_buffer)
3642+
return -ENOMEM;
36513643

36523644
err = ar_context_init(&ohci->ar_request_ctx, ohci, 0,
36533645
OHCI1394_AsReqRcvContextControlSet);
@@ -3747,10 +3739,6 @@ static int pci_probe(struct pci_dev *dev,
37473739
fail_misc_buf:
37483740
dma_free_coherent(ohci->card.device, PAGE_SIZE,
37493741
ohci->misc_buffer, ohci->misc_buffer_bus);
3750-
fail_iounmap:
3751-
pci_iounmap(dev, ohci->registers);
3752-
fail_iomem:
3753-
pci_release_region(dev, 0);
37543742

37553743
return err;
37563744
}
@@ -3793,8 +3781,6 @@ static void pci_remove(struct pci_dev *dev)
37933781
kfree(ohci->it_context_list);
37943782
kfree(ohci->ir_context_list);
37953783
pci_disable_msi(dev);
3796-
pci_iounmap(dev, ohci->registers);
3797-
pci_release_region(dev, 0);
37983784

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

0 commit comments

Comments
 (0)