]> git.hungrycats.org Git - linux/commitdiff
[netdrvr] ethtool_ops support in 3c503, 3c505, 3c507
authorJeff Garzik <jgarzik@redhat.com>
Tue, 26 Aug 2003 12:29:36 +0000 (08:29 -0400)
committerJeff Garzik <jgarzik@redhat.com>
Tue, 26 Aug 2003 12:29:36 +0000 (08:29 -0400)
drivers/net/3c503.c
drivers/net/3c505.c
drivers/net/3c507.c

index 39fc773bfb4be4700a92a6d25cc13d831c9e0874..9e87e44f059888d53e8dfffec829711a110d0703 100644 (file)
@@ -80,7 +80,7 @@ static void el2_block_input(struct net_device *dev, int count, struct sk_buff *s
                           int ring_offset);
 static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
                         int ring_page);
-static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
+static struct ethtool_ops netdev_ethtool_ops;
 
 \f
 /* This routine probes for a memory-mapped 3c503 board by looking for
@@ -308,7 +308,7 @@ el2_probe1(struct net_device *dev, int ioaddr)
 
     dev->open = &el2_open;
     dev->stop = &el2_close;
-    dev->do_ioctl = &netdev_ioctl;
+    dev->ethtool_ops = &netdev_ethtool_ops;
 
     if (dev->mem_start)
        printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
@@ -617,69 +617,18 @@ el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring
     return;
 }
 
-/**
- * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
- * @dev: network interface on which out-of-band action is to be performed
- * @useraddr: userspace address to which data is to be read and returned
- *
- * Process the various commands of the SIOCETHTOOL interface.
- */
 
-static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
+static void netdev_get_drvinfo(struct net_device *dev,
+                              struct ethtool_drvinfo *info)
 {
-       u32 ethcmd;
-
-       /* dev_ioctl() in ../../net/core/dev.c has already checked
-          capable(CAP_NET_ADMIN), so don't bother with that here.  */
-
-       if (get_user(ethcmd, (u32 *)useraddr))
-               return -EFAULT;
-
-       switch (ethcmd) {
-
-       case ETHTOOL_GDRVINFO: {
-               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-               strcpy (info.driver, DRV_NAME);
-               strcpy (info.version, DRV_VERSION);
-               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
-               if (copy_to_user (useraddr, &info, sizeof (info)))
-                       return -EFAULT;
-               return 0;
-       }
-
-       default:
-               break;
-       }
-
-       return -EOPNOTSUPP;
+       strcpy(info->driver, DRV_NAME);
+       strcpy(info->version, DRV_VERSION);
+       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
 }
 
-/**
- * netdev_ioctl: Handle network interface ioctls
- * @dev: network interface on which out-of-band action is to be performed
- * @rq: user request data
- * @cmd: command issued by user
- *
- * Process the various out-of-band ioctls passed to this driver.
- */
-
-static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
-{
-       int rc = 0;
-
-       switch (cmd) {
-       case SIOCETHTOOL:
-               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
-               break;
-
-       default:
-               rc = -EOPNOTSUPP;
-               break;
-       }
-
-       return rc;
-}
- 
+static struct ethtool_ops netdev_ethtool_ops = {
+       .get_drvinfo            = netdev_get_drvinfo,
+};
 
 #ifdef MODULE
 #define MAX_EL2_CARDS  4       /* Max number of EL2 cards per module */
index dfd0ed0c486ca97e6fa882db5a742601fca57438..44e86a1355d4b5f970feaf7898e2a59de8809360 100644 (file)
@@ -1163,86 +1163,30 @@ static struct net_device_stats *elp_get_stats(struct net_device *dev)
        return &adapter->stats;
 }
 
-/**
- * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
- * @dev: network interface on which out-of-band action is to be performed
- * @useraddr: userspace address to which data is to be read and returned
- *
- * Process the various commands of the SIOCETHTOOL interface.
- */
 
-static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
+static void netdev_get_drvinfo(struct net_device *dev,
+                              struct ethtool_drvinfo *info)
 {
-       u32 ethcmd;
-
-       /* dev_ioctl() in ../../net/core/dev.c has already checked
-          capable(CAP_NET_ADMIN), so don't bother with that here.  */
-
-       if (get_user(ethcmd, (u32 *)useraddr))
-               return -EFAULT;
-
-       switch (ethcmd) {
-
-       case ETHTOOL_GDRVINFO: {
-               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-               strcpy (info.driver, DRV_NAME);
-               strcpy (info.version, DRV_VERSION);
-               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
-               if (copy_to_user (useraddr, &info, sizeof (info)))
-                       return -EFAULT;
-               return 0;
-       }
-
-       /* get message-level */
-       case ETHTOOL_GMSGLVL: {
-               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
-               edata.data = debug;
-               if (copy_to_user(useraddr, &edata, sizeof(edata)))
-                       return -EFAULT;
-               return 0;
-       }
-       /* set message-level */
-       case ETHTOOL_SMSGLVL: {
-               struct ethtool_value edata;
-               if (copy_from_user(&edata, useraddr, sizeof(edata)))
-                       return -EFAULT;
-               debug = edata.data;
-               return 0;
-       }
-
-       default:
-               break;
-       }
-
-       return -EOPNOTSUPP;
+       strcpy(info->driver, DRV_NAME);
+       strcpy(info->version, DRV_VERSION);
+       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
 }
 
