Greg KH wrote:
On Fri, Aug 29, 2003 at 08:04:34AM -0400, David T Hollis wrote:
[EMAIL PROTECTED], 2003-08-29 07:56:36-04:00, [EMAIL PROTECTED]
Add ethtool_ops support to usbnet
Hm, I get a confict when trying to apply this patch. Can you rediff it,
or just wait for me to sync back up with Linus?
thanks,
greg k-h
Sorry to take so long turning this around. It should apply cleanly to
the latest revs of usbnet in Bitkeeper.
--- usb-2.5/drivers/usb/net/usbnet.c 2003-09-06 09:42:19.927586568 -0400
+++ linux-2.6.0-test2-mm2/drivers/usb/net/usbnet.c 2003-09-06 09:50:46.209620000
-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)
{
@@ -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)