[PATCH] DM9000 - better checks for platform resources
The current DM9000 driver cannot cope if it is given more than 3 resources (for example, if it is being passed an wake-up irq that it is not using yet). Check that we have been given at-least one IRQ resource. Also fix the minor type-casting for the case of 2 resources. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
@@ -410,10 +410,7 @@ dm9000_probe(struct platform_device *pdev)
|
|||||||
if (pdev->num_resources < 2) {
|
if (pdev->num_resources < 2) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
} else if (pdev->num_resources == 2) {
|
||||||
|
|
||||||
switch (pdev->num_resources) {
|
|
||||||
case 2:
|
|
||||||
base = pdev->resource[0].start;
|
base = pdev->resource[0].start;
|
||||||
|
|
||||||
if (!request_mem_region(base, 4, ndev->name)) {
|
if (!request_mem_region(base, 4, ndev->name)) {
|
||||||
@@ -423,17 +420,16 @@ dm9000_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
ndev->base_addr = base;
|
ndev->base_addr = base;
|
||||||
ndev->irq = pdev->resource[1].start;
|
ndev->irq = pdev->resource[1].start;
|
||||||
db->io_addr = (void *)base;
|
db->io_addr = (void __iomem *)base;
|
||||||
db->io_data = (void *)(base + 4);
|
db->io_data = (void __iomem *)(base + 4);
|
||||||
|
|
||||||
break;
|
} else {
|
||||||
|
|
||||||
case 3:
|
|
||||||
db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
||||||
db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
||||||
|
|
||||||
if (db->addr_res == NULL || db->data_res == NULL) {
|
if (db->addr_res == NULL || db->data_res == NULL ||
|
||||||
|
db->irq_res == NULL) {
|
||||||
printk(KERN_ERR PFX "insufficient resources\n");
|
printk(KERN_ERR PFX "insufficient resources\n");
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
goto out;
|
goto out;
|
||||||
@@ -482,7 +478,6 @@ dm9000_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
/* ensure at least we have a default set of IO routines */
|
/* ensure at least we have a default set of IO routines */
|
||||||
dm9000_set_io(db, iosize);
|
dm9000_set_io(db, iosize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check to see if anything is being over-ridden */
|
/* check to see if anything is being over-ridden */
|
||||||
|
Reference in New Issue
Block a user