Commit b5a099c6 authored by Robert Jarzmik's avatar Robert Jarzmik Committed by David S. Miller

net: ethernet: davicom: fix devicetree irq resource

The dm9000 driver doesn't work in at least one device-tree
configuration, spitting an error message on irq resource :
[    1.062495] dm9000 8000000.ethernet: insufficient resources
[    1.068439] dm9000 8000000.ethernet: not found (-2).
[    1.073451] dm9000: probe of 8000000.ethernet failed with error -2

The reason behind is that the interrupt might be provided by a gpio
controller, not probed when dm9000 is probed, and needing the probe
deferral mechanism to apply.

Currently, the interrupt is directly taken from resources. This patch
changes this to use the more generic platform_get_irq(), which handles
the deferral.

Moreover, since commit Fixes: 7085a740 ("drivers: platform: parse
IRQ flags from resources"), the interrupt trigger flags are honored in
platform_get_irq(), so remove the needless code in dm9000.
Signed-off-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Acked-by: default avatarMarcel Ziswiler <marcel@ziswiler.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Tested-by: default avatarSergei Ianovich <ynvich@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1ad54668
...@@ -128,7 +128,6 @@ struct board_info { ...@@ -128,7 +128,6 @@ struct board_info {
struct resource *data_res; struct resource *data_res;
struct resource *addr_req; /* resources requested */ struct resource *addr_req; /* resources requested */
struct resource *data_req; struct resource *data_req;
struct resource *irq_res;
int irq_wake; int irq_wake;
...@@ -1300,22 +1299,16 @@ static int ...@@ -1300,22 +1299,16 @@ static int
dm9000_open(struct net_device *dev) dm9000_open(struct net_device *dev)
{ {
struct board_info *db = netdev_priv(dev); struct board_info *db = netdev_priv(dev);
unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
if (netif_msg_ifup(db)) if (netif_msg_ifup(db))
dev_dbg(db->dev, "enabling %s\n", dev->name); dev_dbg(db->dev, "enabling %s\n", dev->name);
/* If there is no IRQ type specified, default to something that /* If there is no IRQ type specified, tell the user that this is a
* may work, and tell the user that this is a problem */ * problem
*/
if (irqflags == IRQF_TRIGGER_NONE) if (irq_get_trigger_type(dev->irq) == IRQF_TRIGGER_NONE)
irqflags = irq_get_trigger_type(dev->irq);
if (irqflags == IRQF_TRIGGER_NONE)
dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n"); dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
irqflags |= IRQF_SHARED;
/* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */ /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */ iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
mdelay(1); /* delay needs by DM9000B */ mdelay(1); /* delay needs by DM9000B */
...@@ -1323,7 +1316,8 @@ dm9000_open(struct net_device *dev) ...@@ -1323,7 +1316,8 @@ dm9000_open(struct net_device *dev)
/* Initialize DM9000 board */ /* Initialize DM9000 board */
dm9000_init_dm9000(dev); dm9000_init_dm9000(dev);
if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev)) if (request_irq(dev->irq, dm9000_interrupt, IRQF_SHARED,
dev->name, dev))
return -EAGAIN; return -EAGAIN;
/* Now that we have an interrupt handler hooked up we can unmask /* Now that we have an interrupt handler hooked up we can unmask
* our interrupts * our interrupts
...@@ -1500,15 +1494,22 @@ dm9000_probe(struct platform_device *pdev) ...@@ -1500,15 +1494,22 @@ dm9000_probe(struct platform_device *pdev)
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);
if (db->addr_res == NULL || db->data_res == NULL || if (!db->addr_res || !db->data_res) {
db->irq_res == NULL) { dev_err(db->dev, "insufficient resources addr=%p data=%p\n",
dev_err(db->dev, "insufficient resources\n"); db->addr_res, db->data_res);
ret = -ENOENT; ret = -ENOENT;
goto out; goto out;
} }
ndev->irq = platform_get_irq(pdev, 0);
if (ndev->irq < 0) {
dev_err(db->dev, "interrupt resource unavailable: %d\n",
ndev->irq);
ret = ndev->irq;
goto out;
}
db->irq_wake = platform_get_irq(pdev, 1); db->irq_wake = platform_get_irq(pdev, 1);
if (db->irq_wake >= 0) { if (db->irq_wake >= 0) {
dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake); dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake);
...@@ -1570,7 +1571,6 @@ dm9000_probe(struct platform_device *pdev) ...@@ -1570,7 +1571,6 @@ dm9000_probe(struct platform_device *pdev)
/* fill in parameters for net-dev structure */ /* fill in parameters for net-dev structure */
ndev->base_addr = (unsigned long)db->io_addr; ndev->base_addr = (unsigned long)db->io_addr;
ndev->irq = db->irq_res->start;
/* 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);
......
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