linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Felix Fietkau <nbd@nbd.name>
Cc: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>,
	linux-wireless@vger.kernel.org,
	Stanislaw Gruszka <sgruszka@redhat.com>
Subject: [PATCH 09/12] mt76usb: resue mt76u_urb_alloc for tx
Date: Thu, 21 Mar 2019 16:25:34 +0100	[thread overview]
Message-ID: <20190321152537.19105-10-sgruszka@redhat.com> (raw)
In-Reply-To: <20190321152537.19105-1-sgruszka@redhat.com>

Add new rx_urb_alloc routine and reuse common urb_alloc for tx
allocations.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/usb.c | 35 ++++++++++++------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index 10507a26d598..7cefa4fe8251 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -352,7 +352,19 @@ mt76u_urb_alloc(struct mt76_dev *dev, struct mt76_queue_entry *e)
 		sg_init_table(urb->sg, MT_SG_MAX_SIZE);
 	}
 
-	return mt76u_refill_rx(dev, urb, MT_SG_MAX_SIZE, GFP_KERNEL);
+	return 0;
+}
+
+static int
+mt76u_rx_urb_alloc(struct mt76_dev *dev, struct mt76_queue_entry *e)
+{
+	int err;
+
+	err = mt76u_urb_alloc(dev, e);
+	if (err)
+		return err;
+
+	return mt76u_refill_rx(dev, e->urb, MT_SG_MAX_SIZE, GFP_KERNEL);
 }
 
 static void mt76u_urb_free(struct urb *urb)
@@ -570,7 +582,7 @@ static int mt76u_alloc_rx(struct mt76_dev *dev)
 	q->buf_size = dev->usb.sg_en ? MT_RX_BUF_SIZE : PAGE_SIZE;
 	q->ndesc = MT_NUM_RX_ENTRIES;
 	for (i = 0; i < q->ndesc; i++) {
-		err = mt76u_urb_alloc(dev, &q->entry[i]);
+		err = mt76u_rx_urb_alloc(dev, &q->entry[i]);
 		if (err < 0)
 			return err;
 	}
@@ -770,9 +782,8 @@ static void mt76u_tx_kick(struct mt76_dev *dev, struct mt76_queue *q)
 
 static int mt76u_alloc_tx(struct mt76_dev *dev)
 {
-	struct urb *urb;
 	struct mt76_queue *q;
-	int i, j;
+	int i, j, err;
 
 	for (i = 0; i <= MT_TXQ_PSD; i++) {
 		INIT_LIST_HEAD(&dev->q_tx[i].swq);
@@ -798,19 +809,9 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
 
 		q->ndesc = MT_NUM_TX_ENTRIES;
 		for (j = 0; j < q->ndesc; j++) {
-			urb = usb_alloc_urb(0, GFP_KERNEL);
-			if (!urb)
-				return -ENOMEM;
-			q->entry[j].urb = urb;
-
-			if (!dev->usb.sg_en)
-				continue;
-
-			urb->sg = devm_kcalloc(dev->dev, MT_SG_MAX_SIZE,
-					       sizeof(struct scatterlist),
-					       GFP_KERNEL);
-			if (!urb->sg)
-				return -ENOMEM;
+			err = mt76u_urb_alloc(dev, &q->entry[j]);
+			if (err < 0)
+				return err;
 		}
 	}
 	return 0;
-- 
2.20.1


  parent reply	other threads:[~2019-03-21 15:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 15:25 [PATCH 00/12] mt76usb: some cleanups and optimizations Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 01/12] mt76usb: change mt76u_submit_buf Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 02/12] mt76: remove rx_page_lock Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 03/12] mt76usb: change mt76u_fill_rx_sg arguments Stanislaw Gruszka
2019-03-22 10:10   ` Lorenzo Bianconi
2019-03-22 12:45     ` Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 04/12] mt76usb: use usb_dev private data Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 05/12] mt76usb: remove mt76u_buf redundant fileds Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 06/12] mt76usb: move mt76u_buf->done to queue entry Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 07/12] mt76usb: remove mt76u_buf and use urb directly Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 08/12] mt76usb: remove MT_RXQ_MAIN queue from mt76u_urb_alloc Stanislaw Gruszka
2019-03-21 15:25 ` Stanislaw Gruszka [this message]
2019-03-21 15:25 ` [PATCH 10/12] mt76usb: remove unneded sg_init_table Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 11/12] mt76usb: allocate urb and sg as linear data Stanislaw Gruszka
2019-03-21 15:25 ` [PATCH 12/12] mt76usb: remove queue variable from rx_tasklet Stanislaw Gruszka
2019-03-22 11:02 ` [PATCH 00/12] mt76usb: some cleanups and optimizations Lorenzo Bianconi
2019-03-24  7:25 ` Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190321152537.19105-10-sgruszka@redhat.com \
    --to=sgruszka@redhat.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).