All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <oliver@hartkopp.net>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH]: Third (final?) release of Sun Neptune driver
Date: Mon, 08 Oct 2007 18:01:20 +0200	[thread overview]
Message-ID: <470A5450.70403@hartkopp.net> (raw)
In-Reply-To: <20071005.031209.57156822.davem@davemloft.net>

David Miller wrote:
> +
> +static int link_status_1g(struct niu *np, int *link_up_p)
> +{
> +	u16 current_speed, bmsr;
> +	unsigned long flags;
> +	u8 current_duplex;
> +	int err, link_up;
> +
> +	if (np->link_config.loopback_mode != LOOPBACK_DISABLED)
> +		return -EINVAL;
>   

Should *link_up_p be set to any value before returning?

> +
> +	link_up = 0;
> +	current_speed = SPEED_INVALID;
> +	current_duplex = DUPLEX_INVALID;
> +
> +	spin_lock_irqsave(&np->lock, flags);
> +
> +	err = mii_read(np, np->phy_addr, MII_BMSR);
> +	if (err < 0)
> +		goto out;
> +
> +	bmsr = err;
> +	if (bmsr & BMSR_LSTATUS) {
> +		u16 adv, lpa, common, estat;
> +
> +		err = mii_read(np, np->phy_addr, MII_ADVERTISE);
> +		if (err < 0)
> +			goto out;
> +		adv = err;
> +
> +		err = mii_read(np, np->phy_addr, MII_LPA);
> +		if (err < 0)
> +			goto out;
> +		lpa = err;
> +
> +		common = adv & lpa;
> +
> +		err = mii_read(np, np->phy_addr, MII_ESTATUS);
> +		if (err < 0)
> +			goto out;
> +		estat = err;
> +
> +		if (estat & (ESTATUS_1000_TFULL | ESTATUS_1000_THALF)) {
> +			current_speed = SPEED_1000;
> +			if (estat == ESTATUS_1000_TFULL)
> +				current_duplex = DUPLEX_FULL;
> +			else
> +				current_duplex = DUPLEX_HALF;
> +		} else {
> +			if (common & ADVERTISE_100BASE4) {
> +				current_speed = SPEED_100;
> +				current_duplex = DUPLEX_HALF;
> +			} else if (common & ADVERTISE_100FULL) {
> +				current_speed = SPEED_100;
> +				current_duplex = DUPLEX_FULL;
> +			} else if (common & ADVERTISE_100HALF) {
> +				current_speed = SPEED_100;
> +				current_duplex = DUPLEX_HALF;
> +			} else if (common & ADVERTISE_10FULL) {
> +				current_speed = SPEED_10;
> +				current_duplex = DUPLEX_FULL;
> +			} else if (common & ADVERTISE_10HALF) {
> +				current_speed = SPEED_10;
> +				current_duplex = DUPLEX_HALF;
> +			} else
> +				goto out;
> +		}
> +		link_up = 1;
> +	}
> +
> +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.

Oliver




  parent reply	other threads:[~2007-10-08 16:01 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 [this message]
2007-10-08 23:08   ` David Miller

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=470A5450.70403@hartkopp.net \
    --to=oliver@hartkopp.net \
    --cc=davem@davemloft.net \
    --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 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.