--- a/drivers/usb/net/usbnet.c 2003-09-18 23:09:49.569063272 -0400 +++ b/drivers/usb/net/usbnet.c 2003-09-18 23:10:52.005571480 -0400 @@ -298,6 +298,8 @@ /*-------------------------------------------------------------------------*/ +static struct ethtool_ops usbnet_ethtool_ops; + /* mostly for PDA style devices, which are always connected if present */ static int always_connected (struct usbnet *dev) { @@ -383,10 +385,10 @@ #ifdef CONFIG_USB_AX8817X -#define NEED_MII /* ASIX AX8817X based USB 2.0 Ethernet Devices */ #define HAVE_HARDWARE +#define NEED_MII #include <linux/crc32.h> @@ -2415,72 +2417,45 @@ /*-------------------------------------------------------------------------*/ -static inline int -usbnet_ethtool_ioctl (struct net_device *net, void __user *useraddr) +static void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) { - struct usbnet *dev = (struct usbnet *) net->priv; - u32 cmd; + struct usbnet *dev = net->priv; - if (get_user (cmd, (u32 *)useraddr)) - return -EFAULT; - switch (cmd) { - - case ETHTOOL_GDRVINFO: { /* get driver info */ - struct ethtool_drvinfo info; - - memset (&info, 0, sizeof info); - info.cmd = ETHTOOL_GDRVINFO; - strncpy (info.driver, driver_name, sizeof info.driver); - strncpy (info.version, DRIVER_VERSION, sizeof info.version); - strncpy (info.fw_version, dev->driver_info->description, - sizeof info.fw_version); - usb_make_path (dev->udev, info.bus_info, sizeof info.bus_info); - if (copy_to_user (useraddr, &info, sizeof (info))) - return -EFAULT; - return 0; - } + strncpy (info->driver, driver_name, sizeof info->driver); + strncpy (info->version, DRIVER_VERSION, sizeof info->version); + strncpy (info->fw_version, dev->driver_info->description, + sizeof info->fw_version); + usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info); +} - case ETHTOOL_GLINK: /* get link status */ - if (dev->driver_info->check_connect) { - struct ethtool_value edata = { ETHTOOL_GLINK }; - - edata.data = dev->driver_info->check_connect (dev) == 0; - if (copy_to_user (useraddr, &edata, sizeof (edata))) - return -EFAULT; - return 0; - } - break; +static u32 usbnet_get_link (struct net_device *net) +{ + struct usbnet *dev = net->priv; - case ETHTOOL_GMSGLVL: { /* get message-level */ - struct ethtool_value edata = {ETHTOOL_GMSGLVL}; + /* If a check_connect is defined, return it's results */ + if (dev->driver_info->check_connect) + return dev->driver_info->check_connect (dev) == 0; - edata.data = dev->msg_level; - if (copy_to_user (useraddr, &edata, sizeof (edata))) - return -EFAULT; - return 0; - } + /* Otherwise, we're up to avoid breaking scripts */ + return 1; +} - case ETHTOOL_SMSGLVL: { /* set message-level */ - struct ethtool_value edata; +static u32 usbnet_get_msglevel (struct net_device *net) +{ + struct usbnet *dev = net->priv; - if (copy_from_user (&edata, useraddr, sizeof (edata))) - return -EFAULT; - dev->msg_level = edata.data; - return 0; - } - - /* could also map RINGPARAM to RX/TX QLEN */ + return dev->msg_level; +} - } - /* Note that the ethtool user space code requires EOPNOTSUPP */ - return -EOPNOTSUPP; +static void usbnet_set_msglevel (struct net_device *net, u32 level) +{ + struct usbnet *dev = net->priv; + + dev->msg_level = level; } static int usbnet_ioctl (struct net_device *net, struct ifreq *rq, int cmd) { - if (cmd == SIOCETHTOOL) - return usbnet_ethtool_ioctl (net, (void __user *)rq->ifr_data); - #ifdef NEED_MII { struct usbnet *dev = (struct usbnet *)net->priv; @@ -2889,6 +2864,7 @@ net->watchdog_timeo = TX_TIMEOUT_JIFFIES; net->tx_timeout = usbnet_tx_timeout; net->do_ioctl = usbnet_ioctl; + net->ethtool_ops = &usbnet_ethtool_ops; // allow device-specific bind/init procedures // NOTE net->name still not usable ... @@ -3167,6 +3143,14 @@ .disconnect = usbnet_disconnect, }; +/* Default ethtool_ops assigned. Devices can override in their bind() routine */ +static struct ethtool_ops usbnet_ethtool_ops = { + .get_drvinfo = usbnet_get_drvinfo, + .get_link = usbnet_get_link, + .get_msglevel = usbnet_get_msglevel, + .set_msglevel = usbnet_set_msglevel, +}; + /*-------------------------------------------------------------------------*/ static int __init usbnet_init (void)
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel