@@ -17,8 +17,18 @@ static int
mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq)
{
- struct mt7603_mcu_rxd *rxd = (struct mt7603_mcu_rxd *)skb->data;
+ struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
+ struct mt7603_mcu_rxd *rxd;
+
+ if (!skb) {
+ dev_err(mdev->dev,
+ "MCU message %d (seq %d) timed out\n",
+ cmd, seq);
+ dev->mcu_hang = MT7603_WATCHDOG_TIMEOUT;
+ return -ETIMEDOUT;
+ }
+ rxd = (struct mt7603_mcu_rxd *)skb->data;
if (seq != rxd->seq)
return -EAGAIN;
@@ -85,15 +95,6 @@ mt7603_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
while (wait_resp) {
skb = mt76_mcu_get_response(&dev->mt76, expires);
- if (!skb) {
- dev_err(mdev->dev,
- "MCU message %d (seq %d) timed out\n",
- cmd, seq);
- dev->mcu_hang = MT7603_WATCHDOG_TIMEOUT;
- ret = -ETIMEDOUT;
- break;
- }
-
ret = mt7603_mcu_parse_response(mdev, cmd, skb, seq);
dev_kfree_skb(skb);
if (ret != -EAGAIN)
@@ -182,9 +182,16 @@ static int __mt7615_mcu_msg_send(struct mt7615_dev *dev, struct sk_buff *skb,
int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq)
{
- struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data;
+ struct mt7615_mcu_rxd *rxd;
int ret = 0;
+ if (!skb) {
+ dev_err(mdev->dev, "Message %ld (seq %d) timeout\n",
+ cmd & MCU_CMD_MASK, seq);
+ return -ETIMEDOUT;
+ }
+
+ rxd = (struct mt7615_mcu_rxd *)skb->data;
if (seq != rxd->seq)
return -EAGAIN;
@@ -238,12 +245,6 @@ int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq)
while (true) {
skb = mt76_mcu_get_response(&dev->mt76, expires);
- if (!skb) {
- dev_err(dev->mt76.dev, "Message %ld (seq %d) timeout\n",
- cmd & MCU_CMD_MASK, seq);
- return -ETIMEDOUT;
- }
-
ret = mt7615_mcu_parse_response(&dev->mt76, cmd, skb, seq);
dev_kfree_skb(skb);
if (ret != -EAGAIN)
@@ -13,8 +13,18 @@
int mt76x02_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq)
{
- u32 *rxfce = (u32 *)skb->cb;
+ struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
+ u32 *rxfce;
+
+ if (!skb) {
+ dev_err(mdev->dev,
+ "MCU message %d (seq %d) timed out\n", cmd,
+ seq);
+ dev->mcu_timeout = 1;
+ return -ETIMEDOUT;
+ }
+ rxfce = (u32 *)skb->cb;
if (seq != FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, *rxfce))
return -EAGAIN;
@@ -57,15 +67,6 @@ int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
while (wait_resp) {
skb = mt76_mcu_get_response(&dev->mt76, expires);
- if (!skb) {
- dev_err(mdev->dev,
- "MCU message %d (seq %d) timed out\n", cmd,
- seq);
- ret = -ETIMEDOUT;
- dev->mcu_timeout = 1;
- break;
- }
-
ret = mt76x02_mcu_parse_response(mdev, cmd, skb, seq);
dev_kfree_skb(skb);
if (ret != -EAGAIN)
@@ -313,9 +313,16 @@ mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq)
{
struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);
- struct mt7915_mcu_rxd *rxd = (struct mt7915_mcu_rxd *)skb->data;
+ struct mt7915_mcu_rxd *rxd;
int ret = 0;
+ if (!skb) {
+ dev_err(mdev->dev, "Message %d (seq %d) timeout\n",
+ cmd, seq);
+ return -ETIMEDOUT;
+ }
+
+ rxd = (struct mt7915_mcu_rxd *)skb->data;
if (seq != rxd->seq)
return -EAGAIN;
@@ -347,12 +354,6 @@ mt7915_mcu_wait_response(struct mt7915_dev *dev, int cmd, int seq)
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 = mt7915_mcu_parse_response(&dev->mt76, cmd, skb, seq);
dev_kfree_skb(skb);
if (ret != -EAGAIN)
Preparation for further cleanup Signed-off-by: Felix Fietkau <nbd@nbd.name> --- .../net/wireless/mediatek/mt76/mt7603/mcu.c | 21 ++++++++++--------- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 15 ++++++------- .../net/wireless/mediatek/mt76/mt76x02_mcu.c | 21 ++++++++++--------- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 15 ++++++------- 4 files changed, 38 insertions(+), 34 deletions(-)