Commit 680abb25 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: move mt76_mcu_get_response in mt76-core

Move mt76_mcu_get_response in mt76-core module and remove duplicated
code. mt76_mcu_get_response will be reused adding support for mt7603
driver
Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 9df0fab9
...@@ -34,3 +34,20 @@ mt76_mcu_msg_alloc(const void *data, int head_len, ...@@ -34,3 +34,20 @@ mt76_mcu_msg_alloc(const void *data, int head_len,
return skb; return skb;
} }
EXPORT_SYMBOL_GPL(mt76_mcu_msg_alloc); EXPORT_SYMBOL_GPL(mt76_mcu_msg_alloc);
/* mmio */
struct sk_buff *mt76_mcu_get_response(struct mt76_dev *dev,
unsigned long expires)
{
unsigned long timeout;
if (!time_is_after_jiffies(expires))
return NULL;
timeout = expires - jiffies;
wait_event_timeout(dev->mmio.mcu.wait,
!skb_queue_empty(&dev->mmio.mcu.res_q),
timeout);
return skb_dequeue(&dev->mmio.mcu.res_q);
}
EXPORT_SYMBOL_GPL(mt76_mcu_get_response);
...@@ -754,6 +754,8 @@ void mt76u_queues_deinit(struct mt76_dev *dev); ...@@ -754,6 +754,8 @@ void mt76u_queues_deinit(struct mt76_dev *dev);
struct sk_buff * struct sk_buff *
mt76_mcu_msg_alloc(const void *data, int head_len, mt76_mcu_msg_alloc(const void *data, int head_len,
int data_len, int tail_len); int data_len, int tail_len);
struct sk_buff *mt76_mcu_get_response(struct mt76_dev *dev,
unsigned long expires);
void mt76u_mcu_complete_urb(struct urb *urb); void mt76u_mcu_complete_urb(struct urb *urb);
int mt76u_mcu_init_rx(struct mt76_dev *dev); int mt76u_mcu_init_rx(struct mt76_dev *dev);
......
...@@ -21,21 +21,6 @@ ...@@ -21,21 +21,6 @@
#include "mt76x02_mcu.h" #include "mt76x02_mcu.h"
static struct sk_buff *
mt76x02_mcu_get_response(struct mt76x02_dev *dev, unsigned long expires)
{
unsigned long timeout;
if (!time_is_after_jiffies(expires))
return NULL;
timeout = expires - jiffies;
wait_event_timeout(dev->mt76.mmio.mcu.wait,
!skb_queue_empty(&dev->mt76.mmio.mcu.res_q),
timeout);
return skb_dequeue(&dev->mt76.mmio.mcu.res_q);
}
static int static int
mt76x02_tx_queue_mcu(struct mt76x02_dev *dev, enum mt76_txq_id qid, mt76x02_tx_queue_mcu(struct mt76x02_dev *dev, enum mt76_txq_id qid,
struct sk_buff *skb, int cmd, int seq) struct sk_buff *skb, int cmd, int seq)
...@@ -94,7 +79,7 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, ...@@ -94,7 +79,7 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
u32 *rxfce; u32 *rxfce;
bool check_seq = false; bool check_seq = false;
skb = mt76x02_mcu_get_response(dev, expires); skb = mt76_mcu_get_response(&dev->mt76, expires);
if (!skb) { if (!skb) {
dev_err(mdev->dev, dev_err(mdev->dev,
"MCU message %d (seq %d) timed out\n", cmd, "MCU message %d (seq %d) timed out\n", cmd,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment