Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5004759rwn; Mon, 12 Sep 2022 02:53:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR4dE5no1hjIYLOViMYYkHd8+Jqb8ugwVzMW9KEN4mPN5cnMtBBFcxiA/s445lmprzrpGMFP X-Received: by 2002:a17:903:26d4:b0:178:8de:fb5f with SMTP id jg20-20020a17090326d400b0017808defb5fmr15255129plb.45.1662976430558; Mon, 12 Sep 2022 02:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662976430; cv=none; d=google.com; s=arc-20160816; b=wGpvBHXTErivZulgg0P+DJ5DeZVkpvZFVkajWHA2S9IiieK7Iaj8id63ExuTlpV1Fq +RZByom6ktCiciJlXOJkgZcP4UVLRmDU4Lav/Pzb8U2JamqQsyL5tZHj/t2yfRZrZDhP /VO63uGuLGN0WVxvZIEaXBRNrQh8g9hnq58ZWPL27lJL3XVzY40Wdfw56BKjhlSLwrPT ETPlJ2GOLrepUhO6zGEn58BirbqXOt1f87vqVujzpNhjrrM1oQI7sgZ+rS1asVTWR0QJ oqxEXzKAsmhtPkvLQHMw692yZRk9u98H0y+PnE5ZUPcTNauds3cbmRNvJQ9PBU56r84W lYzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:sender:message-id:content-transfer-encoding :content-disposition:mime-version:subject:cc:to:from:references :in-reply-to:dkim-signature; bh=oGsSCx6vnYSPKIXNfcv9dULMF1Fss3aaza+G+S+XB44=; b=GPCRj0zyOfxK4qkTCcGM1y7omN5rF0+x875KJBD+65EsesuvspSZrfbSBoxv35YvLC gXTnDj2qQ1REYsFCPNM3Uc3bQZyhDUvvwUd0Ep12/Yg6BgolgVRxRoUKbrlAEgpcIoZn taTxw5xQR4JjM/+8fTXv7POvJ35O5OfWFjISHC4Hd5m2AtTMOQYjVgwZ1abPzqoucrAK cCncrG7WMQeEkWIL9AyjK9QzJ/J/xYQ68jlLjjTrj63yhYPqgGQ1hdddEoKDnNPeqBWa KWsmyPIbEsR01mQvFdlTCntJXylduWFUmaJobOH/cN7lxcxkjODz471SluSXX7bK9hUM qEiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=JAkRGnBl; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d3-20020aa78e43000000b0053e3e2ca431si6744252pfr.295.2022.09.12.02.53.41; Mon, 12 Sep 2022 02:53:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=JAkRGnBl; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbiILJxD (ORCPT + 64 others); Mon, 12 Sep 2022 05:53:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbiILJwz (ORCPT ); Mon, 12 Sep 2022 05:52:55 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16D2F36844; Mon, 12 Sep 2022 02:52:50 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Mon, 12 Sep 2022 10:52:46 +0100 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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) --- .../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