]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Tsi108_eth: Add ethtool support
authorAlex Bounine <alex.bou9@gmail.com>
Mon, 11 Feb 2008 19:36:37 +0000 (14:36 -0500)
committerJeff Garzik <jeff@garzik.org>
Mon, 11 Feb 2008 19:47:29 +0000 (14:47 -0500)
Add ethtool support to tsi108_eth network driver.

Signed-off-by: Alexandre Bounine <alexandreb@tundra.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/tsi108_eth.c

index bc3848962bb13101cc6c750b80346b4713fe06a8..6f33f84d37b0631652d04825b58a554cc7477dc7 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>
@@ -1519,12 +1520,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 +1624,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