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