From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH 07/10] mt76: mt7603: switch to .mcu_skb_send_msg
Date: Wed, 30 Sep 2020 14:24:38 +0200 [thread overview]
Message-ID: <20200930122441.64523-7-nbd@nbd.name> (raw)
In-Reply-To: <20200930122441.64523-1-nbd@nbd.name>
Reduces code duplication
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7603/mcu.c | 43 +++----------------
1 file changed, 6 insertions(+), 37 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c
index f787c9d3088e..b2ccfe6772ce 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c
@@ -36,14 +36,16 @@ mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd,
}
static int
-__mt7603_mcu_msg_send(struct mt7603_dev *dev, struct sk_buff *skb,
- int cmd, int *wait_seq)
+mt7603_mcu_skb_send_msg(struct mt76_dev *mdev, struct sk_buff *skb,
+ int cmd, int *wait_seq)
{
+ struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
int hdrlen = dev->mcu_running ? sizeof(struct mt7603_mcu_txd) : 12;
- struct mt76_dev *mdev = &dev->mt76;
struct mt7603_mcu_txd *txd;
u8 seq;
+ mdev->mcu.timeout = 3 * HZ;
+
seq = ++mdev->mcu.msg_seq & 0xf;
if (!seq)
seq = ++mdev->mcu.msg_seq & 0xf;
@@ -74,39 +76,6 @@ __mt7603_mcu_msg_send(struct mt7603_dev *dev, struct sk_buff *skb,
return mt76_tx_queue_skb_raw(dev, MT_TXQ_MCU, skb, 0);
}
-static int
-mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
- int len, bool wait_resp)
-{
- struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
- unsigned long expires = jiffies + 3 * HZ;
- struct sk_buff *skb;
- int ret, seq;
-
- skb = mt76_mcu_msg_alloc(mdev, data, len);
- if (!skb)
- return -ENOMEM;
-
- mutex_lock(&mdev->mcu.mutex);
-
- ret = __mt7603_mcu_msg_send(dev, skb, cmd, &seq);
- if (ret)
- goto out;
-
- while (wait_resp) {
- skb = mt76_mcu_get_response(&dev->mt76, expires);
- ret = mt7603_mcu_parse_response(mdev, cmd, skb, seq);
- dev_kfree_skb(skb);
- if (ret != -EAGAIN)
- break;
- }
-
-out:
- mutex_unlock(&mdev->mcu.mutex);
-
- return ret;
-}
-
static int
mt7603_mcu_init_download(struct mt7603_dev *dev, u32 addr, u32 len)
{
@@ -271,7 +240,7 @@ int mt7603_mcu_init(struct mt7603_dev *dev)
{
static const struct mt76_mcu_ops mt7603_mcu_ops = {
.headroom = sizeof(struct mt7603_mcu_txd),
- .mcu_send_msg = mt7603_mcu_msg_send,
+ .mcu_skb_send_msg = mt7603_mcu_skb_send_msg,
.mcu_parse_response = mt7603_mcu_parse_response,
.mcu_restart = mt7603_mcu_restart,
};
--
2.28.0
next prev parent reply other threads:[~2020-09-30 12:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 12:24 [PATCH 01/10] mt76: rename __mt76_mcu_send_msg to mt76_mcu_send_msg Felix Fietkau
2020-09-30 12:24 ` [PATCH 02/10] mt76: rename __mt76_mcu_skb_send_msg to mt76_mcu_skb_send_msg Felix Fietkau
2020-09-30 12:24 ` [PATCH 03/10] mt76: implement .mcu_parse_response in struct mt76_mcu_ops Felix Fietkau
2020-09-30 12:24 ` [PATCH 04/10] mt76: move mcu timeout handling to .mcu_parse_response Felix Fietkau
2020-09-30 12:24 ` [PATCH 05/10] mt76: move waiting and locking out of mcu_ops->mcu_skb_send_msg Felix Fietkau
2020-09-30 12:24 ` [PATCH 06/10] mt76: make mcu_ops->mcu_send_msg optional Felix Fietkau
2020-09-30 12:24 ` Felix Fietkau [this message]
2020-09-30 12:24 ` [PATCH 08/10] mt76: implement functions to get the response skb for MCU calls Felix Fietkau
2020-09-30 12:24 ` [PATCH 09/10] mt76: mt7915: move eeprom parsing out of mt7915_mcu_parse_response Felix Fietkau
2020-09-30 12:24 ` [PATCH 10/10] mt76: mt7915: query station rx rate from firmware Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200930122441.64523-7-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox