Skip to content

Commit 03ad032

Browse files
PeterHolikdavem330
authored andcommitted
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>
1 parent bb9e63e commit 03ad032

3 files changed

Lines changed: 33 additions & 32 deletions

File tree

‎drivers/net/usb/cdc_ether.c‎

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/init.h>
2626
#include <linux/netdevice.h>
2727
#include <linux/etherdevice.h>
28-
#include <linux/ctype.h>
2928
#include <linux/ethtool.h>
3029
#include <linux/workqueue.h>
3130
#include <linux/mii.h>
@@ -389,36 +388,6 @@ static void cdc_status(struct usbnet *dev, struct urb *urb)
389388
}
390389
}
391390

392-
static 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-
402-
static inline int
403-
get_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-
422391
static int cdc_bind(struct usbnet *dev, struct usb_interface *intf)
423392
{
424393
int status;
@@ -428,7 +397,7 @@ static int cdc_bind(struct usbnet *dev, struct usb_interface *intf)
428397
if (status < 0)
429398
return status;
430399

431-
status = get_ethernet_addr(dev, info->ether);
400+
status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress);
432401
if (status < 0) {
433402
usb_set_intfdata(info->data, NULL);
434403
usb_driver_release_interface(driver_of(intf), info->data);

‎drivers/net/usb/usbnet.c‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/init.h>
3838
#include <linux/netdevice.h>
3939
#include <linux/etherdevice.h>
40+
#include <linux/ctype.h>
4041
#include <linux/ethtool.h>
4142
#include <linux/workqueue.h>
4243
#include <linux/mii.h>
@@ -156,6 +157,36 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
156157
}
157158
EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
158159

160+
static 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+
170+
int 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+
}
188+
EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
189+
159190
static void intr_complete (struct urb *urb);
160191

161192
static int init_status (struct usbnet *dev, struct usb_interface *intf)

‎include/linux/usb/usbnet.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ extern void usbnet_tx_timeout (struct net_device *net);
183183
extern int usbnet_change_mtu (struct net_device *net, int new_mtu);
184184

185185
extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *);
186+
extern int usbnet_get_ethernet_addr(struct usbnet *, int);
186187
extern void usbnet_defer_kevent (struct usbnet *, int);
187188
extern void usbnet_skb_return (struct usbnet *, struct sk_buff *);
188189
extern void usbnet_unlink_rx_urbs(struct usbnet *);

0 commit comments

Comments
 (0)