net: convert print_mac to %pM
[safe/jmp/linux-2.6] / drivers / net / tsi108_eth.c
index 5a730ba..6924805 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/net.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/ethtool.h>
 #include <linux/skbuff.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
@@ -161,6 +162,7 @@ static struct platform_driver tsi_eth_driver = {
        .remove = tsi108_ether_remove,
        .driver = {
                .name = "tsi-ethernet",
+               .owner = THIS_MODULE,
        },
 };
 
@@ -261,7 +263,7 @@ static inline void tsi108_write_tbi(struct tsi108_prv_data *data,
                        return;
                udelay(10);
        }
-       printk(KERN_ERR "%s function time out \n", __FUNCTION__);
+       printk(KERN_ERR "%s function time out \n", __func__);
 }
 
 static int mii_speed(struct mii_if_info *mii)
@@ -338,22 +340,21 @@ static void tsi108_check_phy(struct net_device *dev)
 
                        TSI_WRITE(TSI108_MAC_CFG2, mac_cfg2_reg);
                        TSI_WRITE(TSI108_EC_PORTCTRL, portctrl_reg);
+               }
 
-                       if (data->link_up == 0) {
-                               /* The manual says it can take 3-4 usecs for the speed change
-                                * to take effect.
-                                */
-                               udelay(5);
+               if (data->link_up == 0) {
+                       /* The manual says it can take 3-4 usecs for the speed change
+                        * to take effect.
+                        */
+                       udelay(5);
 
-                               spin_lock(&data->txlock);
-                               if (is_valid_ether_addr(dev->dev_addr) && data->txfree)
-                                       netif_wake_queue(dev);
+                       spin_lock(&data->txlock);
+                       if (is_valid_ether_addr(dev->dev_addr) && data->txfree)
+                               netif_wake_queue(dev);
 
-                               data->link_up = 1;
-                               spin_unlock(&data->txlock);
-                       }
+                       data->link_up = 1;
+                       spin_unlock(&data->txlock);
                }
-
        } else {
                if (data->link_up == 1) {
                        netif_stop_queue(dev);
@@ -802,7 +803,8 @@ static int tsi108_refill_rx(struct net_device *dev, int budget)
                int rx = data->rxhead;
                struct sk_buff *skb;
 
-               data->rxskbs[rx] = skb = dev_alloc_skb(TSI108_RXBUF_SIZE + 2);
+               data->rxskbs[rx] = skb = netdev_alloc_skb(dev,
+                                                         TSI108_RXBUF_SIZE + 2);
                if (!skb)
                        break;
 
@@ -1057,7 +1059,7 @@ static void tsi108_stop_ethernet(struct net_device *dev)
                        return;
                udelay(10);
        }
-       printk(KERN_ERR "%s function time out \n", __FUNCTION__);
+       printk(KERN_ERR "%s function time out \n", __func__);
 }
 
 static void tsi108_reset_ether(struct tsi108_prv_data * data)
@@ -1242,7 +1244,7 @@ static void tsi108_init_phy(struct net_device *dev)
                udelay(10);
        }
        if (i == 0)
