netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] gianfar: Fix tests of unsigneds in gfar_parse_group()
Date: Tue, 15 Dec 2009 19:42:05 +0100	[thread overview]
Message-ID: <4B27D87D.5070908@gmail.com> (raw)

interruptTransmit, -Receive and -Error are unsigned so the tests did not work.

This also changes that if irq_of_parse_and_map(np, 0) returns NO_IRQ, that
gfar_parse_group() returns an -EINVAL.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Found using coccinelle: http://coccinelle.lip6.fr/

diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 6850dc0..c411682 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -522,6 +522,7 @@ static int gfar_parse_group(struct device_node *np,
 {
 	u32 *queue_mask;
 	u64 addr, size;
+	int irq;
 
 	addr = of_translate_address(np,
 			of_get_address(np, 0, &size, NULL));
@@ -530,20 +531,22 @@ static int gfar_parse_group(struct device_node *np,
 	if (!priv->gfargrp[priv->num_grps].regs)
 		return -ENOMEM;
 
-	priv->gfargrp[priv->num_grps].interruptTransmit =
-			irq_of_parse_and_map(np, 0);
+	irq = irq_of_parse_and_map(np, 0);
+	if (irq < 0)
+		return -EINVAL;
+	priv->gfargrp[priv->num_grps].interruptTransmit = irq;
 
 	/* If we aren't the FEC we have multiple interrupts */
 	if (model && strcasecmp(model, "FEC")) {
-		priv->gfargrp[priv->num_grps].interruptReceive =
-			irq_of_parse_and_map(np, 1);
-		priv->gfargrp[priv->num_grps].interruptError =
-			irq_of_parse_and_map(np,2);
-		if (priv->gfargrp[priv->num_grps].interruptTransmit < 0 ||
-			priv->gfargrp[priv->num_grps].interruptReceive < 0 ||
-			priv->gfargrp[priv->num_grps].interruptError < 0) {
+		irq = irq_of_parse_and_map(np, 1);
+		if (irq < 0)
 			return -EINVAL;
-		}
+		priv->gfargrp[priv->num_grps].interruptReceive = irq;
+
+		irq = irq_of_parse_and_map(np, 2);
+		if (irq < 0)
+			return -EINVAL;
+		priv->gfargrp[priv->num_grps].interruptError = irq;
 	}
 
 	priv->gfargrp[priv->num_grps].grp_id = priv->num_grps;

             reply	other threads:[~2009-12-15 18:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-15 18:42 Roel Kluin [this message]
2009-12-16  5:02 ` [PATCH] gianfar: Fix tests of unsigneds in gfar_parse_group() Kumar Gopalpet-B05799
2009-12-16  5:04 ` Kumar Gopalpet-B05799
2009-12-16 15:48   ` roel kluin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B27D87D.5070908@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).