-+static int ar231x_setup_timer(struct net_device *dev)
-+{
-+ struct ar231x_private *sp = netdev_priv(dev);
-+
-+ init_timer(&sp->link_timer);
-+
-+ sp->link_timer.function = ar231x_link_timer_fn;
-+ sp->link_timer.data = (int)dev;
-+ sp->link_timer.expires = jiffies + HZ;
-+
-+ add_timer(&sp->link_timer);
-+ return 0;
-+}
-+
-+static void ar231x_link_timer_fn(unsigned long data)
-+{
-+ struct net_device *dev = (struct net_device *)data;
-+ struct ar231x_private *sp = netdev_priv(dev);
-+
-+ /**
-+ * See if the link status changed.
-+ * This was needed to make sure we set the PHY to the
-+ * autonegotiated value of half or full duplex.
-+ */
-+ ar231x_check_link(dev);
-+
-+ /**
-+ * Loop faster when we don't have link.
-+ * This was needed to speed up the AP bootstrap time.
-+ */
-+ if (sp->link == 0)
-+ mod_timer(&sp->link_timer, jiffies + HZ / 2);
-+ else
-+ mod_timer(&sp->link_timer, jiffies + LINK_TIMER);
-+}
-+
-+static void ar231x_check_link(struct net_device *dev)
-+{
-+ struct ar231x_private *sp = netdev_priv(dev);
-+ u16 phy_data;
-+
-+ phy_data = ar231x_mdiobus_read(sp->mii_bus, sp->phy, MII_BMSR);
-+ if (sp->phy_data != phy_data) {
-+ if (phy_data & BMSR_LSTATUS) {
-+ /**
-+ * Link is present, ready link partner ability to
-+ * deterine duplexity.
-+ */
-+ int duplex = 0;
-+ u16 reg;
-+
-+ sp->link = 1;
-+ reg = ar231x_mdiobus_read(sp->mii_bus, sp->phy,
-+ MII_BMCR);
-+ if (reg & BMCR_ANENABLE) {
-+ /* auto neg enabled */
-+ reg = ar231x_mdiobus_read(sp->mii_bus, sp->phy,
-+ MII_LPA);
-+ duplex = reg & (LPA_100FULL | LPA_10FULL) ?
-+ 1 : 0;
-+ } else {
-+ /* no auto neg, just read duplex config */
-+ duplex = (reg & BMCR_FULLDPLX) ? 1 : 0;
-+ }
-+
-+ printk(KERN_INFO "%s: Configuring MAC for %s duplex\n",
-+ dev->name, (duplex) ? "full" : "half");
-+
-+ if (duplex) {
-+ /* full duplex */
-+ sp->eth_regs->mac_control =
-+ (sp->eth_regs->mac_control |
-+ MAC_CONTROL_F) & ~MAC_CONTROL_DRO;
-+ } else {
-+ /* half duplex */
-+ sp->eth_regs->mac_control =
-+ (sp->eth_regs->mac_control |
-+ MAC_CONTROL_DRO) & ~MAC_CONTROL_F;
-+ }
-+ } else {
-+ /* no link */
-+ sp->link = 0;
-+ }
-+ sp->phy_data = phy_data;
-+ }
-+}
-+