netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1
  2005-10-19  1:31 [patch 2.6.14-rc3 0/3] misc fixes/cleanups for sundance John W. Linville
@ 2005-10-19  1:31 ` John W. Linville
  2005-10-19  1:31   ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 John W. Linville
  2005-10-19  2:29   ` [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1 Jeff Garzik
  0 siblings, 2 replies; 10+ messages in thread
From: John W. Linville @ 2005-10-19  1:31 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: jgarzik

Remove an if (1) { ... } block in sundance_probe1.  Its purpose seems
to be only to allow for delaring some extra local variables.  But, it also
adds ugly indentation without adding any meaning to the code.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---

 drivers/net/sundance.c |   48 +++++++++++++++++++++++-------------------------
 1 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -518,6 +518,7 @@ static int __devinit sundance_probe1 (st
 #else
 	int bar = 1;
 #endif
+	int phy, phy_idx = 0;
 
 
 /* when built into the kernel, we only print version if device is found */
@@ -605,33 +606,30 @@ static int __devinit sundance_probe1 (st
 			printk("%2.2x:", dev->dev_addr[i]);
 	printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq);
 
-	if (1) {
-		int phy, phy_idx = 0;
-		np->phys[0] = 1;		/* Default setting */
-		np->mii_preamble_required++;
-		for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
-			int mii_status = mdio_read(dev, phy, MII_BMSR);
-			if (mii_status != 0xffff  &&  mii_status != 0x0000) {
-				np->phys[phy_idx++] = phy;
-				np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE);
-				if ((mii_status & 0x0040) == 0)
-					np->mii_preamble_required++;
-				printk(KERN_INFO "%s: MII PHY found at address %d, status "
-					   "0x%4.4x advertising %4.4x.\n",
-					   dev->name, phy, mii_status, np->mii_if.advertising);
-			}
-		}
-		np->mii_preamble_required--;
-
-		if (phy_idx == 0) {
-			printk(KERN_INFO "%s: No MII transceiver found, aborting.  ASIC status %x\n",
-				   dev->name, ioread32(ioaddr + ASICCtrl));
-			goto err_out_unregister;
-		}
-
-		np->mii_if.phy_id = np->phys[0];
+	np->phys[0] = 1;		/* Default setting */
+	np->mii_preamble_required++;
+	for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
+		int mii_status = mdio_read(dev, phy, MII_BMSR);
+		if (mii_status != 0xffff  &&  mii_status != 0x0000) {
+			np->phys[phy_idx++] = phy;
+			np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE);
+			if ((mii_status & 0x0040) == 0)
+				np->mii_preamble_required++;
+			printk(KERN_INFO "%s: MII PHY found at address %d, status "
+				   "0x%4.4x advertising %4.4x.\n",
+				   dev->name, phy, mii_status, np->mii_if.advertising);
+		}
+	}
+	np->mii_preamble_required--;
+
+	if (phy_idx == 0) {
+		printk(KERN_INFO "%s: No MII transceiver found, aborting.  ASIC status %x\n",
+			   dev->name, ioread32(ioaddr + ASICCtrl));
+		goto err_out_unregister;
 	}
 
