aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb/usbnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/usb/usbnet.c')
-rw-r--r--drivers/net/usb/usbnet.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 47f68cfa7e21..22c0585a0319 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -37,6 +37,7 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/netdevice.h> 38#include <linux/netdevice.h>
39#include <linux/etherdevice.h> 39#include <linux/etherdevice.h>
40#include <linux/ctype.h>
40#include <linux/ethtool.h> 41#include <linux/ethtool.h>
41#include <linux/workqueue.h> 42#include <linux/workqueue.h>
42#include <linux/mii.h> 43#include <linux/mii.h>
@@ -156,6 +157,36 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
156} 157}
157EXPORT_SYMBOL_GPL(usbnet_get_endpoints); 158EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
158 159
160static u8 nibble(unsigned char c)
161{
162 if (likely(isdigit(c)))
163 return c - '0';
164 c = toupper(c);
165 if (likely(isxdigit(c)))
166 return 10 + c - 'A';
167 return 0;
168}
169
170int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
171{
172 int tmp, i;
173 unsigned char buf [13];
174
175 tmp = usb_string(dev->udev, iMACAddress, buf, sizeof buf);
176 if (tmp != 12) {
177 dev_dbg(&dev->udev->dev,
178 "bad MAC string %d fetch, %d\n", iMACAddress, tmp);
179 if (tmp >= 0)
180 tmp = -EINVAL;
181 return tmp;
182 }
183 for (i = tmp = 0; i < 6; i++, tmp += 2)
184 dev->net->dev_addr [i] =
185 (nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
186 return 0;
187}
188EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
189
159static void intr_complete (struct urb *urb); 190static void intr_complete (struct urb *urb);
160 191
161static int init_status (struct usbnet *dev, struct usb_interface *intf) 192static int init_status (struct usbnet *dev, struct usb_interface *intf)
@@ -1185,12 +1216,6 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1185#endif 1216#endif
1186 1217
1187 net->netdev_ops = &usbnet_netdev_ops; 1218 net->netdev_ops = &usbnet_netdev_ops;
1188#ifdef CONFIG_COMPAT_NET_DEV_OPS
1189 net->hard_start_xmit = usbnet_start_xmit;
1190 net->open = usbnet_open;
1191 net->stop = usbnet_stop;
1192 net->tx_timeout = usbnet_tx_timeout;
1193#endif
1194 net->watchdog_timeo = TX_TIMEOUT_JIFFIES; 1219 net->watchdog_timeo = TX_TIMEOUT_JIFFIES;
1195 net->ethtool_ops = &usbnet_ethtool_ops; 1220 net->ethtool_ops = &usbnet_ethtool_ops;
1196 1221