Commit e263d722 authored by Hector Martin's avatar Hector Martin Committed by Kalle Valo

wifi: brcmfmac: firmware: Handle per-board clm_blob files

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: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: default avatarHector Martin <marcan@marcan.st>
Reviewed-by: default avatarAlvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/E1oZDnT-0077a4-4k@rmk-PC.armlinux.org.uk
parent e2e37224
...@@ -587,22 +587,29 @@ static int brcmf_fw_complete_request(const struct firmware *fw, ...@@ -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) static char *brcm_alt_fw_path(const char *path, const char *board_type)
{ {
char alt_path[BRCMF_FW_NAME_LEN]; char base[BRCMF_FW_NAME_LEN];
char suffix[5]; const char *suffix;
char *ret;
strscpy(alt_path, path, BRCMF_FW_NAME_LEN); if (!board_type)
/* At least one character + suffix */
if (strlen(alt_path) < 5)
return NULL; return NULL;
/* strip .txt or .bin at the end */ suffix = strrchr(path, '.');
strscpy(suffix, alt_path + strlen(alt_path) - 4, 5); if (!suffix || suffix == path)
alt_path[strlen(alt_path) - 4] = 0; return NULL;
strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
strlcat(alt_path, board_type, BRCMF_FW_NAME_LEN); /* strip extension at the end */
strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN); 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);
return kstrdup(alt_path, GFP_KERNEL); brcmf_dbg(TRACE, "FW alt path: %s\n", ret);
return ret;
} }
static int brcmf_fw_request_firmware(const struct firmware **fw, static int brcmf_fw_request_firmware(const struct firmware **fw,
...@@ -612,7 +619,7 @@ static int brcmf_fw_request_firmware(const struct firmware **fw, ...@@ -612,7 +619,7 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,
int ret; int ret;
/* Files can be board-specific, first try a board-specific path */ /* 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; char *alt_path;
alt_path = brcm_alt_fw_path(cur->path, fwctx->req->board_type); alt_path = brcm_alt_fw_path(cur->path, fwctx->req->board_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment