From: Andrew Morton Fix up whitespace and coding style chaos. Cc: Dan Faerch Cc: Benjamin LaHaise Cc: Jeff Garzik Signed-off-by: Andrew Morton --- drivers/net/ns83820.c | 145 ++++++++++++++++++---------------------- 1 files changed, 67 insertions(+), 78 deletions(-) diff -puN drivers/net/ns83820.c~drivers-net-ns83820c-add-paramter-to-disable-auto-tidy drivers/net/ns83820.c --- devel/drivers/net/ns83820.c~drivers-net-ns83820c-add-paramter-to-disable-auto-tidy 2006-02-13 15:55:52.000000000 -0800 +++ devel-akpm/drivers/net/ns83820.c 2006-02-13 15:55:52.000000000 -0800 @@ -129,9 +129,9 @@ /* Global parameters. See module_param near the bottom. */ static int ihr = 2; -static int reset_phy = 0; -static int lnksts = 0; /* CFG_LNKSTS bit polarity */ -static int disable_autoneg = 0; +static int reset_phy; +static int lnksts; /* CFG_LNKSTS bit polarity */ +static int disable_autoneg; /* Dprintk is used for more interesting debug events */ #undef Dprintk @@ -1267,108 +1267,103 @@ static struct net_device_stats *ns83820_ return &dev->stats; } -/* Dan Faerch: ethtool get/set support. - * This probably isnt perfect, but it does the job for me. I only own fiber, so copper support has hardly begun. - * Please feel free to double-check anything!! (as im a super-newbie at this :) -*/ - /* Let ethtool retrieve info */ -static int ns83820_get_settings(struct net_device *ndev, struct ethtool_cmd *cmd) -{ struct ns83820 *dev = PRIV(ndev); - u32 cfg,tanar, tbicr; +static int ns83820_get_settings(struct net_device *ndev, + struct ethtool_cmd *cmd) +{ + struct ns83820 *dev = PRIV(ndev); + u32 cfg, tanar, tbicr; int have_optical = 0; int fullduplex = 0; -/* - Heres the list of available ethtool commands from other drivers: - cmd->advertising = - cmd->speed = - cmd->duplex = - cmd->port = 0; - cmd->phy_address = - cmd->transceiver = 0; - cmd->autoneg = - cmd->maxtxpkt = 0; - cmd->maxrxpkt = 0; - Feel free to implement any of theese if needed. -*/ + /* + * Here's the list of available ethtool commands from other drivers: + * cmd->advertising = + * cmd->speed = + * cmd->duplex = + * cmd->port = 0; + * cmd->phy_address = + * cmd->transceiver = 0; + * cmd->autoneg = + * cmd->maxtxpkt = 0; + * cmd->maxrxpkt = 0; + */ - /*read current configuration*/ + /* read current configuration */ cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY; tanar = readl(dev->base + TANAR); tbicr = readl(dev->base + TBICR); - /*we have optical thingie-majiggy*/ if (dev->CFG_cache & CFG_TBI_EN) { + /* we have an optical interface */ have_optical = 1; - //fullduplex = (tanar & TANAR_FULL_DUP); fullduplex = (cfg & CFG_DUPSTS) ? 1 : 0; - } else { /* We have copper */ + } else { + /* We have copper */ fullduplex = (cfg & CFG_DUPSTS) ? 1 : 0; - } - //log status - printk(KERN_INFO "%s: T:%d-%d-%d - \n", - ndev->name, - (tanar & TANAR_FULL_DUP), - (cfg & CFG_DUPSTS), - tanar - ); + printk(KERN_INFO "%s: T:%d-%d-%d - \n", ndev->name, + tanar & TANAR_FULL_DUP, cfg & CFG_DUPSTS, tanar); + cmd->supported = SUPPORTED_Autoneg; - cmd->supported = (SUPPORTED_Autoneg); - - /*we have optical thingie-majiggy*/ + /* we have optical interface */ if (dev->CFG_cache & CFG_TBI_EN) { - cmd->supported |= (SUPPORTED_1000baseT_Half | - SUPPORTED_1000baseT_Full); - cmd->supported |= SUPPORTED_FIBRE; + cmd->supported |= SUPPORTED_1000baseT_Half | + SUPPORTED_1000baseT_Full | + SUPPORTED_FIBRE; cmd->port = PORT_FIBRE; - } /*TODO: else show copper related thingies*/ - - cmd->duplex = ((fullduplex) ? DUPLEX_FULL : DUPLEX_HALF); - cmd->speed = ( - ((cfg / CFG_SPDSTS0) & 3) >= 2 ? SPEED_1000 : - (((cfg / CFG_SPDSTS0) & 3) == 1 ? SPEED_100 : SPEED_10 ) - ); - //cmd->autoneg = !disable_autoneg; - cmd->autoneg = (tbicr & TBICR_MR_AN_ENABLE) ? 1: 0; + } /* TODO: else copper related support */ + cmd->duplex = fullduplex ? DUPLEX_FULL : DUPLEX_HALF; + switch (cfg / CFG_SPDSTS0 & 3) { + case 2: + cmd->speed = SPEED_1000; + break; + case 1: + cmd->speed = SPEED_100; + break; + default: + cmd->speed = SPEED_10; + break; + } + cmd->autoneg = (tbicr & TBICR_MR_AN_ENABLE) ? 1: 0; return 0; } /* Let ethool change settings*/ -static int ns83820_set_settings(struct net_device *ndev, struct ethtool_cmd *cmd) -{ struct ns83820 *dev = PRIV(ndev); - u32 cfg,tanar; +static int ns83820_set_settings(struct net_device *ndev, + struct ethtool_cmd *cmd) +{ + struct ns83820 *dev = PRIV(ndev); + u32 cfg, tanar; int have_optical = 0; int fullduplex = 0; - /*read current configuration*/ + /* read current configuration */ cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY; tanar = readl(dev->base + TANAR); - /*we have optical*/ if (dev->CFG_cache & CFG_TBI_EN) { + /* we have optical */ have_optical = 1; fullduplex = (tanar & TANAR_FULL_DUP); - // fullduplex = (cfg & CFG_DUPSTS); - } else { /*We have a copper*/ - fullduplex = (cfg & CFG_DUPSTS); + } else { + /* we have copper */ + fullduplex = cfg & CFG_DUPSTS; } spin_lock_irq(&dev->misc_lock); spin_lock(&dev->tx_lock); - //Set Duplex - if ( cmd->duplex != fullduplex) { //If ethtool-setting is different than current setting - /*we have optical*/ + /* Set duplex */ + if (cmd->duplex != fullduplex) { if (have_optical) { /*set full duplex*/ - if (cmd->duplex==DUPLEX_FULL) { + if (cmd->duplex == DUPLEX_FULL) { /* force full duplex */ writel(readl(dev->base + TXCFG) | TXCFG_CSI | TXCFG_HBI | TXCFG_ATP, @@ -1378,7 +1373,6 @@ static int ns83820_set_settings(struct n /* Light up full duplex LED */ writel(readl(dev->base + GPIOR) | GPIOR_GP1_OUT, dev->base + GPIOR); - //writel(readl(dev->base + TANAR) | TANAR_FULL_DUP, dev->base + TANAR); } else { /*TODO: set half duplex */ } @@ -1391,10 +1385,11 @@ static int ns83820_set_settings(struct n ndev->name); } - //Set Autoneg - if (cmd->autoneg != ((disable_autoneg) ? AUTONEG_DISABLE : AUTONEG_ENABLE )) { //If ethtool-setting is different than current setting + /* Set autonegotiation */ + if ((disable_autoneg && cmd->autoneg != AUTONEG_DISABLE) || + (!disable_autoneg && cmd->autoneg != AUTONEG_ENABLE)) { if (cmd->autoneg == AUTONEG_ENABLE) { - disable_autoneg=0; + disable_autoneg = 0; /* restart auto negotiation */ writel(TBICR_MR_AN_ENABLE | TBICR_MR_RESTART_AN, @@ -1405,18 +1400,14 @@ static int ns83820_set_settings(struct n printk(KERN_INFO "%s: autoneg enabled via ethtool\n", ndev->name); } else { - disable_autoneg=1; + disable_autoneg = 1; /* disable auto negotiation */ - writel(0x00000000, - dev->base + TBICR); - //dev->linkstate = LINK_UP; + writel(0x00000000, dev->base + TBICR); } - printk(KERN_INFO "%s: autoneg %s via ethtool\n", - ndev->name, - (cmd->autoneg) ? "ENABLED" : "DISABLED" - ); + printk(KERN_INFO "%s: autoneg %s via ethtool\n", ndev->name, + cmd->autoneg ? "ENABLED" : "DISABLED"); } phy_intr(ndev); @@ -2150,9 +2141,7 @@ static int __devinit ns83820_init_one(st printk(KERN_INFO "%s: Skipping autonegotiation\n", ndev->name); } - - dev->CFG_cache |= CFG_MODE_1000; - + dev->CFG_cache |= CFG_MODE_1000; } writel(dev->CFG_cache, dev->base + CFG); _