Commit 714c25ed authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] USB net drivers, ethtool bus_info

USB net drivers, ethtool bus_info

This patch makes the USB network drivers that have ethtool support
expose only those stable IDs ... no more references to unstable values
like dev->bus->busnum (changes depending on order of modprobe)
or dev->devnum (assigned not quite randomly during enumeration :).

This supports more intelligent policies for user mode tools, such
as "always assign this address to the device on that port", as well
as making troubleshooting more practical when there are multiple
devices (of a given type) present ... you can tell which is which.
parent 3668d7cd
...@@ -655,7 +655,6 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr) ...@@ -655,7 +655,6 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
{ {
struct catc *catc = dev->priv; struct catc *catc = dev->priv;
u32 cmd; u32 cmd;
char tmp[40];
if (get_user(cmd, (u32 *)useraddr)) if (get_user(cmd, (u32 *)useraddr))
return -EFAULT; return -EFAULT;
...@@ -666,8 +665,7 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr) ...@@ -666,8 +665,7 @@ static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO}; struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
strncpy(info.driver, SHORT_DRIVER_DESC, ETHTOOL_BUSINFO_LEN); strncpy(info.driver, SHORT_DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN); strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
sprintf(tmp, "usb%d:%d", catc->usbdev->bus->busnum, catc->usbdev->devnum); usb_make_path (catc->usbdev, info.bus_info, sizeof info.bus_info);
strncpy(info.bus_info, tmp,ETHTOOL_BUSINFO_LEN);
if (copy_to_user(useraddr, &info, sizeof(info))) if (copy_to_user(useraddr, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -909,9 +907,9 @@ static void *catc_probe(struct usb_device *usbdev, unsigned int ifnum, const str ...@@ -909,9 +907,9 @@ static void *catc_probe(struct usb_device *usbdev, unsigned int ifnum, const str
f5u011_rxmode(catc, catc->rxmode); f5u011_rxmode(catc, catc->rxmode);
} }
dbg("Init done."); dbg("Init done.");
printk(KERN_INFO "%s: %s USB Ethernet at usb%d:%d.%d, ", printk(KERN_INFO "%s: %s USB Ethernet at usb-%s-%s/%d, ",
netdev->name, (catc->is_f5u011) ? "Belkin F5U011" : "CATC EL1210A NetMate", netdev->name, (catc->is_f5u011) ? "Belkin F5U011" : "CATC EL1210A NetMate",
usbdev->bus->busnum, usbdev->devnum, ifnum); usbdev->bus->bus_name, usbdev->devpath, ifnum);
for (i = 0; i < 5; i++) printk("%2.2x:", netdev->dev_addr[i]); for (i = 0; i < 5; i++) printk("%2.2x:", netdev->dev_addr[i]);
printk("%2.2x.\n", netdev->dev_addr[i]); printk("%2.2x.\n", netdev->dev_addr[i]);
return catc; return catc;
......
...@@ -798,7 +798,6 @@ static int pegasus_ethtool_ioctl(struct net_device *net, void *uaddr) ...@@ -798,7 +798,6 @@ static int pegasus_ethtool_ioctl(struct net_device *net, void *uaddr)
{ {
pegasus_t *pegasus; pegasus_t *pegasus;
int cmd; int cmd;
char tmp[128];
pegasus = net->priv; pegasus = net->priv;
if (get_user(cmd, (int *)uaddr)) if (get_user(cmd, (int *)uaddr))
...@@ -808,9 +807,7 @@ static int pegasus_ethtool_ioctl(struct net_device *net, void *uaddr) ...@@ -808,9 +807,7 @@ static int pegasus_ethtool_ioctl(struct net_device *net, void *uaddr)
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO}; struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
strncpy(info.driver, DRIVER_DESC, ETHTOOL_BUSINFO_LEN); strncpy(info.driver, DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN); strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
sprintf(tmp, "usb%d:%d", pegasus->usb->bus->busnum, usb_make_path (pegasus->usb, info.bus_info, sizeof info.bus_info);
pegasus->usb->devnum);
strncpy(info.bus_info, tmp, ETHTOOL_BUSINFO_LEN);
if (copy_to_user(uaddr, &info, sizeof(info))) if (copy_to_user(uaddr, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
return 0; return 0;
......
...@@ -552,7 +552,6 @@ static int rtl8150_ethtool_ioctl(struct net_device *netdev, void *uaddr) ...@@ -552,7 +552,6 @@ static int rtl8150_ethtool_ioctl(struct net_device *netdev, void *uaddr)
{ {
rtl8150_t *dev; rtl8150_t *dev;
int cmd; int cmd;
char tmp[128];
dev = netdev->priv; dev = netdev->priv;
if (get_user(cmd, (int *)uaddr)) if (get_user(cmd, (int *)uaddr))
...@@ -564,9 +563,7 @@ static int rtl8150_ethtool_ioctl(struct net_device *netdev, void *uaddr) ...@@ -564,9 +563,7 @@ static int rtl8150_ethtool_ioctl(struct net_device *netdev, void *uaddr)
strncpy(info.driver, DRIVER_DESC, ETHTOOL_BUSINFO_LEN); strncpy(info.driver, DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN); strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
sprintf(tmp, "usb%d:%d", dev->udev->bus->busnum, usb_make_path (dev->udev, info.bus_info, sizeof info.bus_info);
dev->udev->devnum);
strncpy(info.bus_info, tmp, ETHTOOL_BUSINFO_LEN);
if (copy_to_user(uaddr, &info, sizeof(info))) if (copy_to_user(uaddr, &info, sizeof(info)))
return -EFAULT; return -EFAULT;
return 0; return 0;
......
...@@ -834,10 +834,10 @@ static void nc_dump_registers (struct usbnet *dev) ...@@ -834,10 +834,10 @@ static void nc_dump_registers (struct usbnet *dev)
static inline void nc_dump_usbctl (struct usbnet *dev, u16 usbctl) static inline void nc_dump_usbctl (struct usbnet *dev, u16 usbctl)
{ {
#ifdef DEBUG #ifdef DEBUG
devdbg (dev, "net1080 %03d/%03d usbctl 0x%x:%s%s%s%s%s;" devdbg (dev, "net1080 %s-%s usbctl 0x%x:%s%s%s%s%s;"
" this%s%s;" " this%s%s;"
" other%s%s; r/o 0x%x", " other%s%s; r/o 0x%x",
dev->udev->bus->busnum, dev->udev->devnum, dev->udev->bus->bus_name, dev->udev->devpath,
usbctl, usbctl,
(usbctl & USBCTL_ENABLE_LANG) ? " lang" : "", (usbctl & USBCTL_ENABLE_LANG) ? " lang" : "",
(usbctl & USBCTL_ENABLE_MFGR) ? " mfgr" : "", (usbctl & USBCTL_ENABLE_MFGR) ? " mfgr" : "",
...@@ -879,10 +879,10 @@ static inline void nc_dump_usbctl (struct usbnet *dev, u16 usbctl) ...@@ -879,10 +879,10 @@ static inline void nc_dump_usbctl (struct usbnet *dev, u16 usbctl)
static inline void nc_dump_status (struct usbnet *dev, u16 status) static inline void nc_dump_status (struct usbnet *dev, u16 status)
{ {
#ifdef DEBUG #ifdef DEBUG
devdbg (dev, "net1080 %03d/%03d status 0x%x:" devdbg (dev, "net1080 %s-%s status 0x%x:"
" this (%c) PKT=%d%s%s%s;" " this (%c) PKT=%d%s%s%s;"
" other PKT=%d%s%s%s; unspec 0x%x", " other PKT=%d%s%s%s; unspec 0x%x",
dev->udev->bus->busnum, dev->udev->devnum, dev->udev->bus->bus_name, dev->udev->devpath,
status, status,
// XXX the packet counts don't seem right // XXX the packet counts don't seem right
...@@ -917,8 +917,8 @@ static inline void nc_dump_status (struct usbnet *dev, u16 status) ...@@ -917,8 +917,8 @@ static inline void nc_dump_status (struct usbnet *dev, u16 status)
static inline void nc_dump_ttl (struct usbnet *dev, u16 ttl) static inline void nc_dump_ttl (struct usbnet *dev, u16 ttl)
{ {
#ifdef DEBUG #ifdef DEBUG
devdbg (dev, "net1080 %03d/%03d ttl 0x%x this = %d, other = %d", devdbg (dev, "net1080 %s-%s ttl 0x%x this = %d, other = %d",
dev->udev->bus->busnum, dev->udev->devnum, dev->udev->bus->bus_name, dev->udev->devpath,
ttl, ttl,
TTL_THIS (ttl), TTL_THIS (ttl),
...@@ -941,7 +941,8 @@ static int net1080_reset (struct usbnet *dev) ...@@ -941,7 +941,8 @@ static int net1080_reset (struct usbnet *dev)
// nc_dump_registers (dev); // nc_dump_registers (dev);
if ((retval = nc_register_read (dev, REG_STATUS, vp)) < 0) { if ((retval = nc_register_read (dev, REG_STATUS, vp)) < 0) {
dbg ("can't read dev %d status: %d", dev->udev->devnum, retval); dbg ("can't read %s-%s status: %d",
dev->udev->bus->bus_name, dev->udev->devpath, retval);
goto done; goto done;
} }
status = *vp; status = *vp;
...@@ -1504,10 +1505,9 @@ static int usbnet_open (struct net_device *net) ...@@ -1504,10 +1505,9 @@ static int usbnet_open (struct net_device *net)
// put into "known safe" state // put into "known safe" state
if (info->reset && (retval = info->reset (dev)) < 0) { if (info->reset && (retval = info->reset (dev)) < 0) {
devinfo (dev, "open reset fail (%d) usbnet bus%d%s, %s", devinfo (dev, "open reset fail (%d) usbnet usb-%s-%s, %s",
retval, retval,
// FIXME busnum is unstable dev->udev->bus->bus_name, dev->udev->devpath,
dev->udev->bus->busnum, dev->udev->devpath,
info->description); info->description);
goto done; goto done;
} }
...@@ -1557,9 +1557,7 @@ static int usbnet_ethtool_ioctl (struct net_device *net, void *useraddr) ...@@ -1557,9 +1557,7 @@ static int usbnet_ethtool_ioctl (struct net_device *net, void *useraddr)
strncpy (info.version, DRIVER_VERSION, sizeof info.version); strncpy (info.version, DRIVER_VERSION, sizeof info.version);
strncpy (info.fw_version, dev->driver_info->description, strncpy (info.fw_version, dev->driver_info->description,
sizeof info.fw_version); sizeof info.fw_version);
snprintf (info.bus_info, sizeof info.bus_info, "USB bus%d%s", usb_make_path (dev->udev, info.bus_info, sizeof info.bus_info);
/* FIXME busnums are bogus/unstable IDs */
dev->udev->bus->busnum, dev->udev->devpath);
if (copy_to_user (useraddr, &info, sizeof (info))) if (copy_to_user (useraddr, &info, sizeof (info)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -1847,9 +1845,8 @@ static void usbnet_disconnect (struct usb_device *udev, void *ptr) ...@@ -1847,9 +1845,8 @@ static void usbnet_disconnect (struct usb_device *udev, void *ptr)
{ {
struct usbnet *dev = (struct usbnet *) ptr; struct usbnet *dev = (struct usbnet *) ptr;
devinfo (dev, "unregister usbnet bus%d%s, %s", devinfo (dev, "unregister usbnet usb-%s-%s, %s",
// FIXME busnum is unstable udev->bus->bus_name, udev->devpath,
udev->bus->busnum, udev->devpath,
dev->driver_info->description); dev->driver_info->description);
unregister_netdev (&dev->net); unregister_netdev (&dev->net);
...@@ -1938,9 +1935,8 @@ usbnet_probe (struct usb_device *udev, unsigned ifnum, ...@@ -1938,9 +1935,8 @@ usbnet_probe (struct usb_device *udev, unsigned ifnum,
net->do_ioctl = usbnet_ioctl; net->do_ioctl = usbnet_ioctl;
register_netdev (&dev->net); register_netdev (&dev->net);
devinfo (dev, "register usbnet bus%d%s, %s", devinfo (dev, "register usbnet usb-%s-%s, %s",
// FIXME busnum is unstable udev->bus->bus_name, udev->devpath,
udev->bus->busnum, udev->devpath,
dev->driver_info->description); dev->driver_info->description);
// ok, it's ready to go. // ok, it's ready to go.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment