1 --- a/drivers/net/usb/smsc95xx.c
2 +++ b/drivers/net/usb/smsc95xx.c
4 #define SUSPEND_SUSPEND3 (0x08)
5 #define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \
6 SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3)
7 +#define MAC_ADDR_LEN (6)
11 @@ -76,6 +77,10 @@ static bool turbo_mode = true;
12 module_param(turbo_mode, bool, 0644);
13 MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");
15 +static char *macaddr = ":";
16 +module_param(macaddr, charp, 0);
17 +MODULE_PARM_DESC(macaddr, "MAC address");
19 static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index,
22 @@ -765,8 +770,59 @@ static int smsc95xx_ioctl(struct net_dev
23 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
26 +/* Check the macaddr module parameter for a MAC address */
27 +static int smsc95xx_is_macaddr_param(struct usbnet *dev, u8 *dev_mac)
29 + int i, j, got_num, num;
30 + u8 mtbl[MAC_ADDR_LEN];
32 + if (macaddr[0] == ':')
39 + while (j < MAC_ADDR_LEN) {
40 + if (macaddr[i] && macaddr[i] != ':') {
42 + if ('0' <= macaddr[i] && macaddr[i] <= '9')
43 + num = num * 16 + macaddr[i] - '0';
44 + else if ('A' <= macaddr[i] && macaddr[i] <= 'F')
45 + num = num * 16 + 10 + macaddr[i] - 'A';
46 + else if ('a' <= macaddr[i] && macaddr[i] <= 'f')
47 + num = num * 16 + 10 + macaddr[i] - 'a';
51 + } else if (got_num == 2) {
52 + mtbl[j++] = (u8) num;
61 + if (j == MAC_ADDR_LEN) {
62 + netif_dbg(dev, ifup, dev->net, "Overriding MAC address with: "
63 + "%02x:%02x:%02x:%02x:%02x:%02x\n", mtbl[0], mtbl[1], mtbl[2],
64 + mtbl[3], mtbl[4], mtbl[5]);
65 + for (i = 0; i < MAC_ADDR_LEN; i++)
66 + dev_mac[i] = mtbl[i];
73 static void smsc95xx_init_mac_address(struct usbnet *dev)
75 + /* Check module parameters */
76 + if (smsc95xx_is_macaddr_param(dev, dev->net->dev_addr))
79 /* try reading mac address from EEPROM */
80 if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
81 dev->net->dev_addr) == 0) {