[PATCH net-next 05/13] sunhme: Regularize probe errors

From: Sean Anderson
Date: Sun Sep 18 2022 - 19:27:04 EST


This fixes several error paths to ensure they return an appropriate error
(instead of ENODEV).

Signed-off-by: Sean Anderson <seanga2@xxxxxxxxx>
---

drivers/net/ethernet/sun/sunhme.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 52247505d08e..f0b77bdf51dd 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -2948,7 +2948,6 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
if (err)
goto err_out;
pci_set_master(pdev);
- err = -ENODEV;

if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) {
qp = quattro_pci_find(pdev);
@@ -2985,18 +2984,22 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
}

hpreg_res = pci_resource_start(pdev, 0);
- err = -ENODEV;
+ err = -EINVAL;
if ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) != 0) {
printk(KERN_ERR "happymeal(PCI): Cannot find proper PCI device base address.\n");
goto err_out_clear_quattro;
}
- if (pci_request_regions(pdev, DRV_NAME)) {
+
+ err = pci_request_regions(pdev, DRV_NAME);
+ if (err) {
printk(KERN_ERR "happymeal(PCI): Cannot obtain PCI resources, "
"aborting.\n");
goto err_out_clear_quattro;
}

- if ((hpreg_base = ioremap(hpreg_res, 0x8000)) == NULL) {
+ hpreg_base = ioremap(hpreg_res, 0x8000);
+ err = -ENOMEM;
+ if (!hpreg_base) {
printk(KERN_ERR "happymeal(PCI): Unable to remap card memory.\n");
goto err_out_free_res;
}
@@ -3066,7 +3069,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,

hp->happy_block = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
&hp->hblock_dvma, GFP_KERNEL);
- err = -ENODEV;
+ err = -ENOMEM;
if (!hp->happy_block)
goto err_out_iounmap;

--
2.37.1