From patchwork Sun Mar 8 22:08:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 216355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1BCDC10DCE for ; Sun, 8 Mar 2020 22:09:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77DCF20848 for ; Sun, 8 Mar 2020 22:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583705354; bh=4+cAbQUfuCpgHKGN1/CeRCdKC0EvuboIRQwtXQoYeXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KWDCrlO68N4HT1J4MtXErX8TQirpkXlYSu58hNuEyGxCeB7fnbtMI4/eaiOwamP6r sAjZfLoT6GdhEw0XPxFyJ2LlvCgUluxRAnJ6zeOESOw+QM2MdS/eMxtWgt5VtR9CZB q1smKmqQjXUVluKoCbkL0H6WW+z44mhaF0SGAQg4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726401AbgCHWJL (ORCPT ); Sun, 8 Mar 2020 18:09:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:39318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbgCHWJL (ORCPT ); Sun, 8 Mar 2020 18:09:11 -0400 Received: from localhost.localdomain (unknown [151.48.128.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6D2762083E; Sun, 8 Mar 2020 22:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583705350; bh=4+cAbQUfuCpgHKGN1/CeRCdKC0EvuboIRQwtXQoYeXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w7+kBXW7KqD9YQTlBwk18k9GXGs4WVdtG1RMcJoZN6SEHso7fXyl8jNxCcx/DqbrD oR522AWzMszM4cCFBr6K8QDGkR6GR6tP26+0P8LAk+0J+3K/z1yCQPEY5Un1jscVmX 0serPthQF206bhoBrBYcrmvx4GA6trRkQ5n4NuC0= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, linux-wireless@vger.kernel.org, ryder.lee@mediatek.com Subject: [PATCH v2 02/25] mt76: mt7615: introduce mt7615_mcu_wait_response Date: Sun, 8 Mar 2020 23:08:14 +0100 Message-Id: X-Mailer: git-send-email 2.24.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Introduce mt7615_mcu_wait_response in order to be reused parsing mt7663u mcu messages Co-developed-by: Sean Wang Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 71b209fe439f..a4e971d7f6a7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -144,12 +144,33 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, return ret; } +int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq) +{ + unsigned long expires = jiffies + 20 * HZ; + struct sk_buff *skb; + int ret = 0; + + while (true) { + skb = mt76_mcu_get_response(&dev->mt76, expires); + if (!skb) { + dev_err(dev->mt76.dev, "Message %d (seq %d) timeout\n", + cmd, seq); + return -ETIMEDOUT; + } + + ret = mt7615_mcu_parse_response(dev, cmd, skb, seq); + if (ret != -EAGAIN) + break; + } + + return ret; +} + static int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, int len, bool wait_resp) { struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76); - unsigned long expires = jiffies + 20 * HZ; struct sk_buff *skb; int ret, seq; @@ -163,19 +184,8 @@ mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, if (ret) goto out; - while (wait_resp) { - skb = mt76_mcu_get_response(mdev, expires); - if (!skb) { - dev_err(mdev->dev, "Message %d (seq %d) timeout\n", - cmd, seq); - ret = -ETIMEDOUT; - break; - } - - ret = mt7615_mcu_parse_response(dev, cmd, skb, seq); - if (ret != -EAGAIN) - break; - } + if (wait_resp) + ret = mt7615_mcu_wait_response(dev, cmd, seq); out: mutex_unlock(&mdev->mcu.mutex);