wifi: rtw89: use struct to access firmware C2H event header
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 28 Jul 2023 07:02:48 +0000 (15:02 +0800)
committerKalle Valo <kvalo@kernel.org>
Tue, 1 Aug 2023 14:44:36 +0000 (17:44 +0300)
Firmware C2H events contain two-word header which can indicate category,
class, function and length of received events. Use struct to access them,
and doesn't change logic at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-7-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h

index cf22e50..f8616c1 100644 (file)
@@ -2809,12 +2809,13 @@ void rtw89_fw_free_all_early_h2c(struct rtw89_dev *rtwdev)
 
 static void rtw89_fw_c2h_parse_attr(struct sk_buff *c2h)
 {
+       const struct rtw89_c2h_hdr *hdr = (const struct rtw89_c2h_hdr *)c2h->data;
        struct rtw89_fw_c2h_attr *attr = RTW89_SKB_C2H_CB(c2h);
 
-       attr->category = RTW89_GET_C2H_CATEGORY(c2h->data);
-       attr->class = RTW89_GET_C2H_CLASS(c2h->data);
-       attr->func = RTW89_GET_C2H_FUNC(c2h->data);
-       attr->len = RTW89_GET_C2H_LEN(c2h->data);
+       attr->category = le32_get_bits(hdr->w0, RTW89_C2H_HDR_W0_CATEGORY);
+       attr->class = le32_get_bits(hdr->w0, RTW89_C2H_HDR_W0_CLASS);
+       attr->func = le32_get_bits(hdr->w0, RTW89_C2H_HDR_W0_FUNC);
+       attr->len = le32_get_bits(hdr->w1, RTW89_C2H_HDR_W1_LEN);
 }
 
 static bool rtw89_fw_c2h_chk_atomic(struct rtw89_dev *rtwdev,
index 831dbe6..becd8ac 100644 (file)
@@ -3101,14 +3101,15 @@ inline void RTW89_SET_FWCMD_MCC_SET_DURATION_DURATION_Y(void *cmd, u32 val)
 
 #define RTW89_C2H_HEADER_LEN 8
 
-#define RTW89_GET_C2H_CATEGORY(c2h) \
-       le32_get_bits(*((const __le32 *)c2h), GENMASK(1, 0))
-#define RTW89_GET_C2H_CLASS(c2h) \
-       le32_get_bits(*((const __le32 *)c2h), GENMASK(7, 2))
-#define RTW89_GET_C2H_FUNC(c2h) \
-       le32_get_bits(*((const __le32 *)c2h), GENMASK(15, 8))
-#define RTW89_GET_C2H_LEN(c2h) \
-       le32_get_bits(*((const __le32 *)(c2h) + 1), GENMASK(13, 0))
+struct rtw89_c2h_hdr {
+       __le32 w0;
+       __le32 w1;
+} __packed;
+
+#define RTW89_C2H_HDR_W0_CATEGORY GENMASK(1, 0)
+#define RTW89_C2H_HDR_W0_CLASS GENMASK(7, 2)
+#define RTW89_C2H_HDR_W0_FUNC GENMASK(15, 8)
+#define RTW89_C2H_HDR_W1_LEN GENMASK(13, 0)
 
 struct rtw89_fw_c2h_attr {
        u8 category;