misc fixes/cleanups for sundance
Subsystems (2)
cover misc fixes/cleanups for sundance
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...
PATCH 1/3 sundance: remove if (1) { ... } block in sundance_probe1
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.
---
drivers/net/sundance.c | 48 +++++++++++++++++++++++------------------------- 1 files changed, 23 insertions(+), 25 deletions(-)
drivers/net/sundance.c +23 -25
@@ -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 (stprintk ("%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 ) {
PATCH 2/3 sundance: probe PHYs from MII address 0
Probe for PHYs starting at MII address 0 instead of MII address 1. This covers the entire range of MII addresses.
---
drivers/net/sundance.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/net/sundance.c +1 -1
@@ -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;
PATCH 3/3 sundance: expand reset mask
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.
---
drivers/net/sundance.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/net/sundance.c +1 -1
@@ -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));
Jeff Garzik
AppliedRe: [patch 2.6.14-rc3 3/3] sundance: expand reset mask
applied
Re: [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0
In reply to John W. LinvilleQuoted 13 lines · John W. Linville
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 <[email protected]>---
drivers/net/sundance.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/net/sundance.c static int __devinit sundance_probe1 (st · line 611
Quoted 5 lines
drivers/net/sundance.c +1
-1@@ -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
Re: [patch 2.6.14-rc3 2/3] sundance: probe PHYs from MII address 0
Quoted 14 lines · Jeff Garzik
drivers/net/sundance.c static int __devinit sundance_probe1 (st · line 611
Quoted 8 lines · John W. Linville
drivers/net/sundance.c +1
-1@@ -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.
Quoted 2 lines
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
Signature · 2 lines
John W. Linville [email protected]
PATCH 1/1 sundance: include MII address 0 in PHY probe
Include MII address 0 at the end of the PHY scan. This covers the entire range of possible MII addresses.
---
drivers/net/sundance.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/sundance.c +5 -4
@@ -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--;
Jeff Garzik
AppliedRe: [patch 2.6.14-rc3] sundance: include MII address 0 in PHY probe
Quoted 4 lines · John W. Linville
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 <[email protected]>
applied
Jeff Garzik
AppliedRe: [patch 2.6.14-rc3 1/3] sundance: remove if (1) { ... } block in sundance_probe1
In reply to John W. Linvilleapplied