-               printk(KERN_ERR "%s function time out \n", __FUNCTION__);
+               printk(KERN_ERR "%s function time out \n", __func__);
 
        if (data->phy_type == TSI108_PHY_BCM54XX) {
                tsi108_write_mii(data, 0x09, 0x0300);
@@ -1267,12 +1269,11 @@ static void tsi108_init_phy(struct net_device *dev)
         * PHY_STAT register before the link up status bit is set.
         */
 
-       data->link_up = 1;
+       data->link_up = 0;
 
        while (!((phyval = tsi108_read_mii(data, MII_BMSR)) &
                 BMSR_LSTATUS)) {
                if (i++ > (MII_READ_DELAY / 10)) {
-                       data->link_up = 0;
                        break;
                }
                spin_unlock_irqrestore(&phy_lock, flags);
@@ -1352,8 +1353,9 @@ static int tsi108_open(struct net_device *dev)
        data->rxhead = 0;
 
        for (i = 0; i < TSI108_RXRING_LEN; i++) {
-               struct sk_buff *skb = dev_alloc_skb(TSI108_RXBUF_SIZE + NET_IP_ALIGN);
+               struct sk_buff *skb;
 
+               skb = netdev_alloc_skb(dev, TSI108_RXBUF_SIZE + NET_IP_ALIGN);
                if (!skb) {
                        /* Bah.  No memory for now, but maybe we'll get
                         * some more later.
@@ -1435,7 +1437,6 @@ static int tsi108_close(struct net_device *dev)
                dev_kfree_skb(skb);
        }
 
-       synchronize_irq(data->irq_num);
        free_irq(data->irq_num, dev);
 
        /* Discard the RX ring. */
@@ -1521,12 +1522,46 @@ static void tsi108_init_mac(struct net_device *dev)
        TSI_WRITE(TSI108_EC_INTMASK, ~0);
 }
 
+static int tsi108_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+       struct tsi108_prv_data *data = netdev_priv(dev);
+       unsigned long flags;
+       int rc;
+
+       spin_lock_irqsave(&data->txlock, flags);
+       rc = mii_ethtool_gset(&data->mii_if, cmd);
+       spin_unlock_irqrestore(&data->txlock, flags);
+
+       return rc;
+}
+
+static int tsi108_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+       struct tsi108_prv_data *data = netdev_priv(dev);
+       unsigned long flags;
+       int rc;
+
+       spin_lock_irqsave(&data->txlock, flags);
+       rc = mii_ethtool_sset(&data->mii_if, cmd);
+       spin_unlock_irqrestore(&data->txlock, flags);
+
+       return rc;
+}
+
 static int tsi108_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
        struct tsi108_prv_data *data = netdev_priv(dev);
+       if (!netif_running(dev))
+               return -EINVAL;
        return generic_mii_ioctl(&data->mii_if, if_mii(rq), cmd, NULL);
 }
 
+static const struct ethtool_ops tsi108_ethtool_ops = {
+       .get_link       = ethtool_op_get_link,
+       .get_settings   = tsi108_get_settings,
+       .set_settings   = tsi108_set_settings,
+};
+
 static int
 tsi108_init_one(struct platform_device *pdev)
 {
@@ -1534,7 +1569,6 @@ tsi108_init_one(struct platform_device *pdev)
        struct tsi108_prv_data *data = NULL;
        hw_info *einfo;
        int err = 0;
-       DECLARE_MAC_BUF(mac);
 
        einfo = pdev->dev.platform_data;
 
@@ -1591,6 +1625,7 @@ tsi108_init_one(struct platform_device *pdev)
        dev->get_stats = tsi108_get_stats;
        netif_napi_add(dev, &data->napi, tsi108_poll, 64);
        dev->do_ioctl = tsi108_do_ioctl;
+       dev->ethtool_ops = &tsi108_ethtool_ops;
 
        /* Apparently, the Linux networking code won't use scatter-gather
         * if the hardware doesn't do checksums.  However, it's faster
@@ -1623,8 +1658,8 @@ tsi108_init_one(struct platform_device *pdev)
        }
 
        platform_set_drvdata(pdev, dev);
-       printk(KERN_INFO "%s: Tsi108 Gigabit Ethernet, MAC: %s\n",
-              dev->name, print_mac(mac, dev->dev_addr));
+       printk(KERN_INFO "%s: Tsi108 Gigabit Ethernet, MAC: %pM\n",
+              dev->name, dev->dev_addr);
 #ifdef DEBUG
        data->msg_enable = DEBUG;
        dump_eth_one(dev);
@@ -1695,3 +1730,4 @@ module_exit(tsi108_ether_exit);
 MODULE_AUTHOR("Tundra Semiconductor Corporation");
 MODULE_DESCRIPTION("Tsi108 Gigabit Ethernet driver");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:tsi-ethernet");