diff options
author | olof@lixom.net <olof@lixom.net> | 2007-05-12 15:57:46 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-05-15 17:44:39 -0400 |
commit | 1af7f05628fab81fdf4412d757676412ba5db660 (patch) | |
tree | 4088aa83e616feaba7ed0bb37ce70d1c80c1e218 /drivers/net/pasemi_mac.c | |
parent | fd17825480b2de3076727c677f8e257623705963 (diff) |
pasemi_mac: Fix local-mac-address parsing
Turns out we have an old version of firmware that stores the mac address
in 'mac-address' as a string instead of a byte array. All versions that
use local-mac-address should have it as byte array, so no need to do
string parsing for that case.
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/pasemi_mac.c')
-rw-r--r-- | drivers/net/pasemi_mac.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c index 933d56476894..8d38425e46c3 100644 --- a/drivers/net/pasemi_mac.c +++ b/drivers/net/pasemi_mac.c | |||
@@ -85,6 +85,7 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac) | |||
85 | { | 85 | { |
86 | struct pci_dev *pdev = mac->pdev; | 86 | struct pci_dev *pdev = mac->pdev; |
87 | struct device_node *dn = pci_device_to_OF_node(pdev); | 87 | struct device_node *dn = pci_device_to_OF_node(pdev); |
88 | int len; | ||
88 | const u8 *maddr; | 89 | const u8 *maddr; |
89 | u8 addr[6]; | 90 | u8 addr[6]; |
90 | 91 | ||
@@ -94,9 +95,17 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac) | |||
94 | return -ENOENT; | 95 | return -ENOENT; |
95 | } | 96 | } |
96 | 97 | ||
97 | maddr = of_get_property(dn, "local-mac-address", NULL); | 98 | maddr = of_get_property(dn, "local-mac-address", &len); |
99 | |||
100 | if (maddr && len == 6) { | ||
101 | memcpy(mac->mac_addr, maddr, 6); | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | /* Some old versions of firmware mistakenly uses mac-address | ||
106 | * (and as a string) instead of a byte array in local-mac-address. | ||
107 | */ | ||
98 | 108 | ||
99 | /* Fall back to mac-address for older firmware */ | ||
100 | if (maddr == NULL) | 109 | if (maddr == NULL) |
101 | maddr = of_get_property(dn, "mac-address", NULL); | 110 | maddr = of_get_property(dn, "mac-address", NULL); |
102 | 111 | ||
@@ -106,6 +115,7 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac) | |||
106 | return -ENOENT; | 115 | return -ENOENT; |
107 | } | 116 | } |
108 | 117 | ||
118 | |||
109 | if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &addr[0], | 119 | if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &addr[0], |
110 | &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) != 6) { | 120 | &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) != 6) { |
111 | dev_warn(&pdev->dev, | 121 | dev_warn(&pdev->dev, |
@@ -113,7 +123,8 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac) | |||
113 | return -EINVAL; | 123 | return -EINVAL; |
114 | } | 124 | } |
115 | 125 | ||
116 | memcpy(mac->mac_addr, addr, sizeof(addr)); | 126 | memcpy(mac->mac_addr, addr, 6); |
127 | |||
117 | return 0; | 128 | return 0; |
118 | } | 129 | } |
119 | 130 | ||