aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/bcma/sprom.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index 5386cddba43e..c96f71c183cd 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -502,7 +502,6 @@ static bool bcma_sprom_onchip_available(struct bcma_bus *bus)
502 case BCMA_CHIP_ID_BCM4331: 502 case BCMA_CHIP_ID_BCM4331:
503 present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT; 503 present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
504 break; 504 break;
505
506 case BCMA_CHIP_ID_BCM43224: 505 case BCMA_CHIP_ID_BCM43224:
507 case BCMA_CHIP_ID_BCM43225: 506 case BCMA_CHIP_ID_BCM43225:
508 /* for these chips OTP is always available */ 507 /* for these chips OTP is always available */
@@ -550,7 +549,8 @@ int bcma_sprom_get(struct bcma_bus *bus)
550{ 549{
551 u16 offset = BCMA_CC_SPROM; 550 u16 offset = BCMA_CC_SPROM;
552 u16 *sprom; 551 u16 *sprom;
553 int err = 0; 552 size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4, };
553 int i, err = 0;
554 554
555 if (!bus->drv_cc.core) 555 if (!bus->drv_cc.core)
556 return -EOPNOTSUPP; 556 return -EOPNOTSUPP;
@@ -579,32 +579,37 @@ int bcma_sprom_get(struct bcma_bus *bus)
579 } 579 }
580 } 580 }
581 581
582 sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
583 GFP_KERNEL);
584 if (!sprom)
585 return -ENOMEM;
586
587 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 || 582 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
588 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431) 583 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
589 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false); 584 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
590 585
591 bcma_debug(bus, "SPROM offset 0x%x\n", offset); 586 bcma_debug(bus, "SPROM offset 0x%x\n", offset);
592 bcma_sprom_read(bus, offset, sprom, SSB_SPROMSIZE_WORDS_R4); 587 for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) {
588 size_t words = sprom_sizes[i];
589
590 sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
591 if (!sprom)
592 return -ENOMEM;
593
594 bcma_sprom_read(bus, offset, sprom, words);
595 err = bcma_sprom_valid(sprom, words);
596 if (!err)
597 break;
598
599 kfree(sprom);
600 }
593 601
594 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 || 602 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
595 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431) 603 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
596 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true); 604 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
597 605
598 err = bcma_sprom_valid(sprom, SSB_SPROMSIZE_WORDS_R4);
599 if (err) { 606 if (err) {
600 bcma_warn(bus, "invalid sprom read from the PCIe card, try to use fallback sprom\n"); 607 bcma_warn(bus, "Invalid SPROM read from the PCIe card, trying to use fallback SPROM\n");
601 err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); 608 err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
602 goto out; 609 } else {
610 bcma_sprom_extract_r8(bus, sprom);
611 kfree(sprom);
603 } 612 }
604 613
605 bcma_sprom_extract_r8(bus, sprom);
606
607out:
608 kfree(sprom);
609 return err; 614 return err;
610} 615}