diff options
author | Jiri Pirko <jiri@resnulli.us> | 2013-01-05 22:25:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-07 00:04:15 -0500 |
commit | efc61a3442da9fd17a61fcabef445534598f54a8 (patch) | |
tree | 885ee9e659de98c65128fe1b5f7ef8c4865405d5 /drivers/net/ethernet/ethoc.c | |
parent | b681b65d4fc0cad468c4caad02b0bc93d59b00df (diff) |
ethoc: fix mac address set
Function ethoc_set_mac_address() was incorrectly using passed pointer as
pointer to address, that is not correct.
Struct sockaddr have to be be used here.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ethoc.c')
-rw-r--r-- | drivers/net/ethernet/ethoc.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index b93062dac482..b51c81ac0b6f 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c | |||
@@ -771,20 +771,24 @@ static int ethoc_config(struct net_device *dev, struct ifmap *map) | |||
771 | return -ENOSYS; | 771 | return -ENOSYS; |
772 | } | 772 | } |
773 | 773 | ||
774 | static int ethoc_set_mac_address(struct net_device *dev, void *addr) | 774 | static void ethoc_do_set_mac_address(struct net_device *dev) |
775 | { | 775 | { |
776 | struct ethoc *priv = netdev_priv(dev); | 776 | struct ethoc *priv = netdev_priv(dev); |
777 | u8 *mac = (u8 *)addr; | 777 | unsigned char *mac = dev->dev_addr; |
778 | |||
779 | if (!is_valid_ether_addr(mac)) | ||
780 | return -EADDRNOTAVAIL; | ||
781 | 778 | ||
782 | ethoc_write(priv, MAC_ADDR0, (mac[2] << 24) | (mac[3] << 16) | | 779 | ethoc_write(priv, MAC_ADDR0, (mac[2] << 24) | (mac[3] << 16) | |
783 | (mac[4] << 8) | (mac[5] << 0)); | 780 | (mac[4] << 8) | (mac[5] << 0)); |
784 | ethoc_write(priv, MAC_ADDR1, (mac[0] << 8) | (mac[1] << 0)); | 781 | ethoc_write(priv, MAC_ADDR1, (mac[0] << 8) | (mac[1] << 0)); |
782 | } | ||
785 | 783 | ||
786 | memcpy(dev->dev_addr, mac, ETH_ALEN); | 784 | static int ethoc_set_mac_address(struct net_device *dev, void *p) |
785 | { | ||
786 | const struct sockaddr *addr = p; | ||
787 | 787 | ||
788 | if (!is_valid_ether_addr(addr->sa_data)) | ||
789 | return -EADDRNOTAVAIL; | ||
790 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); | ||
791 | ethoc_do_set_mac_address(dev); | ||
788 | return 0; | 792 | return 0; |
789 | } | 793 | } |
790 | 794 | ||
@@ -1060,11 +1064,7 @@ static int ethoc_probe(struct platform_device *pdev) | |||
1060 | random_mac = true; | 1064 | random_mac = true; |
1061 | } | 1065 | } |
1062 | 1066 | ||
1063 | ret = ethoc_set_mac_address(netdev, netdev->dev_addr); | 1067 | ethoc_do_set_mac_address(netdev); |
1064 | if (ret) { | ||
1065 | dev_err(&netdev->dev, "failed to set MAC address\n"); | ||
1066 | goto error; | ||
1067 | } | ||
1068 | 1068 | ||
1069 | if (random_mac) | 1069 | if (random_mac) |
1070 | netdev->addr_assign_type = NET_ADDR_RANDOM; | 1070 | netdev->addr_assign_type = NET_ADDR_RANDOM; |