diff options
Diffstat (limited to 'drivers/net/usb/asix.c')
-rw-r--r-- | drivers/net/usb/asix.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c index 20e34608fa4a..9e05639435f2 100644 --- a/drivers/net/usb/asix.c +++ b/drivers/net/usb/asix.c | |||
@@ -54,6 +54,7 @@ static const char driver_name [] = "asix"; | |||
54 | #define AX_CMD_WRITE_IPG0 0x12 | 54 | #define AX_CMD_WRITE_IPG0 0x12 |
55 | #define AX_CMD_WRITE_IPG1 0x13 | 55 | #define AX_CMD_WRITE_IPG1 0x13 |
56 | #define AX_CMD_READ_NODE_ID 0x13 | 56 | #define AX_CMD_READ_NODE_ID 0x13 |
57 | #define AX_CMD_WRITE_NODE_ID 0x14 | ||
57 | #define AX_CMD_WRITE_IPG2 0x14 | 58 | #define AX_CMD_WRITE_IPG2 0x14 |
58 | #define AX_CMD_WRITE_MULTI_FILTER 0x16 | 59 | #define AX_CMD_WRITE_MULTI_FILTER 0x16 |
59 | #define AX88172_CMD_READ_NODE_ID 0x17 | 60 | #define AX88172_CMD_READ_NODE_ID 0x17 |
@@ -165,6 +166,7 @@ static const char driver_name [] = "asix"; | |||
165 | /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ | 166 | /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ |
166 | struct asix_data { | 167 | struct asix_data { |
167 | u8 multi_filter[AX_MCAST_FILTER_SIZE]; | 168 | u8 multi_filter[AX_MCAST_FILTER_SIZE]; |
169 | u8 mac_addr[ETH_ALEN]; | ||
168 | u8 phymode; | 170 | u8 phymode; |
169 | u8 ledmode; | 171 | u8 ledmode; |
170 | u8 eeprom_len; | 172 | u8 eeprom_len; |
@@ -732,6 +734,30 @@ static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd) | |||
732 | return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); | 734 | return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); |
733 | } | 735 | } |
734 | 736 | ||
737 | static int asix_set_mac_address(struct net_device *net, void *p) | ||
738 | { | ||
739 | struct usbnet *dev = netdev_priv(net); | ||
740 | struct asix_data *data = (struct asix_data *)&dev->data; | ||
741 | struct sockaddr *addr = p; | ||
742 | |||
743 | if (netif_running(net)) | ||
744 | return -EBUSY; | ||
745 | if (!is_valid_ether_addr(addr->sa_data)) | ||
746 | return -EADDRNOTAVAIL; | ||
747 | |||
748 | memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); | ||
749 | |||
750 | /* We use the 20 byte dev->data | ||
751 | * for our 6 byte mac buffer | ||
752 | * to avoid allocating memory that | ||
753 | * is tricky to free later */ | ||
754 | memcpy(data->mac_addr, addr->sa_data, ETH_ALEN); | ||
755 | asix_write_cmd_async(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, | ||
756 | data->mac_addr); | ||
757 | |||
758 | return 0; | ||
759 | } | ||
760 | |||
735 | /* We need to override some ethtool_ops so we require our | 761 | /* We need to override some ethtool_ops so we require our |
736 | own structure so we don't interfere with other usbnet | 762 | own structure so we don't interfere with other usbnet |
737 | devices that may be connected at the same time. */ | 763 | devices that may be connected at the same time. */ |
@@ -919,7 +945,7 @@ static const struct net_device_ops ax88772_netdev_ops = { | |||
919 | .ndo_start_xmit = usbnet_start_xmit, | 945 | .ndo_start_xmit = usbnet_start_xmit, |
920 | .ndo_tx_timeout = usbnet_tx_timeout, | 946 | .ndo_tx_timeout = usbnet_tx_timeout, |
921 | .ndo_change_mtu = usbnet_change_mtu, | 947 | .ndo_change_mtu = usbnet_change_mtu, |
922 | .ndo_set_mac_address = eth_mac_addr, | 948 | .ndo_set_mac_address = asix_set_mac_address, |
923 | .ndo_validate_addr = eth_validate_addr, | 949 | .ndo_validate_addr = eth_validate_addr, |
924 | .ndo_do_ioctl = asix_ioctl, | 950 | .ndo_do_ioctl = asix_ioctl, |
925 | .ndo_set_multicast_list = asix_set_multicast, | 951 | .ndo_set_multicast_list = asix_set_multicast, |
@@ -1213,7 +1239,7 @@ static const struct net_device_ops ax88178_netdev_ops = { | |||
1213 | .ndo_stop = usbnet_stop, | 1239 | .ndo_stop = usbnet_stop, |
1214 | .ndo_start_xmit = usbnet_start_xmit, | 1240 | .ndo_start_xmit = usbnet_start_xmit, |
1215 | .ndo_tx_timeout = usbnet_tx_timeout, | 1241 | .ndo_tx_timeout = usbnet_tx_timeout, |
1216 | .ndo_set_mac_address = eth_mac_addr, | 1242 | .ndo_set_mac_address = asix_set_mac_address, |
1217 | .ndo_validate_addr = eth_validate_addr, | 1243 | .ndo_validate_addr = eth_validate_addr, |
1218 | .ndo_set_multicast_list = asix_set_multicast, | 1244 | .ndo_set_multicast_list = asix_set_multicast, |
1219 | .ndo_do_ioctl = asix_ioctl, | 1245 | .ndo_do_ioctl = asix_ioctl, |