-/**
- * netdev_ioctl: Handle network interface ioctls
- * @dev: network interface on which out-of-band action is to be performed
- * @rq: user request data
- * @cmd: command issued by user
- *
- * Process the various out-of-band ioctls passed to this driver.
- */
-
-static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
+static u32 netdev_get_msglevel(struct net_device *dev)
 {
-       int rc = 0;
-
-       switch (cmd) {
-       case SIOCETHTOOL:
-               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
-               break;
-
-       default:
-               rc = -EOPNOTSUPP;
-               break;
-       }
+       return debug;
+}
 
-       return rc;
+static void netdev_set_msglevel(struct net_device *dev, u32 level)
+{
+       debug = level;
 }
- 
+
+static struct ethtool_ops netdev_ethtool_ops = {
+       .get_drvinfo            = netdev_get_drvinfo,
+       .get_msglevel           = netdev_get_msglevel,
+       .set_msglevel           = netdev_set_msglevel,
+};
 
 /******************************************************
  *
@@ -1373,7 +1317,7 @@ static inline void elp_init(struct net_device *dev)
        dev->tx_timeout = elp_timeout;                  /* local */
        dev->watchdog_timeo = 10*HZ;
        dev->set_multicast_list = elp_set_mc_list;      /* local */
-       dev->do_ioctl = netdev_ioctl;                   /* local */
+       dev->ethtool_ops = &netdev_ethtool_ops;         /* local */
 
        /* Setup the generic properties */
        ether_setup(dev);
index 3a7f8187c9647bed05d9690282a1393666b03fbe..f37d295b7bfe6ab88b6ab1ee0b7cddfcde67e3ec 100644 (file)
@@ -299,7 +299,7 @@ static void el16_tx_timeout (struct net_device *dev);
 
 static void hardware_send_packet(struct net_device *dev, void *buf, short length, short pad);
 static void init_82586_mem(struct net_device *dev);
-static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
+static struct ethtool_ops netdev_ethtool_ops;
 
 \f
 /* Check for a network adaptor of this type, and return '0' iff one exists.
@@ -431,7 +431,7 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
        dev->get_stats  = el16_get_stats;
        dev->tx_timeout = el16_tx_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
-       dev->do_ioctl = netdev_ioctl;
+       dev->ethtool_ops = &netdev_ethtool_ops;
 
        ether_setup(dev);       /* Generic ethernet behaviour */
 
@@ -874,86 +874,29 @@ static void el16_rx(struct net_device *dev)
        lp->rx_tail = rx_tail;
 }
 
-/**
- * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
- * @dev: network interface on which out-of-band action is to be performed
- * @useraddr: userspace address to which data is to be read and returned
- *
- * Process the various commands of the SIOCETHTOOL interface.
- */
-
-static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
+static void netdev_get_drvinfo(struct net_device *dev,
+                              struct ethtool_drvinfo *info)
 {
-       u32 ethcmd;
-
-       /* dev_ioctl() in ../../net/core/dev.c has already checked
-          capable(CAP_NET_ADMIN), so don't bother with that here.  */
-
-       if (get_user(ethcmd, (u32 *)useraddr))
-               return -EFAULT;
-
-       switch (ethcmd) {
-
-       case ETHTOOL_GDRVINFO: {
-               struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
-               strcpy (info.driver, DRV_NAME);
-               strcpy (info.version, DRV_VERSION);
-               sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
-               if (copy_to_user (useraddr, &info, sizeof (info)))
-                       return -EFAULT;
-               return 0;
-       }
-
-       /* get message-level */
-       case ETHTOOL_GMSGLVL: {
-               struct ethtool_value edata = {ETHTOOL_GMSGLVL};
-               edata.data = debug;
-               if (copy_to_user(useraddr, &edata, sizeof(edata)))
-                       return -EFAULT;
-               return 0;
-       }
-       /* set message-level */
-       case ETHTOOL_SMSGLVL: {
-               struct ethtool_value edata;
-               if (copy_from_user(&edata, useraddr, sizeof(edata)))
-                       return -EFAULT;
-               debug = edata.data;
-               return 0;
-       }
-
-       default:
-               break;
-       }
-
-       return -EOPNOTSUPP;
+       strcpy(info->driver, DRV_NAME);
+       strcpy(info->version, DRV_VERSION);
+       sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
 }
 
-/**
- * netdev_ioctl: Handle network interface ioctls
- * @dev: network interface on which out-of-band action is to be performed
- * @rq: user request data
- * @cmd: command issued by user
- *
- * Process the various out-of-band ioctls passed to this driver.
- */
-
-static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
+static u32 netdev_get_msglevel(struct net_device *dev)
 {
-       int rc = 0;
-
-       switch (cmd) {
-       case SIOCETHTOOL:
-               rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
-               break;
-
-       default:
-               rc = -EOPNOTSUPP;
-               break;
-       }
+       return debug;
+}
 
-       return rc;
+static void netdev_set_msglevel(struct net_device *dev, u32 level)
+{
+       debug = level;
 }
- 
+
+static struct ethtool_ops netdev_ethtool_ops = {
+       .get_drvinfo            = netdev_get_drvinfo,
+       .get_msglevel           = netdev_get_msglevel,
+       .set_msglevel           = netdev_set_msglevel,
+};
 
 #ifdef MODULE
 static struct net_device dev_3c507;