Skip to content

Commit

Permalink
wifi: brcmfmac: firmware: Handle per-board clm_blob files
Browse files Browse the repository at this point in the history
Teach brcm_alt_fw_paths to correctly split off variable length
extensions, and enable alt firmware lookups for the CLM blob firmware
requests.

Apple platforms have per-board CLM blob files.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/E1oZDnT-0077a4-4k@rmk-PC.armlinux.org.uk
  • Loading branch information
Hector Martin authored and Kalle Valo committed Sep 19, 2022
1 parent e2e3722 commit e263d72
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,22 +587,29 @@ static int brcmf_fw_complete_request(const struct firmware *fw,

static char *brcm_alt_fw_path(const char *path, const char *board_type)
{
char alt_path[BRCMF_FW_NAME_LEN];
char suffix[5];
char base[BRCMF_FW_NAME_LEN];
const char *suffix;
char *ret;

strscpy(alt_path, path, BRCMF_FW_NAME_LEN);
/* At least one character + suffix */
if (strlen(alt_path) < 5)
if (!board_type)
return NULL;

/* strip .txt or .bin at the end */
strscpy(suffix, alt_path + strlen(alt_path) - 4, 5);
alt_path[strlen(alt_path) - 4] = 0;
strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
strlcat(alt_path, board_type, BRCMF_FW_NAME_LEN);
strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN);
suffix = strrchr(path, '.');
if (!suffix || suffix == path)
return NULL;

/* strip extension at the end */
strscpy(base, path, BRCMF_FW_NAME_LEN);
base[suffix - path] = 0;

ret = kasprintf(GFP_KERNEL, "%s.%s%s", base, board_type, suffix);
if (!ret)
brcmf_err("out of memory allocating firmware path for '%s'\n",
path);

brcmf_dbg(TRACE, "FW alt path: %s\n", ret);

return kstrdup(alt_path, GFP_KERNEL);
return ret;
}

static int brcmf_fw_request_firmware(const struct firmware **fw,
Expand All @@ -612,7 +619,7 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,
int ret;

/* Files can be board-specific, first try a board-specific path */
if (cur->type == BRCMF_FW_TYPE_NVRAM && fwctx->req->board_type) {
if (fwctx->req->board_type) {
char *alt_path;

alt_path = brcm_alt_fw_path(cur->path, fwctx->req->board_type);
Expand Down

0 comments on commit e263d72

Please sign in to comment.