linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
To: Arend van Spriel <aspriel@gmail.com>,
	Franky Lin <franky.lin@broadcom.com>,
	Hante Meuleman <hante.meuleman@broadcom.com>
Cc: Alyssa Rosenzweig <alyssa@rosenzweig.io>,
	asahi@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com,
	"David S. Miller" <davem@davemloft.net>,
	devicetree@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	Hector Martin <marcan@marcan.st>,
	Jakub Kicinski <kuba@kernel.org>, Kalle Valo <kvalo@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	Paolo Abeni <pabeni@redhat.com>,
	"Rafa__ Mi__ecki" <zajec5@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	SHA-cyfmac-dev-list@infineon.com, Sven Peter <sven@svenpeter.dev>
Subject: [PATCH wireless-next v2 02/12] brcmfmac: firmware: Handle per-board clm_blob files
Date: Mon, 12 Sep 2022 10:52:46 +0100	[thread overview]
Message-ID: <E1oXg7S-0064um-F7@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <Yx8BQbjJT4I2oQ5K@shell.armlinux.org.uk>

From: Hector Martin <marcan@marcan.st>

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>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../broadcom/brcm80211/brcmfmac/firmware.c    | 33 +++++++++++--------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 15e99d8865bd..6c7c0c8f94ce 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -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,
@@ -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);
-- 
2.30.2


  parent reply	other threads:[~2022-09-12  9:53 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  9:52 [PATCH wireless-next v2 0/12] Add support for bcm4378 on Apple platforms Russell King (Oracle)
2022-09-12  9:52 ` [PATCH wireless-next v2 01/12] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips Russell King
2022-09-12 11:59   ` Alvin Šipraga
2022-09-12 12:04     ` Russell King (Oracle)
2022-09-12 14:01       ` Russell King (Oracle)
2022-09-12 14:13         ` Mark Kettenis
2022-09-12 14:27           ` Alvin Šipraga
2022-09-12 14:29             ` Russell King (Oracle)
2022-09-12  9:52 ` Russell King [this message]
2022-09-15 15:33   ` [PATCH wireless-next v2 02/12] brcmfmac: firmware: Handle per-board clm_blob files Alvin Šipraga
2022-09-12  9:52 ` [PATCH wireless-next v2 03/12] brcmfmac: pcie/sdio/usb: Get CLM blob via standard firmware mechanism Russell King
2022-09-15 15:33   ` Alvin Šipraga
2022-09-12  9:52 ` [PATCH wireless-next v2 04/12] brcmfmac: firmware: Support passing in multiple board_types Russell King
2022-09-15 15:34   ` Alvin Šipraga
2022-09-12  9:53 ` [PATCH wireless-next v2 05/12] brcmfmac: pcie: Read Apple OTP information Russell King
2022-09-12  9:53 ` [PATCH wireless-next v2 06/12] brcmfmac: of: Fetch Apple properties Russell King
2022-09-15 15:34   ` Alvin Šipraga
2022-09-12  9:53 ` [PATCH wireless-next v2 07/12] brcmfmac: pcie: Perform firmware selection for Apple platforms Russell King
2022-09-15 15:34   ` Alvin Šipraga
2022-09-12  9:53 ` [PATCH wireless-next v2 08/12] brcmfmac: firmware: Allow platform to override macaddr Russell King
2022-09-15 15:34   ` Alvin Šipraga
2022-09-12  9:53 ` [PATCH wireless-next v2 09/12] brcmfmac: msgbuf: Increase RX ring sizes to 1024 Russell King
2022-09-15 15:34   ` Alvin Šipraga
2022-09-12  9:53 ` [PATCH wireless-next v2 10/12] brcmfmac: pcie: Support PCIe core revisions >= 64 Russell King
2022-09-12  9:53 ` [PATCH wireless-next v2 11/12] brcmfmac: pcie: Add IDs/properties for BCM4378 Russell King
2022-09-15 15:34   ` Alvin Šipraga
2022-09-15 16:54     ` Russell King (Oracle)
2022-09-15 16:59       ` Alvin Šipraga
2022-09-16  7:31         ` Kalle Valo
2022-09-12  9:53 ` [PATCH wireless-next v2 12/12] arm64: dts: apple: Add WiFi module and antenna properties Russell King
2022-09-13  6:52   ` Kalle Valo
2022-09-13 16:30     ` Hector Martin
2022-09-16  7:28       ` Kalle Valo
2022-09-14 10:31 ` [PATCH wireless-next v2 0/12] Add support for bcm4378 on Apple platforms Arend Van Spriel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1oXg7S-0064um-F7@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=SHA-cyfmac-dev-list@infineon.com \
    --cc=alyssa@rosenzweig.io \
    --cc=asahi@lists.linux.dev \
    --cc=aspriel@gmail.com \
    --cc=brcm80211-dev-list.pdl@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=franky.lin@broadcom.com \
    --cc=hante.meuleman@broadcom.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    --cc=sven@svenpeter.dev \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).