diff mbox series

[RFC,3/3] mt76: usb: simplify mt76u_tx_build_sg routine

Message ID 517694b70bc88a867d4bc3c62cce05c3d3eb7faa.1550671183.git.lorenzo@kernel.org (mailing list archive)
State RFC
Delegated to: Kalle Valo
Headers show
Series simplify usb layer buffer allocation | expand

Commit Message

Lorenzo Bianconi Feb. 20, 2019, 2:05 p.m. UTC
From: Lorenzo Bianconi <lorenzo@kernel.org>

Use skb_to_sgvec instad of skb_to_sgvec_nomark in mt76u_tx_build_sg.
Moreover remove nsgs check since it is already performed in skb_to_sgvec

Suggested-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/usb.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index 24bf96de9f9d..87b89d5f1d03 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -724,23 +724,12 @@  static int
 mt76u_tx_build_sg(struct mt76_dev * dev, struct sk_buff *skb,
 		  struct urb *urb)
 {
-	struct sk_buff *iter;
-	int nsgs;
-
 	if (!dev->usb.sg_en)
 		return 0;
 
-	nsgs = 1 + skb_shinfo(skb)->nr_frags;
-	skb_walk_frags(skb, iter)
-		nsgs += 1 + skb_shinfo(iter)->nr_frags;
-
-	memset(urb->sg, 0, sizeof(*urb->sg) * MT_SG_MAX_SIZE);
-
-	nsgs = min_t(int, MT_SG_MAX_SIZE, nsgs);
-	sg_init_marker(urb->sg, nsgs);
-	urb->num_sgs = nsgs;
-
-	return skb_to_sgvec_nomark(skb, urb->sg, 0, skb->len);
+	sg_init_table(urb->sg, MT_SG_MAX_SIZE);
+	urb->num_sgs = skb_to_sgvec(skb, urb->sg, 0, skb->len);
+	return urb->num_sgs;
 }
 
 static int