aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/ti
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2014-09-04 03:00:23 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-05 20:17:13 -0400
commitc2b32e580ccc574cf353661ee6d900947e9fdf28 (patch)
tree3e086c638970122c91c8c344b8c62786e5a04303 /drivers/net/ethernet/ti
parentcaa415270c732505240bb60171c44a7838c555e8 (diff)
net: ethernet: cpsw: improve interrupt lookup logic in cpsw_probe()
Simplify the interrupt resource lookup code in cpsw_probe() by the following: * Only look at the first member of the resource. As the driver only works for DT-enabled platforms anyway, a resource of type IORESOURCE_IRQ will only contain one single entry (res->start == res->end), so there is no need for the iteration. * Add a bounds check to avoid overflows if we are passed more than ARRAY_SIZE(priv->irqs_table) resources. * Assign 'ret' with the return value of devm_request_irq() so that cpsw_probe() returns the appropriate error code. * If devm_request_irq() fails, report the error code in the log message. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Mugunthan V N <mugunthanvnm@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ti')
-rw-r--r--drivers/net/ethernet/ti/cpsw.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 999fb72688d2..03b409988566 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2232,18 +2232,24 @@ static int cpsw_probe(struct platform_device *pdev)
2232 } 2232 }
2233 2233
2234 while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) { 2234 while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) {
2235 for (i = res->start; i <= res->end; i++) { 2235 if (k >= ARRAY_SIZE(priv->irqs_table)) {
2236 if (devm_request_irq(&pdev->dev, i, cpsw_interrupt, 0, 2236 ret = -EINVAL;
2237 dev_name(&pdev->dev), priv)) { 2237 goto clean_ale_ret;
2238 dev_err(priv->dev, "error attaching irq\n");
2239 goto clean_ale_ret;
2240 }
2241 priv->irqs_table[k] = i;
2242 priv->num_irqs = k + 1;
2243 } 2238 }
2239
2240 ret = devm_request_irq(&pdev->dev, res->start, cpsw_interrupt,
2241 0, dev_name(&pdev->dev), priv);
2242 if (ret < 0) {
2243 dev_err(priv->dev, "error attaching irq (%d)\n", ret);
2244 goto clean_ale_ret;
2245 }
2246
2247 priv->irqs_table[k] = res->start;
2244 k++; 2248 k++;
2245 } 2249 }
2246 2250
2251 priv->num_irqs = k;
2252
2247 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 2253 ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
2248 2254
2249 ndev->netdev_ops = &cpsw_netdev_ops; 2255 ndev->netdev_ops = &cpsw_netdev_ops;