Commit 48944738 authored by David Vrabel's avatar David Vrabel Committed by Greg Kroah-Hartman

[PATCH] handle errors returned by platform_get_irq*()

platform_get_irq*() now returns on -ENXIO when the resource cannot be
found.  Ensure all users of platform_get_irq*() handle this error
appropriately.
Signed-off-by: default avatarDavid Vrabel <dvrabel@arcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 305b3228
...@@ -788,6 +788,8 @@ static int locomo_probe(struct platform_device *dev) ...@@ -788,6 +788,8 @@ static int locomo_probe(struct platform_device *dev)
if (!mem) if (!mem)
return -EINVAL; return -EINVAL;
irq = platform_get_irq(dev, 0); irq = platform_get_irq(dev, 0);
if (irq < 0)
return -ENXIO;
return __locomo_probe(&dev->dev, mem, irq); return __locomo_probe(&dev->dev, mem, irq);
} }
......
...@@ -943,6 +943,8 @@ static int sa1111_probe(struct platform_device *pdev) ...@@ -943,6 +943,8 @@ static int sa1111_probe(struct platform_device *pdev)
if (!mem) if (!mem)
return -EINVAL; return -EINVAL;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0)
return -ENXIO;
return __sa1111_probe(&pdev->dev, mem, irq); return __sa1111_probe(&pdev->dev, mem, irq);
} }
......
...@@ -448,13 +448,13 @@ static int s3c2410_rtc_probe(struct platform_device *pdev) ...@@ -448,13 +448,13 @@ static int s3c2410_rtc_probe(struct platform_device *pdev)
/* find the IRQs */ /* find the IRQs */
s3c2410_rtc_tickno = platform_get_irq(pdev, 1); s3c2410_rtc_tickno = platform_get_irq(pdev, 1);
if (s3c2410_rtc_tickno <= 0) { if (s3c2410_rtc_tickno < 0) {
dev_err(&pdev->dev, "no irq for rtc tick\n"); dev_err(&pdev->dev, "no irq for rtc tick\n");
return -ENOENT; return -ENOENT;
} }
s3c2410_rtc_alarmno = platform_get_irq(pdev, 0); s3c2410_rtc_alarmno = platform_get_irq(pdev, 0);
if (s3c2410_rtc_alarmno <= 0) { if (s3c2410_rtc_alarmno < 0) {
dev_err(&pdev->dev, "no irq for alarm\n"); dev_err(&pdev->dev, "no irq for alarm\n");
return -ENOENT; return -ENOENT;
} }
......
...@@ -338,6 +338,10 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev) ...@@ -338,6 +338,10 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev)
wdt->dev = &dev->dev; wdt->dev = &dev->dev;
wdt->irq = platform_get_irq(dev, 0); wdt->irq = platform_get_irq(dev, 0);
if (wdt->irq < 0) {
ret = -ENXIO;
goto err_free;
}
wdt->base = ioremap(res->start, res->end - res->start + 1); wdt->base = ioremap(res->start, res->end - res->start + 1);
if (!wdt->base) { if (!wdt->base) {
ret = -ENOMEM; ret = -ENOMEM;
......
...@@ -434,7 +434,7 @@ static int ...@@ -434,7 +434,7 @@ static int
iop3xx_i2c_probe(struct platform_device *pdev) iop3xx_i2c_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *res;
int ret; int ret, irq;
struct i2c_adapter *new_adapter; struct i2c_adapter *new_adapter;
struct i2c_algo_iop3xx_data *adapter_data; struct i2c_algo_iop3xx_data *adapter_data;
...@@ -470,7 +470,12 @@ iop3xx_i2c_probe(struct platform_device *pdev) ...@@ -470,7 +470,12 @@ iop3xx_i2c_probe(struct platform_device *pdev)
goto release_region; goto release_region;
} }
ret = request_irq(platform_get_irq(pdev, 0), iop3xx_i2c_irq_handler, 0, irq = platform_get_irq(pdev, 0);
if (irq < 0) {
ret = -ENXIO;
goto unmap;
}
ret = request_irq(irq, iop3xx_i2c_irq_handler, 0,
pdev->name, adapter_data); pdev->name, adapter_data);
if (ret) { if (ret) {
......
...@@ -302,6 +302,10 @@ static int fsl_i2c_probe(struct platform_device *pdev) ...@@ -302,6 +302,10 @@ static int fsl_i2c_probe(struct platform_device *pdev)
} }
i2c->irq = platform_get_irq(pdev, 0); i2c->irq = platform_get_irq(pdev, 0);
if (i2c->irq < 0) {
result = -ENXIO;
goto fail_get_irq;
}
i2c->flags = pdata->device_flags; i2c->flags = pdata->device_flags;
init_waitqueue_head(&i2c->queue); init_waitqueue_head(&i2c->queue);
...@@ -340,6 +344,7 @@ static int fsl_i2c_probe(struct platform_device *pdev) ...@@ -340,6 +344,7 @@ static int fsl_i2c_probe(struct platform_device *pdev)
fail_irq: fail_irq:
iounmap(i2c->base); iounmap(i2c->base);
fail_map: fail_map:
fail_get_irq:
kfree(i2c); kfree(i2c);
return result; return result;
}; };
......
...@@ -516,6 +516,10 @@ mv64xxx_i2c_probe(struct platform_device *pd) ...@@ -516,6 +516,10 @@ mv64xxx_i2c_probe(struct platform_device *pd)
drv_data->freq_m = pdata->freq_m; drv_data->freq_m = pdata->freq_m;
drv_data->freq_n = pdata->freq_n; drv_data->freq_n = pdata->freq_n;
drv_data->irq = platform_get_irq(pd, 0); drv_data->irq = platform_get_irq(pd, 0);
if (drv_data->irq < 0) {
rc = -ENXIO;
goto exit_unmap_regs;
}
drv_data->adapter.id = I2C_HW_MV64XXX; drv_data->adapter.id = I2C_HW_MV64XXX;
drv_data->adapter.algo = &mv64xxx_i2c_algo; drv_data->adapter.algo = &mv64xxx_i2c_algo;
drv_data->adapter.owner = THIS_MODULE; drv_data->adapter.owner = THIS_MODULE;
......
...@@ -674,6 +674,11 @@ static int au_ide_probe(struct device *dev) ...@@ -674,6 +674,11 @@ static int au_ide_probe(struct device *dev)
ret = -ENODEV; ret = -ENODEV;
goto out; goto out;
} }
if (ahwif->irq < 0) {
pr_debug("%s %d: no IRQ\n", DRV_NAME, pdev->id);
ret = -ENODEV;
goto out;
}
if (!request_mem_region (res->start, res->end-res->start, pdev->name)) { if (!request_mem_region (res->start, res->end-res->start, pdev->name)) {
pr_debug("%s: request_mem_region failed\n", DRV_NAME); pr_debug("%s: request_mem_region failed\n", DRV_NAME);
......
...@@ -438,7 +438,7 @@ static int pxamci_probe(struct platform_device *pdev) ...@@ -438,7 +438,7 @@ static int pxamci_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (!r || irq == NO_IRQ) if (!r || irq < 0)
return -ENXIO; return -ENXIO;
r = request_mem_region(r->start, SZ_4K, DRIVER_NAME); r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
......
...@@ -696,7 +696,9 @@ static int __init am79c961_probe(struct platform_device *pdev) ...@@ -696,7 +696,9 @@ static int __init am79c961_probe(struct platform_device *pdev)
dev->base_addr = res->start; dev->base_addr = res->start;
dev->irq = platform_get_irq(pdev, 0); dev->irq = platform_get_irq(pdev, 0);
ret = -ENODEV; ret = -ENODEV;
if (dev->irq < 0)
goto nodev;
if (!request_region(dev->base_addr, 0x18, dev->name)) if (!request_region(dev->base_addr, 0x18, dev->name))
goto nodev; goto nodev;
......
...@@ -118,6 +118,8 @@ static int do_pd_setup(struct fs_enet_private *fep) ...@@ -118,6 +118,8 @@ static int do_pd_setup(struct fs_enet_private *fep)
/* Fill out IRQ field */ /* Fill out IRQ field */
fep->interrupt = platform_get_irq(pdev, 0); fep->interrupt = platform_get_irq(pdev, 0);
if (fep->interrupt < 0)
return -EINVAL;
/* Attach the memory for the FCC Parameter RAM */ /* Attach the memory for the FCC Parameter RAM */
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_pram"); r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_pram");
......
...@@ -144,6 +144,8 @@ static int do_pd_setup(struct fs_enet_private *fep) ...@@ -144,6 +144,8 @@ static int do_pd_setup(struct fs_enet_private *fep)
/* Fill out IRQ field */ /* Fill out IRQ field */
fep->interrupt = platform_get_irq_byname(pdev,"interrupt"); fep->interrupt = platform_get_irq_byname(pdev,"interrupt");
if (fep->interrupt < 0)
return -EINVAL;
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
fep->fec.fecp =(void*)r->start; fep->fec.fecp =(void*)r->start;
......
...@@ -118,6 +118,8 @@ static int do_pd_setup(struct fs_enet_private *fep) ...@@ -118,6 +118,8 @@ static int do_pd_setup(struct fs_enet_private *fep)
/* Fill out IRQ field */ /* Fill out IRQ field */
fep->interrupt = platform_get_irq_byname(pdev, "interrupt"); fep->interrupt = platform_get_irq_byname(pdev, "interrupt");
if (fep->interrupt < 0)
return -EINVAL;
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
fep->scc.sccp = (void *)r->start; fep->scc.sccp = (void *)r->start;
......
...@@ -193,8 +193,12 @@ static int gfar_probe(struct platform_device *pdev) ...@@ -193,8 +193,12 @@ static int gfar_probe(struct platform_device *pdev)
priv->interruptTransmit = platform_get_irq_byname(pdev, "tx"); priv->interruptTransmit = platform_get_irq_byname(pdev, "tx");
priv->interruptReceive = platform_get_irq_byname(pdev, "rx"); priv->interruptReceive = platform_get_irq_byname(pdev, "rx");
priv->interruptError = platform_get_irq_byname(pdev, "error"); priv->interruptError = platform_get_irq_byname(pdev, "error");
if (priv->interruptTransmit < 0 || priv->interruptReceive < 0 || priv->interruptError < 0)
goto regs_fail;
} else { } else {
priv->interruptTransmit = platform_get_irq(pdev, 0); priv->interruptTransmit = platform_get_irq(pdev, 0);
if (priv->interruptTransmit < 0)
goto regs_fail;
} }
/* get a pointer to the register memory */ /* get a pointer to the register memory */
......
...@@ -2221,6 +2221,10 @@ static int smc_drv_probe(struct platform_device *pdev) ...@@ -2221,6 +2221,10 @@ static int smc_drv_probe(struct platform_device *pdev)
ndev->dma = (unsigned char)-1; ndev->dma = (unsigned char)-1;
ndev->irq = platform_get_irq(pdev, 0); ndev->irq = platform_get_irq(pdev, 0);
if (ndev->irq < 0) {
ret = -ENODEV;
goto out_free_netdev;
}
ret = smc_request_attrib(pdev); ret = smc_request_attrib(pdev);
if (ret) if (ret)
......
...@@ -218,7 +218,7 @@ static int __init omap_cf_probe(struct device *dev) ...@@ -218,7 +218,7 @@ static int __init omap_cf_probe(struct device *dev)
/* either CFLASH.IREQ (INT_1610_CF) or some GPIO */ /* either CFLASH.IREQ (INT_1610_CF) or some GPIO */
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (!irq) if (irq < 0)
return -EINVAL; return -EINVAL;
cf = kcalloc(1, sizeof *cf, GFP_KERNEL); cf = kcalloc(1, sizeof *cf, GFP_KERNEL);
......
...@@ -1066,6 +1066,8 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, ...@@ -1066,6 +1066,8 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
port->mapbase = res->start; port->mapbase = res->start;
port->membase = S3C24XX_VA_UART + (res->start - S3C24XX_PA_UART); port->membase = S3C24XX_VA_UART + (res->start - S3C24XX_PA_UART);
port->irq = platform_get_irq(platdev, 0); port->irq = platform_get_irq(platdev, 0);
if (port->irq < 0)
port->irq = 0;
ourport->clk = clk_get(&platdev->dev, "uart"); ourport->clk = clk_get(&platdev->dev, "uart");
......
...@@ -286,7 +286,7 @@ void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *); ...@@ -286,7 +286,7 @@ void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *);
int usb_hcd_omap_probe (const struct hc_driver *driver, int usb_hcd_omap_probe (const struct hc_driver *driver,
struct platform_device *pdev) struct platform_device *pdev)
{ {
int retval; int retval, irq;
struct usb_hcd *hcd = 0; struct usb_hcd *hcd = 0;
struct ohci_hcd *ohci; struct ohci_hcd *ohci;
...@@ -329,7 +329,12 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, ...@@ -329,7 +329,12 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
if (retval < 0) if (retval < 0)
goto err2; goto err2;
retval = usb_add_hcd(hcd, platform_get_irq(pdev, 0), SA_INTERRUPT); irq = platform_get_irq(pdev, 0);
if (irq < 0) {
retval = -ENXIO;
goto err2;
}
retval = usb_add_hcd(hcd, irq, SA_INTERRUPT);
if (retval == 0) if (retval == 0)
return retval; return retval;
......
...@@ -1457,7 +1457,7 @@ static int __init sa1100fb_probe(struct platform_device *pdev) ...@@ -1457,7 +1457,7 @@ static int __init sa1100fb_probe(struct platform_device *pdev)
int ret, irq; int ret, irq;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq <= 0) if (irq < 0)
return -EINVAL; return -EINVAL;
if (!request_mem_region(0xb0100000, 0x10000, "LCD")) if (!request_mem_region(0xb0100000, 0x10000, "LCD"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment