Skip to content

Commit

Permalink
net: ethernet: ti: davinci_emac: Use platform_get_irq() to get the in…
Browse files Browse the repository at this point in the history
…terrupt

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 emac_dev_stop() in case
platform_get_irq_optional() fails.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Lad Prabhakar authored and David S. Miller committed Mar 11, 2022
1 parent e8609e6 commit 7cd08f1
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions drivers/net/ethernet/ti/davinci_emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,7 @@ static int emac_dev_stop(struct net_device *ndev)
int irq_num;
struct emac_priv *priv = netdev_priv(ndev);
struct device *emac_dev = &ndev->dev;
int ret = 0;

/* inform the upper layers. */
netif_stop_queue(ndev);
Expand All @@ -1618,17 +1619,31 @@ static int emac_dev_stop(struct net_device *ndev)
phy_disconnect(ndev->phydev);

/* Free IRQ */
while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, i))) {
for (irq_num = res->start; irq_num <= res->end; irq_num++)
free_irq(irq_num, priv->ndev);
i++;
if (dev_of_node(&priv->pdev->dev)) {
do {
ret = platform_get_irq_optional(priv->pdev, i);
if (ret < 0 && ret != -ENXIO)
break;
if (ret > 0) {
free_irq(ret, priv->ndev);
} else {
ret = 0;
break;
}
} while (++i);
} else {
while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, i))) {
for (irq_num = res->start; irq_num <= res->end; irq_num++)
free_irq(irq_num, priv->ndev);
i++;
}
}

if (netif_msg_drv(priv))
dev_notice(emac_dev, "DaVinci EMAC: %s stopped\n", ndev->name);

pm_runtime_put(&priv->pdev->dev);
return 0;
return ret;
}

/**
Expand Down

0 comments on commit 7cd08f1

Please sign in to comment.