diff mbox series

[4/4] wifi: mt76: adjust error handling in mt76s_txrx_worker()

Message ID 20230801050000.18864-4-dmantipov@yandex.ru (mailing list archive)
State New
Delegated to: Felix Fietkau
Headers show
Series [1/4] wifi: mt76: handle possible error returned by sdio_set_host_pm_flags() | expand

Commit Message

Dmitry Antipov Aug. 1, 2023, 4:57 a.m. UTC
Adjust error handling in 'mt76s_txrx_worker()' to issue 'dev_err()'
on all possible errors returned by 'mt76s_tx_run_queue()' and
'mt76s_rx_handler()', including newly introduced -ENOMEM in
'mt76s_rx_run_queue()'. This makes separate 'dev_err()' on SDIO
errors somewhat redundant, so remove them.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 .../net/wireless/mediatek/mt76/sdio_txrx.c    | 21 +++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/sdio_txrx.c b/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
index ddd8c0cc744d..68ab325e0dcd 100644
--- a/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
+++ b/drivers/net/wireless/mediatek/mt76/sdio_txrx.c
@@ -107,7 +107,6 @@  mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
 	sdio_release_host(sdio->func);
 
 	if (err < 0) {
-		dev_err(dev->dev, "sdio read data failed:%d\n", err);
 		put_page(page);
 		return err;
 	}
@@ -127,8 +126,10 @@  mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
 		if (!dev->drv->rx_check || dev->drv->rx_check(dev, buf, len)) {
 			e->skb = mt76s_build_rx_skb(buf, len,
 						    round_up(len + 4, 4));
-			if (!e->skb)
+			if (!e->skb) {
+				err = -ENOMEM;
 				break;
+			}
 
 			if (q->queued + i + 1 == q->ndesc)
 				break;
@@ -143,7 +144,7 @@  mt76s_rx_run_queue(struct mt76_dev *dev, enum mt76_rxq_id qid,
 	q->queued += i;
 	spin_unlock_bh(&q->lock);
 
-	return i;
+	return err < 0 ? err : i;
 }
 
 static int mt76s_rx_handler(struct mt76_dev *dev)
@@ -163,6 +164,8 @@  static int mt76s_rx_handler(struct mt76_dev *dev)
 		if (ret > 0) {
 			mt76_worker_schedule(&sdio->net_worker);
 			nframes += ret;
+		} else if (ret < 0) {
+			return ret;
 		}
 	}
 
@@ -171,6 +174,8 @@  static int mt76s_rx_handler(struct mt76_dev *dev)
 		if (ret > 0) {
 			mt76_worker_schedule(&sdio->net_worker);
 			nframes += ret;
+		} else if (ret < 0) {
+			return ret;
 		}
 	}
 
@@ -230,9 +235,6 @@  static int __mt76s_xmit_queue(struct mt76_dev *dev, u8 *data, int len)
 	err = sdio_writesb(sdio->func, MCR_WTDR1, data, len);
 	sdio_release_host(sdio->func);
 
-	if (err)
-		dev_err(dev->dev, "sdio write failed: %d\n", err);
-
 	return err;
 }
 
@@ -324,15 +326,22 @@  void mt76s_txrx_worker(struct mt76_sdio *sdio)
 			ret = mt76s_tx_run_queue(dev, dev->phy.q_tx[i]);
 			if (ret > 0)
 				nframes += ret;
+			else if (ret < 0)
+				dev_err(dev->dev, "tx error on queue %d: %d\n",
+					i, ret);
 		}
 		ret = mt76s_tx_run_queue(dev, dev->q_mcu[MT_MCUQ_WM]);
 		if (ret > 0)
 			nframes += ret;
+		else if (ret < 0)
+			dev_err(dev->dev, "tx error on MCU queue: %d\n", ret);
 
 		/* rx */
 		ret = mt76s_rx_handler(dev);
 		if (ret > 0)
 			nframes += ret;
+		else if (ret < 0)
+			dev_err(dev->dev, "rx error: %d\n", ret);
 
 		if (test_bit(MT76_MCU_RESET, &dev->phy.state) ||
 		    test_bit(MT76_STATE_SUSPEND, &dev->phy.state)) {