Commit 32f52e8e authored by Lad Prabhakar's avatar Lad Prabhakar Committed by David S. Miller

net: ethernet: ti: davinci_emac: Use platform_get_irq() to get the interrupt

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq() for DT users only.

While at it propagate error code in case request_irq() fails instead of
returning -EBUSY.
Signed-off-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7801302b
...@@ -1454,15 +1454,24 @@ static int emac_dev_open(struct net_device *ndev) ...@@ -1454,15 +1454,24 @@ static int emac_dev_open(struct net_device *ndev)
} }
/* Request IRQ */ /* Request IRQ */
while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, if (dev_of_node(&priv->pdev->dev)) {
res_num))) { while ((ret = platform_get_irq_optional(priv->pdev, res_num)) != -ENXIO) {
for (irq_num = res->start; irq_num <= res->end; irq_num++) { if (ret < 0)
if (request_irq(irq_num, emac_irq, 0, ndev->name, goto rollback;
ndev)) {
dev_err(emac_dev,
"DaVinci EMAC: request_irq() failed\n");
ret = -EBUSY;
ret = request_irq(ret, emac_irq, 0, ndev->name, ndev);
if (ret) {
dev_err(emac_dev, "DaVinci EMAC: request_irq() failed\n");
goto rollback;
}
res_num++;
}
} else {
while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, res_num))) {
for (irq_num = res->start; irq_num <= res->end; irq_num++) {
ret = request_irq(irq_num, emac_irq, 0, ndev->name, ndev);
if (ret) {
dev_err(emac_dev, "DaVinci EMAC: request_irq() failed\n");
goto rollback; goto rollback;
} }
} }
...@@ -1471,6 +1480,7 @@ static int emac_dev_open(struct net_device *ndev) ...@@ -1471,6 +1480,7 @@ static int emac_dev_open(struct net_device *ndev)
/* prepare counters for rollback in case of an error */ /* prepare counters for rollback in case of an error */
res_num--; res_num--;
irq_num--; irq_num--;
}
/* Start/Enable EMAC hardware */ /* Start/Enable EMAC hardware */
emac_hw_enable(priv); emac_hw_enable(priv);
...@@ -1554,6 +1564,13 @@ static int emac_dev_open(struct net_device *ndev) ...@@ -1554,6 +1564,13 @@ static int emac_dev_open(struct net_device *ndev)
napi_disable(&priv->napi); napi_disable(&priv->napi);
rollback: rollback:
if (dev_of_node(&priv->pdev->dev)) {
for (q = res_num - 1; q >= 0; q--) {
irq_num = platform_get_irq(priv->pdev, q);
if (irq_num > 0)
free_irq(irq_num, ndev);
}
} else {
for (q = res_num; q >= 0; q--) { for (q = res_num; q >= 0; q--) {
res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, q); res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, q);
/* at the first iteration, irq_num is already set to the /* at the first iteration, irq_num is already set to the
...@@ -1565,6 +1582,7 @@ static int emac_dev_open(struct net_device *ndev) ...@@ -1565,6 +1582,7 @@ static int emac_dev_open(struct net_device *ndev)
for (m = irq_num; m >= res->start; m--) for (m = irq_num; m >= res->start; m--)
free_irq(m, ndev); free_irq(m, ndev);
} }
}
cpdma_ctlr_stop(priv->dma); cpdma_ctlr_stop(priv->dma);
pm_runtime_put(&priv->pdev->dev); pm_runtime_put(&priv->pdev->dev);
return ret; return ret;
...@@ -1899,13 +1917,10 @@ static int davinci_emac_probe(struct platform_device *pdev) ...@@ -1899,13 +1917,10 @@ static int davinci_emac_probe(struct platform_device *pdev)
goto err_free_txchan; goto err_free_txchan;
} }
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); rc = platform_get_irq(pdev, 0);
if (!res) { if (rc < 0)
dev_err(&pdev->dev, "error getting irq res\n");
rc = -ENOENT;
goto err_free_rxchan; goto err_free_rxchan;
} ndev->irq = rc;
ndev->irq = res->start;
rc = davinci_emac_try_get_mac(pdev, res_ctrl ? 0 : 1, priv->mac_addr); rc = davinci_emac_try_get_mac(pdev, res_ctrl ? 0 : 1, priv->mac_addr);
if (!rc) if (!rc)
......
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