Skip to content

Commit

Permalink
bcma: return error in bcma_sprom_get() when fallback fails
Browse files Browse the repository at this point in the history
When not SPROM is available a fallback mechanism is used. However,
when that fails the code currently continues. This patch assures
that the bcma_sprom_get() function aborts when that happens.

Cc: Rafal Milecki <zajec5@gmail.com>
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Arend van Spriel authored and John W. Linville committed Mar 6, 2012
1 parent 5c17ddc commit 4ac887c
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions drivers/bcma/sprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,23 @@ int bcma_arch_register_fallback_sprom(int (*sprom_callback)(struct bcma_bus *bus
static int bcma_fill_sprom_with_fallback(struct bcma_bus *bus,
struct ssb_sprom *out)
{
if (!get_fallback_sprom)
return -ENOENT;
int err;

return get_fallback_sprom(bus, out);
if (!get_fallback_sprom) {
err = -ENOENT;
goto fail;
}

err = get_fallback_sprom(bus, out);
if (err)
goto fail;

pr_debug("Using SPROM revision %d provided by"
" platform.\n", bus->sprom.revision);
return 0;
fail:
pr_warn("Using fallback SPROM failed (err %d)\n", err);
return err;
}

/**************************************************
Expand Down Expand Up @@ -317,13 +330,7 @@ int bcma_sprom_get(struct bcma_bus *bus)
* available for this device in some other storage.
*/
err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
if (err) {
pr_warn("Using fallback SPROM failed (err %d)\n", err);
} else {
pr_debug("Using SPROM revision %d provided by"
" platform.\n", bus->sprom.revision);
return 0;
}
return err;
}

sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
Expand Down

0 comments on commit 4ac887c

Please sign in to comment.