Search Linux Wireless

[PATCH v2 02/24] rtw88: add get_c2h_from_skb for extracting c2h commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yan-Hsuan Chuang <yhchuang@xxxxxxxxxxx>

pkt_offset is only used when getting the c2h from skb->data, use
get_c2h_from_skb to cleanup the code

Signed-off-by: Yan-Hsuan Chuang <yhchuang@xxxxxxxxxxx>
---
 drivers/net/wireless/realtek/rtw88/fw.c | 4 +---
 drivers/net/wireless/realtek/rtw88/fw.h | 8 ++++++++
 drivers/net/wireless/realtek/rtw88/tx.c | 4 +---
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
index 68c422b..12c4de8 100644
--- a/drivers/net/wireless/realtek/rtw88/fw.c
+++ b/drivers/net/wireless/realtek/rtw88/fw.c
@@ -11,11 +11,9 @@
 void rtw_fw_c2h_cmd_handle_ext(struct rtw_dev *rtwdev, struct sk_buff *skb)
 {
 	struct rtw_c2h_cmd *c2h;
-	u32 pkt_offset;
 	u8 sub_cmd_id;
 
-	pkt_offset = *((u32 *)skb->cb);
-	c2h = (struct rtw_c2h_cmd *)(skb->data + pkt_offset);
+	c2h = get_c2h_from_skb(skb);
 	sub_cmd_id = c2h->payload[0];
 
 	switch (sub_cmd_id) {
diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h
index 89950c7..86d9c86 100644
--- a/drivers/net/wireless/realtek/rtw88/fw.h
+++ b/drivers/net/wireless/realtek/rtw88/fw.h
@@ -192,6 +192,14 @@ static inline void rtw_h2c_pkt_set_header(u8 *h2c_pkt, u8 sub_id)
 #define SET_RA_INFO_RA_MASK3(h2c_pkt, value)                                   \
 	le32p_replace_bits((__le32 *)(h2c_pkt) + 0x01, value, GENMASK(31, 24))
 
+static inline struct rtw_c2h_cmd *get_c2h_from_skb(struct sk_buff *skb)
+{
+	u32 pkt_offset;
+
+	pkt_offset = *((u32 *)skb->cb);
+	return (struct rtw_c2h_cmd *)(skb->data + pkt_offset);
+}
+
 void rtw_fw_c2h_cmd_handle(struct rtw_dev *rtwdev, struct sk_buff *skb);
 void rtw_fw_send_general_info(struct rtw_dev *rtwdev);
 void rtw_fw_send_phydm_info(struct rtw_dev *rtwdev);
diff --git a/drivers/net/wireless/realtek/rtw88/tx.c b/drivers/net/wireless/realtek/rtw88/tx.c
index 21516b7..e5267d5 100644
--- a/drivers/net/wireless/realtek/rtw88/tx.c
+++ b/drivers/net/wireless/realtek/rtw88/tx.c
@@ -199,12 +199,10 @@ void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb)
 	struct rtw_c2h_cmd *c2h;
 	struct sk_buff *cur, *tmp;
 	unsigned long flags;
-	u32 pkt_offset;
 	u8 sn, st;
 	u8 *n;
 
-	pkt_offset = *((u32 *)skb->cb);
-	c2h = (struct rtw_c2h_cmd *)(skb->data + pkt_offset);
+	c2h = get_c2h_from_skb(skb);
 
 	sn = GET_CCX_REPORT_SEQNUM(c2h->payload);
 	st = GET_CCX_REPORT_STATUS(c2h->payload);
-- 
2.7.4




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux