diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2010-03-09 07:24:38 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-10 10:36:21 -0500 |
commit | 7f29a3baa825725d29db399663790d15c78cddcf (patch) | |
tree | 40ed88ca5a2e7a9788bf0b1d5918ecad65a99560 /drivers/net/usb | |
parent | 2b4c32972b9bcfee29d5e2c1b6f261dda5ef2a21 (diff) |
asix: fix setting mac address for AX88772
Setting new MAC address only worked when device was set to promiscuous mode.
Fix MAC address by writing new address to device using undocumented command
AX_CMD_READ_NODE_ID+1. Patch is tested with AX88772 device.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Acked-by: David Hollis <dhollis@davehollis.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-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, |