]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tlan: Add ethtool support
authorOndrej Zary <linux@rainbow-software.org>
Mon, 30 Jun 2014 16:38:29 +0000 (18:38 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 Jul 2014 00:06:51 +0000 (17:06 -0700)
Add basic ethtool support to tlan driver:
 - driver info  - link detect (this allows NetworkManager to detect carrier)
 - EEPROM read

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/tlan.c
drivers/net/ethernet/ti/tlan.h

index ccde7482d404991a4feb381ba5d167fdc3f71e7f..00ec926084ea03e188c91f75207865833e780755 100644 (file)
@@ -778,7 +778,43 @@ static const struct net_device_ops tlan_netdev_ops = {
 #endif
 };
 
+static void tlan_get_drvinfo(struct net_device *dev,
+                            struct ethtool_drvinfo *info)
+{
+       struct tlan_priv *priv = netdev_priv(dev);
+
+       strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
+       if (priv->pci_dev)
+               strlcpy(info->bus_info, pci_name(priv->pci_dev),
+                       sizeof(info->bus_info));
+       else
+               strlcpy(info->bus_info, "EISA", sizeof(info->bus_info));
+       info->eedump_len = TLAN_EEPROM_SIZE;
+}
+
+static int tlan_get_eeprom_len(struct net_device *dev)
+{
+       return TLAN_EEPROM_SIZE;
+}
 
+static int tlan_get_eeprom(struct net_device *dev,
+                          struct ethtool_eeprom *eeprom, u8 *data)
+{
+       int i;
+
+       for (i = 0; i < TLAN_EEPROM_SIZE; i++)
+               if (tlan_ee_read_byte(dev, i, &data[i]))
+                       return -EIO;
+
+       return 0;
+}
+
+static const struct ethtool_ops tlan_ethtool_ops = {
+       .get_drvinfo    = tlan_get_drvinfo,
+       .get_link       = ethtool_op_get_link,
+       .get_eeprom_len = tlan_get_eeprom_len,
+       .get_eeprom     = tlan_get_eeprom,
+};
 
 /***************************************************************
  *     tlan_init
@@ -841,6 +877,7 @@ static int tlan_init(struct net_device *dev)
 
        /* Device methods */
        dev->netdev_ops = &tlan_netdev_ops;
+       dev->ethtool_ops = &tlan_ethtool_ops;
        dev->watchdog_timeo = TX_TIMEOUT;
 
        return 0;
index 4ced9053d9f4a471961e203692dc950816572e83..b6ceebaa2185654dbbdf80a21fd65fd0707703af 100644 (file)
@@ -240,6 +240,7 @@ struct tlan_priv {
 #define TLAN_EEPROM_ACK                0
 #define TLAN_EEPROM_STOP       1
 
+#define TLAN_EEPROM_SIZE       256