diff options
author | Tushar Behera <tushar.behera@linaro.org> | 2013-02-04 18:07:54 +0530 |
---|---|---|
committer | Tushar Behera <tushar.behera@linaro.org> | 2013-06-19 16:52:51 +0530 |
commit | ca1ac47252b01d538e2fe4f67c885381bfcce94d (patch) | |
tree | 0441447e03d31e7723892d5821d4524c0bd5d3eb /drivers | |
parent | 9d843d11f12d6b3b3d48a12e6b5b88228894581f (diff) |
asix: Add support to read MAC address from cmdline
Inherited from arch/mips/rb532/devices.c
Example: bootargs="mac=00:40:5c:26:0a:5b"
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/usb/asix_devices.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index ad5d1e4384d..defda0e64bd 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c @@ -44,6 +44,35 @@ struct ax88172_int_data { __le16 res3; } __packed; +static char asix_mac_addr[6]; +static int __init asix_setup_mac(char *macstr) +{ + int i, h, l; + + if (!macstr) + return 0; + + for (i = 0; i < 6; i++) { + if (i != 5 && *(macstr + 2) != ':') + return 0; + + h = hex_to_bin(*macstr++); + if (h == -1) + return 0; + + l = hex_to_bin(*macstr++); + if (l == -1) + return 0; + + macstr++; + asix_mac_addr[i] = (h << 4) + l; + } + + return 0; +} + +__setup("mac=", asix_setup_mac); + static void asix_status(struct usbnet *dev, struct urb *urb) { struct ax88172_int_data *event; @@ -62,6 +91,9 @@ static void asix_status(struct usbnet *dev, struct urb *urb) static void asix_set_netdev_dev_addr(struct usbnet *dev, u8 *addr) { + if (!is_valid_ether_addr(addr)) + memcpy(addr, asix_mac_addr, ETH_ALEN); + if (is_valid_ether_addr(addr)) { memcpy(dev->net->dev_addr, addr, ETH_ALEN); } else { |