1 From eae8e50669e15002b195177212a6e25afbe7cf4d Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Wed, 10 Oct 2018 13:01:00 +0200
4 Subject: [PATCH] brcmfmac: Add support for first trying to get a board
7 The nvram files which some brcmfmac chips need are board-specific. To be
8 able to distribute these as part of linux-firmware, so that devices with
9 such a wifi chip will work OOTB, multiple (one per board) versions must
10 co-exist under /lib/firmware.
12 This commit adds support for callers of the brcmfmac/firmware.c code to
13 pass in a board_type parameter through the request structure.
15 If that parameter is set then the code will first try to load
16 chipmodel.board_type.txt before falling back to the old chipmodel.txt name.
18 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
19 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
21 .../broadcom/brcm80211/brcmfmac/firmware.c | 27 +++++++++++++++++++++-
22 .../broadcom/brcm80211/brcmfmac/firmware.h | 1 +
23 2 files changed, 27 insertions(+), 1 deletion(-)
25 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
26 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
27 @@ -532,6 +532,31 @@ static int brcmf_fw_complete_request(con
28 return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret;
31 +static int brcmf_fw_request_firmware(const struct firmware **fw,
32 + struct brcmf_fw *fwctx)
34 + struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
37 + /* nvram files are board-specific, first try a board-specific path */
38 + if (cur->type == BRCMF_FW_TYPE_NVRAM && fwctx->req->board_type) {
39 + char alt_path[BRCMF_FW_NAME_LEN];
41 + strlcpy(alt_path, cur->path, BRCMF_FW_NAME_LEN);
42 + /* strip .txt at the end */
43 + alt_path[strlen(alt_path) - 4] = 0;
44 + strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
45 + strlcat(alt_path, fwctx->req->board_type, BRCMF_FW_NAME_LEN);
46 + strlcat(alt_path, ".txt", BRCMF_FW_NAME_LEN);
48 + ret = request_firmware(fw, alt_path, fwctx->dev);
53 + return request_firmware(fw, cur->path, fwctx->dev);
56 static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
58 struct brcmf_fw *fwctx = ctx;
59 @@ -544,7 +569,7 @@ static void brcmf_fw_request_done(const
61 while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) {
62 cur = &fwctx->req->items[fwctx->curpos];
63 - request_firmware(&fw, cur->path, fwctx->dev);
64 + brcmf_fw_request_firmware(&fw, fwctx);
65 ret = brcmf_fw_complete_request(fw, ctx);
68 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
69 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
70 @@ -70,6 +70,7 @@ struct brcmf_fw_request {
74 + const char *board_type;
75 struct brcmf_fw_item items[0];