From patchwork Mon Jul 31 13:07:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinming Hu X-Patchwork-Id: 9871821 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 3A5B460375 for ; Mon, 31 Jul 2017 13:07:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BAE62844B for ; Mon, 31 Jul 2017 13:07:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 109F0285C4; Mon, 31 Jul 2017 13:07:40 +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 AC3352844B for ; Mon, 31 Jul 2017 13:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751971AbdGaNHi (ORCPT ); Mon, 31 Jul 2017 09:07:38 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35356 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751446AbdGaNHh (ORCPT ); Mon, 31 Jul 2017 09:07:37 -0400 Received: by mail-pf0-f195.google.com with SMTP id q85so26148064pfq.2 for ; Mon, 31 Jul 2017 06:07:37 -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=WBg0ecVAUJTGsIF6obnEt9sI+Pu9Y/z7dctYwv/Y8AI=; b=dr6y1CGlIJfJNfFEm3dJZIZqA9TPzhfBwEAQJSE6mlhymuunO3JGqCUnMaZ6W+JLSi RVLLrk/asU/1Dr1XY27THbV/Md6bi/uBsy4FlhUV+EH7OZ6biHl2BIrB3QB6x2T3tRz3 QCvqHeMb0HdLFbh+fA8Yck1+R+px4TNpEax5zlqguR3ZLrGsoveR9qAnQ+vNn+uXlDSL Qil0qzBv6B+GPW9D17Gudc8/bmtsM4FrhwYGYC/5TuhRGzdmnPCgZ3KIp2Y1AR/y6Dbx HYy12wdTsfd7VBQ8OVCajSVrmwe0eN+GOUMGr44Ir5oxpTC1mJQyu45r7JLAzfwhkh8a tGAQ== 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=WBg0ecVAUJTGsIF6obnEt9sI+Pu9Y/z7dctYwv/Y8AI=; b=svUzA1UwyEuY/nd7zRSDulephWEWZ7rCkbEgdiWD427luMPEtD/N3BjA+2XVkYt3eJ 5aiK29jyZWYlZt8CT3WKDba8FY3K+iuPExfj9V77AZ+SVljIVBeV5OzV77m3cApA/qPp +MeP4iVZ3DFk/fZ4bQs6XzLHuQhVyWqP2D+9+aniAiOhDfokhXNSZMt04fTwoJqKU57e Zx3ZFQErISNkgBkHlCb/fYVkWwCNtyUWbuDuecAjsLqSx732ey5ERDHMR1Jcz3PUwstu 3qA85qAUmlzSa7aX6hHLJ0yU1yUMa9IhF1/LFBaJ54eYfhWyIK9h7bYXOjrtYydPfU7J xR6A== X-Gm-Message-State: AIVw110/4hSiDxq3OnJlwdFIBsVT8xFcljGboiGA0ml/hNIIOJ/Iggsk VyFSkQsbOC2MPfE3 X-Received: by 10.99.109.140 with SMTP id i134mr15475493pgc.368.1501506456397; Mon, 31 Jul 2017 06:07:36 -0700 (PDT) Received: from ubuntu.members.linode.com ([2400:8902::f03c:91ff:fee7:7cf1]) by smtp.gmail.com with ESMTPSA id p27sm32546942pfl.23.2017.07.31.06.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 06:07:35 -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: [PATCH 2/2] mwifiex: pcie: compatible with wifi-only image while extract wifi-part fw Date: Mon, 31 Jul 2017 13:07:27 +0000 Message-Id: <1501506447-31851-2-git-send-email-huxinming820@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501506447-31851-1-git-send-email-huxinming820@gmail.com> References: <1501506447-31851-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 --- 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: