From patchwork Mon Sep 12 09:52:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12973513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43798ECAAD5 for ; Mon, 12 Sep 2022 09:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h9RG9WXpj0ZfSZS9ImPwMCMgDTwp9FA6X0cMmku4pC4=; b=KCID8QdfYMG7so oythsQtt4f4LXfZbRdmyniSS8CJqfBHHf86Qg6ER32ih14heCRxVMLUKOZU1WDVcMxLccYFAm1wfT 8wX35OBbEE/2eIFqj7ImAFb0bbrp61DfzRb/8uOR8oBMzSjf8Lhcq8jc5vKVFzJA+ZVPFuB8ZtmoO VCONneqVl/bj8wAykJ/TOjgcNQOVjHnylyHuF6dMDIcZF9UOHITZo/ctBGnNFF6lX099xMo22Mivj c0JT75Exrx2o49JGAA36eDLVN5zoZk6h69r2KyEL8MbgjENj/GfhUW6l5jyU9BgyfdcSzyzfvFZw/ QD16a2W/sCZIAiWO/TuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oXg7j-008R4M-GG; Mon, 12 Sep 2022 09:53:03 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oXg7b-008Qy2-1H for linux-arm-kernel@lists.infradead.org; Mon, 12 Sep 2022 09:52:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oGsSCx6vnYSPKIXNfcv9dULMF1Fss3aaza+G+S+XB44=; b=JAkRGnBlDNmsZXIoEsLD4FSGXv iwJJRgYOXM44LBfqP6gq3TxjSvelm4EktdsgVhkbtvTFHEnoqfxORXfehMqUrbEGl/xUyNCc6iuuG gRVDd7HoUgMmTvYHU4zt3GcWh680gOFB3yZcI68F6nAuSNfRn2gpHtHXzod1NbIIl/AI6WCpwbhTG AKsVi7daYT4J9K3eN8VP4Ookv8PrdtltMyHh2nCXvLxrrWMZFpIhs/VXc30Bpc0U1paWomAcY+BSY ON3LfbYP31idai3yTDEh/z4HUDYG5ZDOsYZYRVI/1H8eqkexdoLFzWy0ePGceByf27Dlb1feh8Uox tc66N6pw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:33092 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oXg7T-0001Rd-5V; Mon, 12 Sep 2022 10:52:47 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oXg7S-0064um-F7; Mon, 12 Sep 2022 10:52:46 +0100 In-Reply-To: References: From: Russell King (Oracle) To: Arend van Spriel , Franky Lin , Hante Meuleman Cc: Alyssa Rosenzweig , asahi@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com, "David S. Miller" , devicetree@vger.kernel.org, Eric Dumazet , Hector Martin , Jakub Kicinski , Kalle Valo , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafa__ Mi__ecki" , Rob Herring , SHA-cyfmac-dev-list@infineon.com, Sven Peter Subject: [PATCH wireless-next v2 02/12] brcmfmac: firmware: Handle per-board clm_blob files MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 12 Sep 2022 10:52:46 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220912_025255_096923_A9BFCBA9 X-CRM114-Status: GOOD ( 14.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Hector Martin 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 Reviewed-by: Arend van Spriel Signed-off-by: Hector Martin Signed-off-by: Russell King (Oracle) Reviewed-by: Alvin Šipraga --- .../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);