From 3c49284ba687a12c6824e90f020c45a04e5574b2 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Tue, 26 Aug 2003 08:21:32 -0400 Subject: [PATCH] [netdrvr 3c501] ethtool_ops support --- drivers/net/3c501.c | 91 +++++++++------------------------------------ drivers/net/3c501.h | 2 +- 2 files changed, 19 insertions(+), 74 deletions(-) diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c index c6fba9fbdd57e..f5a5b8cd31a4d 100644 --- a/drivers/net/3c501.c +++ b/drivers/net/3c501.c @@ -307,7 +307,7 @@ static int __init el1_probe1(struct net_device *dev, int ioaddr) dev->stop = &el1_close; dev->get_stats = &el1_get_stats; dev->set_multicast_list = &set_multicast_list; - dev->do_ioctl = netdev_ioctl; + dev->ethtool_ops = &netdev_ethtool_ops; /* * Setup the generic properties @@ -857,86 +857,31 @@ static void set_multicast_list(struct net_device *dev) } } -/** - * 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; + return debug; +} - switch (cmd) { - case SIOCETHTOOL: - rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); - break; +static void netdev_set_msglevel(struct net_device *dev, u32 level) +{ + debug = level; +} - default: - rc = -EOPNOTSUPP; - break; - } +static struct ethtool_ops netdev_ethtool_ops = { + .get_drvinfo = netdev_get_drvinfo, + .get_msglevel = netdev_get_msglevel, + .set_msglevel = netdev_set_msglevel, +}; - return rc; -} - #ifdef MODULE static struct net_device dev_3c501 = { diff --git a/drivers/net/3c501.h b/drivers/net/3c501.h index e4f34781b9cee..de1dd2fb09ae8 100644 --- a/drivers/net/3c501.h +++ b/drivers/net/3c501.h @@ -14,7 +14,7 @@ static void el_reset(struct net_device *dev); static int el1_close(struct net_device *dev); static struct net_device_stats *el1_get_stats(struct net_device *dev); static void set_multicast_list(struct net_device *dev); -static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); +static struct ethtool_ops netdev_ethtool_ops; #define EL1_IO_EXTENT 16 -- 2.53.0