+	np->mii_if.phy_id = np->phys[0];
+
 	/* Parse override configuration */
 	np->an_enable = 1;
 	if (card_idx < MAX_UNITS) {

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

* [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0
  2005-10-19  1:31 ` [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1 John W. Linville
@ 2005-10-19  1:31   ` John W. Linville
  2005-10-19  1:31     ` [patch 2.6.14-rc3 3/3] sundance: expand reset mask John W. Linville
  2005-10-19  2:31     ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 Jeff Garzik
  2005-10-19  2:29   ` [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1 Jeff Garzik
  1 sibling, 2 replies; 10+ messages in thread
From: John W. Linville @ 2005-10-19  1:31 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: jgarzik

Probe for PHYs starting at MII address 0 instead of MII address 1.
This covers the entire range of MII addresses.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---

 drivers/net/sundance.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -608,7 +608,7 @@ static int __devinit sundance_probe1 (st
 
 	np->phys[0] = 1;		/* Default setting */
 	np->mii_preamble_required++;
-	for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
+	for (phy = 0; phy < 32 && phy_idx < MII_CNT; phy++) {
 		int mii_status = mdio_read(dev, phy, MII_BMSR);
 		if (mii_status != 0xffff  &&  mii_status != 0x0000) {
 			np->phys[phy_idx++] = phy;

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

* [patch 2.6.14-rc3 0/3] misc fixes/cleanups for sundance
@ 2005-10-19  1:31 John W. Linville
  2005-10-19  1:31 ` [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1 John W. Linville
  0 siblings, 1 reply; 10+ messages in thread
From: John W. Linville @ 2005-10-19  1:31 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: jgarzik

Just a little cleanup from me, and some fixes snarfed from the
ICPlus (chip vendor) version of the driver.

	-- Get rid of if (1) { ... } block in sundance_probe1

	-- Change PHY probing to start from MII address 0

	-- Expand the mask used when resetting the chip

Patches to follow...

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

* [patch 2.6.14-rc3 3/3] sundance: expand reset mask
  2005-10-19  1:31   ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 John W. Linville
@ 2005-10-19  1:31     ` John W. Linville
  2005-10-19  2:29       ` Jeff Garzik
  2005-10-19  2:31     ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 Jeff Garzik
  1 sibling, 1 reply; 10+ messages in thread
From: John W. Linville @ 2005-10-19  1:31 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: jgarzik

Expand the mask used when reseting the chip to include the GlobalReset
bit.  This fix comes from ICPlus and seems to be required for some
cards.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---

 drivers/net/sundance.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -690,7 +690,7 @@ static int __devinit sundance_probe1 (st
 	/* Reset the chip to erase previous misconfiguration. */
 	if (netif_msg_hw(np))
 		printk("ASIC Control is %x.\n", ioread32(ioaddr + ASICCtrl));
-	iowrite16(0x007f, ioaddr + ASICCtrl + 2);
+	iowrite16(0x00ff, ioaddr + ASICCtrl + 2);
 	if (netif_msg_hw(np))
 		printk("ASIC Control is now %x.\n", ioread32(ioaddr + ASICCtrl));
 

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

* Re: [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1
  2005-10-19  1:31 ` [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1 John W. Linville
  2005-10-19  1:31   ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 John W. Linville
@ 2005-10-19  2:29   ` Jeff Garzik
  1 sibling, 0 replies; 10+ messages in thread
From: Jeff Garzik @ 2005-10-19  2:29 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-kernel, netdev

applied

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

* Re: [patch 2.6.14-rc3 3/3] sundance: expand reset mask
  2005-10-19  1:31     ` [patch 2.6.14-rc3 3/3] sundance: expand reset mask John W. Linville
@ 2005-10-19  2:29       ` Jeff Garzik
  0 siblings, 0 replies; 10+ messages in thread
From: Jeff Garzik @ 2005-10-19  2:29 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-kernel, netdev

applied

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

* Re: [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0
  2005-10-19  1:31   ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 John W. Linville
  2005-10-19  1:31     ` [patch 2.6.14-rc3 3/3] sundance: expand reset mask John W. Linville
@ 2005-10-19  2:31     ` Jeff Garzik
  2005-10-19 12:00       ` John W. Linville
  1 sibling, 1 reply; 10+ messages in thread
From: Jeff Garzik @ 2005-10-19  2:31 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-kernel, netdev

John W. Linville wrote:
> Probe for PHYs starting at MII address 0 instead of MII address 1.
> This covers the entire range of MII addresses.
> 
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
> ---
> 
>  drivers/net/sundance.c |    2 +-
>  1 files changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
> --- a/drivers/net/sundance.c
> +++ b/drivers/net/sundance.c
> @@ -608,7 +608,7 @@ static int __devinit sundance_probe1 (st
>  
>  	np->phys[0] = 1;		/* Default setting */
>  	np->mii_preamble_required++;
> -	for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
> +	for (phy = 0; phy < 32 && phy_idx < MII_CNT; phy++) {

NAK.  MII address 0 should be scanned _last_, after all other addresses. 
  In some phys, it is a ghost, mirroring another address.

Take a look at some of the original Becker MII scan code from
ftp://ftp.scyld.com/pub/network/ to see an elegant method for this.

Becker's scan code would utilize a mask to keep the loop nice and 
elegant, eliminating an "if (phy == 32) phy = 0;" test.

	Jeff

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

* Re: [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0
  2005-10-19  2:31     ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 Jeff Garzik
@ 2005-10-19 12:00       ` John W. Linville
  2005-10-19 12:07         ` [patch 2.6.14-rc3] sundance: include MII address 0 in PHY probe John W. Linville
  0 siblings, 1 reply; 10+ messages in thread
From: John W. Linville @ 2005-10-19 12:00 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, netdev

On Tue, Oct 18, 2005 at 10:31:51PM -0400, Jeff Garzik wrote:
> John W. Linville wrote:

> >--- a/drivers/net/sundance.c
> >+++ b/drivers/net/sundance.c
> >@@ -608,7 +608,7 @@ static int __devinit sundance_probe1 (st
> > 
> > 	np->phys[0] = 1;		/* Default setting */
> > 	np->mii_preamble_required++;
> >-	for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
> >+	for (phy = 0; phy < 32 && phy_idx < MII_CNT; phy++) {
> 
> NAK.  MII address 0 should be scanned _last_, after all other addresses. 
>  In some phys, it is a ghost, mirroring another address.
> 
> Take a look at some of the original Becker MII scan code from
> ftp://ftp.scyld.com/pub/network/ to see an elegant method for this.

Hmmm...that is clever...patch to follow...

John
-- 
John W. Linville
linville@tuxdriver.com

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

* [patch 2.6.14-rc3] sundance: include MII address 0 in PHY probe
  2005-10-19 12:00       ` John W. Linville
@ 2005-10-19 12:07         ` John W. Linville
  2005-10-20 14:07           ` Jeff Garzik
  0 siblings, 1 reply; 10+ messages in thread
From: John W. Linville @ 2005-10-19 12:07 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: jgarzik

Include MII address 0 at the end of the PHY scan.  This covers the
entire range of possible MII addresses.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
---

 drivers/net/sundance.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -608,16 +608,17 @@ static int __devinit sundance_probe1 (st
 
 	np->phys[0] = 1;		/* Default setting */
 	np->mii_preamble_required++;
-	for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
+	for (phy = 1; phy <= 32 && phy_idx < MII_CNT; phy++) {
 		int mii_status = mdio_read(dev, phy, MII_BMSR);
+		int phyx = phy & 0x1f;
 		if (mii_status != 0xffff  &&  mii_status != 0x0000) {
-			np->phys[phy_idx++] = phy;
-			np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE);
+			np->phys[phy_idx++] = phyx;
+			np->mii_if.advertising = mdio_read(dev, phyx, MII_ADVERTISE);
 			if ((mii_status & 0x0040) == 0)
 				np->mii_preamble_required++;
 			printk(KERN_INFO "%s: MII PHY found at address %d, status "
 				   "0x%4.4x advertising %4.4x.\n",
-				   dev->name, phy, mii_status, np->mii_if.advertising);
+				   dev->name, phyx, mii_status, np->mii_if.advertising);
 		}
 	}
 	np->mii_preamble_required--;

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

* Re: [patch 2.6.14-rc3] sundance: include MII address 0 in PHY probe
  2005-10-19 12:07         ` [patch 2.6.14-rc3] sundance: include MII address 0 in PHY probe John W. Linville
@ 2005-10-20 14:07           ` Jeff Garzik
  0 siblings, 0 replies; 10+ messages in thread
From: Jeff Garzik @ 2005-10-20 14:07 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-kernel, netdev

John W. Linville wrote:
> Include MII address 0 at the end of the PHY scan.  This covers the
> entire range of possible MII addresses.
> 
> Signed-off-by: John W. Linville <linville@tuxdriver.com>

applied

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

end of thread, other threads:[~2005-10-20 14:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-19  1:31 [patch 2.6.14-rc3 0/3] misc fixes/cleanups for sundance John W. Linville
2005-10-19  1:31 ` [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1 John W. Linville
2005-10-19  1:31   ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 John W. Linville
2005-10-19  1:31     ` [patch 2.6.14-rc3 3/3] sundance: expand reset mask John W. Linville
2005-10-19  2:29       ` Jeff Garzik
2005-10-19  2:31     ` [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0 Jeff Garzik
2005-10-19 12:00       ` John W. Linville
2005-10-19 12:07         ` [patch 2.6.14-rc3] sundance: include MII address 0 in PHY probe John W. Linville
2005-10-20 14:07           ` Jeff Garzik
2005-10-19  2:29   ` [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1 Jeff Garzik

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).