public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wifi: rtw88: usb: Simplify rtw_usb_write_data
@ 2024-05-02 21:23 Bitterblue Smith
  2024-05-02 22:18 ` Larry Finger
  2024-05-03  0:35 ` Ping-Ke Shih
  0 siblings, 2 replies; 6+ messages in thread
From: Bitterblue Smith @ 2024-05-02 21:23 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih, Sascha Hauer

The skb created in this function always has the same headroom,
the chip's TX descriptor size. Use chip->tx_pkt_desc_sz directly.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
This is the patch I promised earlier:
https://lore.kernel.org/linux-wireless/cae2d330-a4fb-4570-9dde-09684af23ffd@gmail.com/
---
 drivers/net/wireless/realtek/rtw88/usb.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/usb.c b/usb.c
index 1dfe7c6ae4ba..ff57976b9d3b 100644
--- a/usb.c
+++ b/usb.c
@@ -440,23 +440,21 @@ static int rtw_usb_write_data(struct rtw_dev *rtwdev,
 {
 	const struct rtw_chip_info *chip = rtwdev->chip;
 	struct sk_buff *skb;
-	unsigned int desclen, headsize, size;
+	unsigned int size;
 	u8 qsel;
 	int ret = 0;
 
 	size = pkt_info->tx_pkt_size;
 	qsel = pkt_info->qsel;
-	desclen = chip->tx_pkt_desc_sz;
-	headsize = pkt_info->offset ? pkt_info->offset : desclen;
 
-	skb = dev_alloc_skb(headsize + size);
+	skb = dev_alloc_skb(chip->tx_pkt_desc_sz + size);
 	if (unlikely(!skb))
 		return -ENOMEM;
 
-	skb_reserve(skb, headsize);
+	skb_reserve(skb, chip->tx_pkt_desc_sz);
 	skb_put_data(skb, buf, size);
-	skb_push(skb, headsize);
-	memset(skb->data, 0, headsize);
+	skb_push(skb, chip->tx_pkt_desc_sz);
+	memset(skb->data, 0, chip->tx_pkt_desc_sz);
 	rtw_tx_fill_tx_desc(pkt_info, skb);
 	rtw_tx_fill_txdesc_checksum(rtwdev, pkt_info, skb->data);
 
@@ -471,12 +469,10 @@ static int rtw_usb_write_data(struct rtw_dev *rtwdev,
 static int rtw_usb_write_data_rsvd_page(struct rtw_dev *rtwdev, u8 *buf,
 					u32 size)
 {
-	const struct rtw_chip_info *chip = rtwdev->chip;
 	struct rtw_tx_pkt_info pkt_info = {0};
 
 	pkt_info.tx_pkt_size = size;
 	pkt_info.qsel = TX_DESC_QSEL_BEACON;
-	pkt_info.offset = chip->tx_pkt_desc_sz;
 
 	return rtw_usb_write_data(rtwdev, &pkt_info, buf);
 }
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-03 10:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-02 21:23 [PATCH] wifi: rtw88: usb: Simplify rtw_usb_write_data Bitterblue Smith
2024-05-02 22:18 ` Larry Finger
2024-05-03  0:38   ` Ping-Ke Shih
2024-05-03  9:53   ` Bitterblue Smith
2024-05-03  0:35 ` Ping-Ke Shih
2024-05-03 10:13   ` Bitterblue Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox