Skip to content

Commit eae8e50

Browse files
jwrdegoedeKalle Valo
authored andcommitted
brcmfmac: Add support for first trying to get a board specific nvram file
The nvram files which some brcmfmac chips need are board-specific. To be able to distribute these as part of linux-firmware, so that devices with such a wifi chip will work OOTB, multiple (one per board) versions must co-exist under /lib/firmware. This commit adds support for callers of the brcmfmac/firmware.c code to pass in a board_type parameter through the request structure. If that parameter is set then the code will first try to load chipmodel.board_type.txt before falling back to the old chipmodel.txt name. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent 5b58749 commit eae8e50

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,31 @@ static int brcmf_fw_complete_request(const struct firmware *fw,
532532
return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
533533
}
534534

535+
static int brcmf_fw_request_firmware(const struct firmware **fw,
536+
struct brcmf_fw *fwctx)
537+
{
538+
struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
539+
int ret;
540+
541+
/* nvram files are board-specific, first try a board-specific path */
542+
if (cur->type == BRCMF_FW_TYPE_NVRAM && fwctx->req->board_type) {
543+
char alt_path[BRCMF_FW_NAME_LEN];
544+
545+
strlcpy(alt_path, cur->path, BRCMF_FW_NAME_LEN);
546+
/* strip .txt at the end */
547+
alt_path[strlen(alt_path) - 4] = 0;
548+
strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
549+
strlcat(alt_path, fwctx->req->board_type, BRCMF_FW_NAME_LEN);
550+
strlcat(alt_path, ".txt", BRCMF_FW_NAME_LEN);
551+
552+
ret = request_firmware(fw, alt_path, fwctx->dev);
553+
if (ret == 0)
554+
return ret;
555+
}
556+
557+
return request_firmware(fw, cur->path, fwctx->dev);
558+
}
559+
535560
static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
536561
{
537562
struct brcmf_fw *fwctx = ctx;
@@ -544,7 +569,7 @@ static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
544569

545570
while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) {
546571
cur = &fwctx->req->items[fwctx->curpos];
547-
request_firmware(&fw, cur->path, fwctx->dev);
572+
brcmf_fw_request_firmware(&fw, fwctx);
548573
ret = brcmf_fw_complete_request(fw, ctx);
549574
}
550575

drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct brcmf_fw_request {
7070
u16 domain_nr;
7171
u16 bus_nr;
7272
u32 n_items;
73+
const char *board_type;
7374
struct brcmf_fw_item items[0];
7475
};
7576

0 commit comments

Comments
 (0)