All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ethernet: cpsw: improve interrupt lookup logic in cpsw_probe()
@ 2014-09-04  7:00 Daniel Mack
  2014-09-04 14:06 ` Mugunthan V N
  2014-09-06  0:17 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Mack @ 2014-09-04  7:00 UTC (permalink / raw)
  To: davem; +Cc: julia.lawall, netdev, mugunthanvnm, george.cherian, Daniel Mack

From: Daniel Mack <zonque@gmail.com>

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>
---
 drivers/net/ethernet/ti/cpsw.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 999fb72..03b4099 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)
 	}
 
 	while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) {
-		for (i = res->start; i <= res->end; i++) {
-			if (devm_request_irq(&pdev->dev, i, cpsw_interrupt, 0,
-					     dev_name(&pdev->dev), priv)) {
-				dev_err(priv->dev, "error attaching irq\n");
-				goto clean_ale_ret;
-			}
-			priv->irqs_table[k] = i;
-			priv->num_irqs = k + 1;
+		if (k >= ARRAY_SIZE(priv->irqs_table)) {
+			ret = -EINVAL;
+			goto clean_ale_ret;
 		}
+
+		ret = devm_request_irq(&pdev->dev, res->start, cpsw_interrupt,
+				       0, dev_name(&pdev->dev), priv);
+		if (ret < 0) {
+			dev_err(priv->dev, "error attaching irq (%d)\n", ret);
+			goto clean_ale_ret;
+		}
+
+		priv->irqs_table[k] = res->start;
 		k++;
 	}
 
+	priv->num_irqs = k;
+
 	ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
 
 	ndev->netdev_ops = &cpsw_netdev_ops;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: ethernet: cpsw: improve interrupt lookup logic in cpsw_probe()
  2014-09-04  7:00 [PATCH] net: ethernet: cpsw: improve interrupt lookup logic in cpsw_probe() Daniel Mack
@ 2014-09-04 14:06 ` Mugunthan V N
  2014-09-06  0:17 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Mugunthan V N @ 2014-09-04 14:06 UTC (permalink / raw)
  To: Daniel Mack, davem; +Cc: julia.lawall, netdev, george.cherian, Daniel Mack

On Thursday 04 September 2014 12:30 PM, Daniel Mack wrote:
> From: Daniel Mack <zonque@gmail.com>
> 
> 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>

Regards
Mugunthan V N

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: ethernet: cpsw: improve interrupt lookup logic in cpsw_probe()
  2014-09-04  7:00 [PATCH] net: ethernet: cpsw: improve interrupt lookup logic in cpsw_probe() Daniel Mack
  2014-09-04 14:06 ` Mugunthan V N
@ 2014-09-06  0:17 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-09-06  0:17 UTC (permalink / raw)
  To: daniel; +Cc: julia.lawall, netdev, mugunthanvnm, george.cherian, zonque

From: Daniel Mack <daniel@zonque.org>
Date: Thu,  4 Sep 2014 09:00:23 +0200

> From: Daniel Mack <zonque@gmail.com>
> 
> 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>

Applied to net-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-06  0:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-04  7:00 [PATCH] net: ethernet: cpsw: improve interrupt lookup logic in cpsw_probe() Daniel Mack
2014-09-04 14:06 ` Mugunthan V N
2014-09-06  0:17 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.