aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPeter Holik <peter@holik.at>2009-04-18 03:24:17 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-21 04:55:59 -0400
commit03ad032bb78b2732b607ed198e951240e1d21e59 (patch)
tree3bf7f5927e0545617676ad6feef07fa932db4ad4 /drivers
parentbb9e63e27117b469a151c61fb0045a8ec4cced5d (diff)
export usbnet_get_ethernet_addr from usbnet and fixed cdc_ether.c
because of using the same function get_ethernet_addr as cdc_ether.c i export usbnet_get_ethernet_addr from usbnet and fixed cdc_ether (suggested by Oliver Neukum). Signed-off-by: Peter Holik <peter@holik.at> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/usb/cdc_ether.c33
-rw-r--r--drivers/net/usb/usbnet.c31
2 files changed, 32 insertions, 32 deletions
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 55e8ecc3a9e5..01fd528306ec 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -25,7 +25,6 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/netdevice.h> 26#include <linux/netdevice.h>
27#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
28#include <linux/ctype.h>
29#include <linux/ethtool.h> 28#include <linux/ethtool.h>
30#include <linux/workqueue.h> 29#include <linux/workqueue.h>
31#include <linux/mii.h> 30#include <linux/mii.h>
@@ -389,36 +388,6 @@ static void cdc_status(struct usbnet *dev, struct urb *urb)
389 } 388 }
390} 389}
391 390
392static u8 nibble(unsigned char c)
393{
394 if (likely(isdigit(c)))
395 return c - '0';
396 c = toupper(c);
397 if (likely(isxdigit(c)))
398 return 10 + c - 'A';
399 return 0;
400}
401
402static inline int
403get_ethernet_addr(struct usbnet *dev, struct usb_cdc_ether_desc *e)
404{
405 int tmp, i;
406 unsigned char buf [13];
407
408 tmp = usb_string(dev->udev, e->iMACAddress, buf, sizeof buf);
409 if (tmp != 12) {
410 dev_dbg(&dev->udev->dev,
411 "bad MAC string %d fetch, %d\n", e->iMACAddress, tmp);
412 if (tmp >= 0)
413 tmp = -EINVAL;
414 return tmp;
415 }
416 for (i = tmp = 0; i < 6; i++, tmp += 2)
417 dev->net->dev_addr [i] =
418 (nibble(buf [tmp]) << 4) + nibble(buf [tmp + 1]);
419 return 0;
420}
421
422static int cdc_bind(struct usbnet *dev, struct usb_interface *intf) 391static int cdc_bind(struct usbnet *dev, struct usb_interface *intf)
423{ 392{
424 int status; 393 int status;
@@ -428,7 +397,7 @@ static int cdc_bind(struct usbnet *dev, struct usb_interface *intf)
428 if (status < 0) 397 if (status < 0)
429 return status; 398 return status;
430 399
431 status = get_ethernet_addr(dev, info->ether); 400 status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress);
432 if (status < 0) { 401 if (status < 0) {
433 usb_set_intfdata(info->data, NULL); 402 usb_set_intfdata(info->data, NULL);
434 usb_driver_release_interface(driver_of(intf), info->data); 403 usb_driver_release_interface(driver_of(intf), info->data);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 2b8b9036aff6..c94de6243140 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)