* [PATCH 1/2] misc: cardreader: Use non-hybrid PCI devres API
@ 2025-04-17 9:15 Philipp Stanner
2025-04-17 9:15 ` [PATCH 2/2] misc: cardreader: Return -EBUSY if regions are busy Philipp Stanner
0 siblings, 1 reply; 2+ messages in thread
From: Philipp Stanner @ 2025-04-17 9:15 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Philipp Stanner, Desnes Nunes
Cc: linux-kernel
cardreader enables its PCI device with pcim_enable_device(). This,
implicitly, switches the function pci_request_regions() into managed
mode, where it becomes a devres function.
The PCI subsystem wants to remove this hybrid nature from its
interfaces. To do so, users of the aforementioned combination of
functions must be ported to non-hybrid functions.
Moreover, since both functions are already managed in this driver, the
calls to pci_release_regions() are unnecessary.
Remove the calls to pci_release_regions().
Replace the call to sometimes-managed pci_request_regions() with one to
the always-managed pcim_request_all_regions().
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
drivers/misc/cardreader/alcor_pci.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/misc/cardreader/alcor_pci.c b/drivers/misc/cardreader/alcor_pci.c
index a5549eaf52d0..43f08b0db742 100644
--- a/drivers/misc/cardreader/alcor_pci.c
+++ b/drivers/misc/cardreader/alcor_pci.c
@@ -121,7 +121,7 @@ static int alcor_pci_probe(struct pci_dev *pdev,
priv->cfg = cfg;
priv->irq = pdev->irq;
- ret = pci_request_regions(pdev, DRV_NAME_ALCOR_PCI);
+ ret = pcim_request_all_regions(pdev, DRV_NAME_ALCOR_PCI);
if (ret) {
dev_err(&pdev->dev, "Cannot request region\n");
ret = -ENOMEM;
@@ -131,13 +131,13 @@ static int alcor_pci_probe(struct pci_dev *pdev,
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
ret = -ENODEV;
- goto error_release_regions;
+ goto error_free_ida;
}
priv->iobase = pcim_iomap(pdev, bar, 0);
if (!priv->iobase) {
ret = -ENOMEM;
- goto error_release_regions;
+ goto error_free_ida;
}
/* make sure irqs are disabled */
@@ -147,7 +147,7 @@ static int alcor_pci_probe(struct pci_dev *pdev,
ret = dma_set_mask_and_coherent(priv->dev, AU6601_SDMA_MASK);
if (ret) {
dev_err(priv->dev, "Failed to set DMA mask\n");
- goto error_release_regions;
+ goto error_free_ida;
}
pci_set_master(pdev);
@@ -169,8 +169,6 @@ static int alcor_pci_probe(struct pci_dev *pdev,
error_clear_drvdata:
pci_clear_master(pdev);
pci_set_drvdata(pdev, NULL);
-error_release_regions:
- pci_release_regions(pdev);
error_free_ida:
ida_free(&alcor_pci_idr, priv->id);
return ret;
@@ -186,7 +184,6 @@ static void alcor_pci_remove(struct pci_dev *pdev)
ida_free(&alcor_pci_idr, priv->id);
- pci_release_regions(pdev);
pci_clear_master(pdev);
pci_set_drvdata(pdev, NULL);
}
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 2/2] misc: cardreader: Return -EBUSY if regions are busy
2025-04-17 9:15 [PATCH 1/2] misc: cardreader: Use non-hybrid PCI devres API Philipp Stanner
@ 2025-04-17 9:15 ` Philipp Stanner
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Stanner @ 2025-04-17 9:15 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Philipp Stanner, Desnes Nunes
Cc: linux-kernel
cardreader returns -ENOMEM if a PCI region is currently in use
("requested") by another driver. The proper return code for this is
-EBUSY.
Replace -ENOMEM with -EBUSY.
Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
drivers/misc/cardreader/alcor_pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/cardreader/alcor_pci.c b/drivers/misc/cardreader/alcor_pci.c
index 43f08b0db742..8e7ea2c9142d 100644
--- a/drivers/misc/cardreader/alcor_pci.c
+++ b/drivers/misc/cardreader/alcor_pci.c
@@ -124,7 +124,7 @@ static int alcor_pci_probe(struct pci_dev *pdev,
ret = pcim_request_all_regions(pdev, DRV_NAME_ALCOR_PCI);
if (ret) {
dev_err(&pdev->dev, "Cannot request region\n");
- ret = -ENOMEM;
+ ret = -EBUSY;
goto error_free_ida;
}
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-17 9:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 9:15 [PATCH 1/2] misc: cardreader: Use non-hybrid PCI devres API Philipp Stanner
2025-04-17 9:15 ` [PATCH 2/2] misc: cardreader: Return -EBUSY if regions are busy Philipp Stanner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox