From patchwork Tue Aug 1 01:38:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinming Hu X-Patchwork-Id: 9873553 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 24D6860365 for ; Tue, 1 Aug 2017 01:38:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1251E2862B for ; Tue, 1 Aug 2017 01:38:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06E6B2863D; Tue, 1 Aug 2017 01:38:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6103E2860B for ; Tue, 1 Aug 2017 01:38:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751631AbdHABif (ORCPT ); Mon, 31 Jul 2017 21:38:35 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35391 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbdHABie (ORCPT ); Mon, 31 Jul 2017 21:38:34 -0400 Received: by mail-pg0-f66.google.com with SMTP id l64so354834pge.2 for ; Mon, 31 Jul 2017 18:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JY6k2EyjGKRUKWy2k7khmJ7UWBQ3rKwDwNkkDrtDiMU=; b=cuiSgYN0BGwKwj+YnHcMVAFEFUPsEBWeImyqWvGpm4FnUznlGxEfqg6ueohe0olhwd 3W/54Ht8sxFo/aeq9ShX0JltKPvdgjzTQejmHm3/8e9TGwOQrr+KQeZU78PUClqdvobh S67jXFnw1qgDL8lRbIJG8BOV6iXOlqILF0aHvmoIVuZt3AUNh+5j0VZrtFDUxXDWwAb/ cIkoditMS3FVmJ/oKJgQniPMQU+cZC4eriyrWfUgiMqgNmmCJ9TFRC/904EUpxLEoRM7 dUDuMf01RIKtcMYuRGWex9Ezu9z+DsJOkiSdhLYUoksWtx92rRGnlYQQDPPL65SvsNFj jeyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JY6k2EyjGKRUKWy2k7khmJ7UWBQ3rKwDwNkkDrtDiMU=; b=clNJH4D03S2bemjqfq2hC+qHhuXRbTPVCA8lc3LxhDOMqIgkr15tOH/Y8j98BLGS96 JCx+4gbZ0QggfeHpkaN+9L1juSioyQQitEv8TBqqm0AV6MiBKqi6PkxTDPA6WuKGr65y z+5oL5Ha14tQRivThqGMZ7zX18Mqo08mclF4+iyOSTtSrUJ1Iy//ahkbpcwPH5VAk5OA lsB6Epfrlk4hriAM74dZQgfoB78HPMPsXs5aGQXP8dXXjjy1KRtRS5oLjf1ixni+yjto st1dBAp25ryjLBkeSRtVlqliELs7d8e9X3WYcx/A8LtFUThX2+gLMm9Z7Ef9fWeq13bA iYbw== X-Gm-Message-State: AIVw112waiD9hbYCAwApla5f92cEOt9/0QBCuiVjC6aMg73C+T//pS7h HtvziCT3niQyzAUc X-Received: by 10.98.101.4 with SMTP id z4mr17315519pfb.163.1501551513764; Mon, 31 Jul 2017 18:38:33 -0700 (PDT) Received: from ubuntu.members.linode.com ([2400:8902::f03c:91ff:fee7:7cf1]) by smtp.gmail.com with ESMTPSA id o7sm48701171pgf.63.2017.07.31.18.38.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 18:38:33 -0700 (PDT) From: Xinming Hu To: Linux Wireless Cc: Kalle Valo , Brian Norris , Dmitry Torokhov , rajatja@google.com, Zhiyuan Yang , Tim Song , Cathy Luo , Ganapathi Bhat , Xinming Hu Subject: [v2 PATCH 2/2] mwifiex: pcie: compatible with wifi-only image while extract wifi-part fw Date: Tue, 1 Aug 2017 01:38:24 +0000 Message-Id: <1501551504-8560-2-git-send-email-huxinming820@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501551504-8560-1-git-send-email-huxinming820@gmail.com> References: <1501551504-8560-1-git-send-email-huxinming820@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xinming Hu Sometimes, we might using wifi-only firmware with a combo firmware name, in this case, do not need to filter bluetooth part from header. Signed-off-by: Xinming Hu Signed-off-by: Cathy Luo Reviewed-by: Brian Norris --- v2: fix comment format/grammar (Brain) --- drivers/net/wireless/marvell/mwifiex/pcie.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 3da1eeb..dc4e054 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -1985,7 +1985,8 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, * (3) wifi image. * * This function bypass the header and bluetooth part, return - * the offset of tail wifi-only part. + * the offset of tail wifi-only part. If the image is already wifi-only, + * that is start with CMD1, return 0. */ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter, @@ -1993,7 +1994,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter, const struct mwifiex_fw_data *fwdata; u32 offset = 0, data_len, dnld_cmd; int ret = 0; - bool cmd7_before = false; + bool cmd7_before = false, first_cmd = false; while (1) { /* Check for integer and buffer overflow */ @@ -2014,20 +2015,29 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter, switch (dnld_cmd) { case MWIFIEX_FW_DNLD_CMD_1: - if (!cmd7_before) { - mwifiex_dbg(adapter, ERROR, - "no cmd7 before cmd1!\n"); + if (offset + data_len < data_len) { + mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); ret = -1; goto done; } - if (offset + data_len < data_len) { - mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); + + /* Image start with cmd1, already wifi-only firmware */ + if (!first_cmd) { + mwifiex_dbg(adapter, MSG, + "input wifi-only firmware\n"); + return 0; + } + + if (!cmd7_before) { + mwifiex_dbg(adapter, ERROR, + "no cmd7 before cmd1!\n"); ret = -1; goto done; } offset += data_len; break; case MWIFIEX_FW_DNLD_CMD_5: + first_cmd = true; /* Check for integer overflow */ if (offset + data_len < data_len) { mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); @@ -2037,6 +2047,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter, offset += data_len; break; case MWIFIEX_FW_DNLD_CMD_6: + first_cmd = true; /* Check for integer overflow */ if (offset + data_len < data_len) { mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); @@ -2053,6 +2064,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter, } goto done; case MWIFIEX_FW_DNLD_CMD_7: + first_cmd = true; cmd7_before = true; break; default: