cpumask: sh: Introduce cpumask_of_{node,pcibus} to replace {node,pcibus}_to_cpumask
[safe/jmp/linux-2.6] / drivers / net / tsi108_eth.c
index bc38489..eb1da6f 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)
@@ -801,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;
 
@@ -1056,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)
@@ -1241,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);
@@ -1350,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.
@@ -1433,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. */
@@ -1519,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)
 {
@@ -1589,6 +1626,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
@@ -1693,3 +1731,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");