From: David Miller <davem@davemloft.net>
To: oliver@hartkopp.net
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH]: Third (final?) release of Sun Neptune driver
Date: Mon, 08 Oct 2007 16:08:35 -0700 (PDT) [thread overview]
Message-ID: <20071008.160835.121874561.davem@davemloft.net> (raw)
In-Reply-To: <470A5450.70403@hartkopp.net>
From: Oliver Hartkopp <oliver@hartkopp.net>
Date: Mon, 08 Oct 2007 18:01:20 +0200
> David Miller wrote:
> > +
> > +static int link_status_1g(struct niu *np, int *link_up_p)
...
> Should *link_up_p be set to any value before returning?
...
> > +out:
> > + spin_unlock_irqrestore(&np->lock, flags);
> > +
> > + *link_up_p = link_up;
> > + return 0;
> > +}
> > +
> >
> Although you added a proper return value in link_status_10g() while
> fixing the locking issue, you should think about providing a similar
> return value for link_status_1g() to be constistent here.
Thanks for finding these two issues. I've fixed it in the patch
below.
Luckily, this case was harmless. When we enable a loopback mode,
niu_open() forces the link up by calling netif_carrier_on().
Then, niu_timer() always sees -EINVAL coming back from
niu_link_status() because of these loopback checks, and in such
cases never uses the link_up value because niu_link_status_common()
will not be invoked.
Anyways, thanks again!
commit ec3ec3566a8ee3c8c262606e06299c8212ebd53f
Author: David S. Miller <davem@sunset.davemloft.net>
Date: Mon Oct 8 16:08:17 2007 -0700
[NIU]: Make sure link_up status is set to something in link_status_{1,10}g().
Noticed by Oliver Hartkopp.
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 2a69cee..7c09243 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -1082,13 +1082,14 @@ static int link_status_10g(struct niu *np, int *link_up_p)
unsigned long flags;
int err, link_up;
- if (np->link_config.loopback_mode != LOOPBACK_DISABLED)
- return -EINVAL;
-
link_up = 0;
spin_lock_irqsave(&np->lock, flags);
+ err = -EINVAL;
+ if (np->link_config.loopback_mode != LOOPBACK_DISABLED)
+ return out;
+
err = mdio_read(np, np->phy_addr, BCM8704_PMA_PMD_DEV_ADDR,
BCM8704_PMD_RCV_SIGDET);
if (err < 0)
@@ -1119,15 +1120,12 @@ static int link_status_10g(struct niu *np, int *link_up_p)
link_up = 1;
np->link_config.active_speed = SPEED_10000;
np->link_config.active_duplex = DUPLEX_FULL;
+ err = 0;
out:
spin_unlock_irqrestore(&np->lock, flags);
*link_up_p = link_up;
- return 0;
-
-out_err:
- spin_unlock_irqrestore(&np->lock, flags);
return err;
}
@@ -1138,15 +1136,16 @@ static int link_status_1g(struct niu *np, int *link_up_p)
u8 current_duplex;
int err, link_up;
- if (np->link_config.loopback_mode != LOOPBACK_DISABLED)
- return -EINVAL;
-
link_up = 0;
current_speed = SPEED_INVALID;
current_duplex = DUPLEX_INVALID;
spin_lock_irqsave(&np->lock, flags);
+ err = -EINVAL;
+ if (np->link_config.loopback_mode != LOOPBACK_DISABLED)
+ goto out;
+
err = mii_read(np, np->phy_addr, MII_BMSR);
if (err < 0)
goto out;
@@ -1172,6 +1171,7 @@ static int link_status_1g(struct niu *np, int *link_up_p)
goto out;
estat = err;
+ link_up = 1;
if (estat & (ESTATUS_1000_TFULL | ESTATUS_1000_THALF)) {
current_speed = SPEED_1000;
if (estat & ESTATUS_1000_TFULL)
@@ -1195,16 +1195,16 @@ static int link_status_1g(struct niu *np, int *link_up_p)
current_speed = SPEED_10;
current_duplex = DUPLEX_HALF;
} else
- goto out;
+ link_up = 0;
}
- link_up = 1;
}
+ err = 0;
out:
spin_unlock_irqrestore(&np->lock, flags);
*link_up_p = link_up;
- return 0;
+ return err;
}
static int niu_link_status(struct niu *np, int *link_up_p)
prev parent reply other threads:[~2007-10-08 23:08 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-05 10:12 [PATCH]: Third (final?) release of Sun Neptune driver David Miller
2007-10-05 15:35 ` Stephen Hemminger
2007-10-05 22:49 ` David Miller
2007-10-05 22:54 ` David Miller
2007-10-05 23:31 ` Jeff Garzik
2007-10-05 22:56 ` David Miller
2007-10-05 23:07 ` David Miller
2007-10-05 23:24 ` David Miller
2007-10-05 23:32 ` Jeff Garzik
2007-10-05 23:27 ` David Miller
2007-10-05 15:39 ` Stephen Hemminger
2007-10-05 21:12 ` David Miller
2007-10-05 21:18 ` Stephen Hemminger
2007-10-05 23:30 ` David Miller
2007-10-05 15:40 ` Stephen Hemminger
2007-10-05 21:12 ` David Miller
2007-10-05 21:14 ` Jeff Garzik
2007-10-05 21:21 ` Stephen Hemminger
2007-10-05 21:40 ` David Miller
2007-10-05 21:38 ` David Miller
2007-10-05 23:42 ` David Miller
2007-10-05 15:43 ` Stephen Hemminger
2007-10-06 0:04 ` David Miller
2007-10-06 0:28 ` Stephen Hemminger
2007-10-06 0:46 ` David Miller
2007-10-06 8:32 ` Johannes Berg
2007-10-05 16:46 ` Ingo Oeser
2007-10-05 16:49 ` Ingo Oeser
2007-10-06 0:08 ` David Miller
2007-10-08 16:04 ` Oliver Hartkopp
2007-10-05 16:55 ` Jeff Garzik
2007-10-05 17:45 ` Matheos Worku
2007-10-05 21:18 ` David Miller
2007-10-05 21:20 ` David Miller
[not found] ` <470677A0.5060502@sun.com>
2007-10-05 21:24 ` David Miller
2007-10-05 22:18 ` Matheos Worku
2007-10-05 22:43 ` David Miller
2007-10-06 0:10 ` David Miller
2007-10-08 16:01 ` Oliver Hartkopp
2007-10-08 23:08 ` David Miller [this message]
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=20071008.160835.121874561.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=oliver@hartkopp.net \
/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).