aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ssb
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-02-20 15:11:05 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-03-06 16:24:23 -0500
commite5652756ff36ed9e1283121f788e6a17117efcab (patch)
tree188efe8dec8a47f5a09d8fb18c357668852390ac /drivers/ssb
parent8524982847ff00b66ffb89314c342c51f4138ee7 (diff)
ssb: pci: Standardize a function to get mac address
Don't require alignment of mac addresses to u16. Signed-off-by: Joe Perches <joe@perches.com> Tested-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/ssb')
-rw-r--r--drivers/ssb/pci.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c
index e9d94968f394..4ec0bdbf25ed 100644
--- a/drivers/ssb/pci.c
+++ b/drivers/ssb/pci.c
@@ -231,6 +231,15 @@ static inline u8 ssb_crc8(u8 crc, u8 data)
231 return t[crc ^ data]; 231 return t[crc ^ data];
232} 232}
233 233
234static void sprom_get_mac(char *mac, const u16 *in)
235{
236 int i;
237 for (i = 0; i < 3; i++) {
238 *mac++ = in[i];
239 *mac++ = in[i] >> 8;
240 }
241}
242
234static u8 ssb_sprom_crc(const u16 *sprom, u16 size) 243static u8 ssb_sprom_crc(const u16 *sprom, u16 size)
235{ 244{
236 int word; 245 int word;
@@ -341,8 +350,6 @@ static s8 r123_extract_antgain(u8 sprom_revision, const u16 *in,
341 350
342static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in) 351static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
343{ 352{
344 int i;
345 u16 v;
346 u16 loc[3]; 353 u16 loc[3];
347 354
348 if (out->revision == 3) /* rev 3 moved MAC */ 355 if (out->revision == 3) /* rev 3 moved MAC */
@@ -352,19 +359,10 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
352 loc[1] = SSB_SPROM1_ET0MAC; 359 loc[1] = SSB_SPROM1_ET0MAC;
353 loc[2] = SSB_SPROM1_ET1MAC; 360 loc[2] = SSB_SPROM1_ET1MAC;
354 } 361 }
355 for (i = 0; i < 3; i++) { 362 sprom_get_mac(out->il0mac, &in[SPOFF(loc[0])]);
356 v = in[SPOFF(loc[0]) + i];
357 *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
358 }
359 if (out->revision < 3) { /* only rev 1-2 have et0, et1 */ 363 if (out->revision < 3) { /* only rev 1-2 have et0, et1 */
360 for (i = 0; i < 3; i++) { 364 sprom_get_mac(out->et0mac, &in[SPOFF(loc[1])]);
361 v = in[SPOFF(loc[1]) + i]; 365 sprom_get_mac(out->et1mac, &in[SPOFF(loc[2])]);
362 *(((__be16 *)out->et0mac) + i) = cpu_to_be16(v);
363 }
364 for (i = 0; i < 3; i++) {
365 v = in[SPOFF(loc[2]) + i];
366 *(((__be16 *)out->et1mac) + i) = cpu_to_be16(v);
367 }
368 } 366 }
369 SPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0); 367 SPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0);
370 SPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A, 368 SPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A,
@@ -454,19 +452,15 @@ static void sprom_extract_r458(struct ssb_sprom *out, const u16 *in)
454 452
455static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in) 453static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
456{ 454{
457 int i;
458 u16 v;
459 u16 il0mac_offset; 455 u16 il0mac_offset;
460 456
461 if (out->revision == 4) 457 if (out->revision == 4)
462 il0mac_offset = SSB_SPROM4_IL0MAC; 458 il0mac_offset = SSB_SPROM4_IL0MAC;
463 else 459 else
464 il0mac_offset = SSB_SPROM5_IL0MAC; 460 il0mac_offset = SSB_SPROM5_IL0MAC;
465 /* extract the MAC address */ 461
466 for (i = 0; i < 3; i++) { 462 sprom_get_mac(out->il0mac, &in[SPOFF(il0mac_offset)]);
467 v = in[SPOFF(il0mac_offset) + i]; 463
468 *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
469 }
470 SPEX(et0phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET0A, 0); 464 SPEX(et0phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET0A, 0);
471 SPEX(et1phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET1A, 465 SPEX(et1phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET1A,
472 SSB_SPROM4_ETHPHY_ET1A_SHIFT); 466 SSB_SPROM4_ETHPHY_ET1A_SHIFT);
@@ -530,7 +524,7 @@ static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
530static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in) 524static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
531{ 525{
532 int i; 526 int i;
533 u16 v, o; 527 u16 o;
534 u16 pwr_info_offset[] = { 528 u16 pwr_info_offset[] = {
535 SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1, 529 SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
536 SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3 530 SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
@@ -539,10 +533,8 @@ static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
539 ARRAY_SIZE(out->core_pwr_info)); 533 ARRAY_SIZE(out->core_pwr_info));
540 534
541 /* extract the MAC address */ 535 /* extract the MAC address */
542 for (i = 0; i < 3; i++) { 536 sprom_get_mac(out->il0mac, &in[SPOFF(SSB_SPROM8_IL0MAC)]);
543 v = in[SPOFF(SSB_SPROM8_IL0MAC) + i]; 537
544 *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
545 }
546 SPEX(board_rev, SSB_SPROM8_BOARDREV, 0xFFFF, 0); 538 SPEX(board_rev, SSB_SPROM8_BOARDREV, 0xFFFF, 0);
547 SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8); 539 SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8);
548 SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0); 540 SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0);