diff options
author | Felix Fietkau <nbd@nbd.name> | 2020-09-30 04:51:03 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2020-12-04 13:46:15 +0100 |
commit | 14b80ba24592d1db67fae8af7e1375d29d580deb (patch) | |
tree | b65f3e2cb5e2f973859f98b90b9eb37141c2bd22 /drivers/net/wireless/mediatek/mt76/mt7603 | |
parent | 64537a02131712a3b2f596c8a5785a8f3c0b6c47 (diff) | |
download | lwn-14b80ba24592d1db67fae8af7e1375d29d580deb.tar.gz lwn-14b80ba24592d1db67fae8af7e1375d29d580deb.zip |
mt76: mt7603: switch to .mcu_skb_send_msg
Reduces code duplication
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/mt7603')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 43 |
1 files 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; @@ -75,39 +77,6 @@ __mt7603_mcu_msg_send(struct mt7603_dev *dev, struct sk_buff *skb, } 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) { struct { @@ -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, }; |