mt76: move waiting and locking out of mcu_ops->mcu_skb_send_msg

This removes some code duplication and prepares the code for making
the MCU API more flexible

Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Felix Fietkau
2020-09-30 05:35:49 +02:00
parent fcfbb046c2
commit 477caa196f
7 changed files with 116 additions and 168 deletions
+32
View File
@@ -50,3 +50,35 @@ void mt76_mcu_rx_event(struct mt76_dev *dev, struct sk_buff *skb)
wake_up(&dev->mcu.wait);
}
EXPORT_SYMBOL_GPL(mt76_mcu_rx_event);
int mt76_mcu_skb_send_msg(struct mt76_dev *dev, struct sk_buff *skb,
int cmd, bool wait_resp)
{
unsigned long expires;
int ret, seq;
mutex_lock(&dev->mcu.mutex);
ret = dev->mcu_ops->mcu_skb_send_msg(dev, skb, cmd, &seq);
if (ret < 0)
goto out;
if (!wait_resp) {
ret = 0;
goto out;
}
expires = jiffies + dev->mcu.timeout;
do {
skb = mt76_mcu_get_response(dev, expires);
ret = dev->mcu_ops->mcu_parse_response(dev, cmd, skb, seq);
dev_kfree_skb(skb);
} while (ret == -EAGAIN);
out:
mutex_unlock(&dev->mcu.mutex);
return ret;
}
EXPORT_SYMBOL_GPL(mt76_mcu_skb_send_msg);