rtlwifi: access skb->data to get C2H data by macro

The format of C2H data is ID(1 byte) + Length(1 byte) + value, and it is
more readable to use macros to access C2H data.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
Ping-Ke Shih 2018-05-18 17:30:06 +08:00 committed by Kalle Valo
parent 9ae6ed271a
commit 9644032e30
2 changed files with 9 additions and 4 deletions

View File

@ -2288,10 +2288,10 @@ static void rtl_c2h_content_parsing(struct ieee80211_hw *hw,
u8 cmd_id, cmd_seq, cmd_len; u8 cmd_id, cmd_seq, cmd_len;
u8 *cmd_buf = NULL; u8 *cmd_buf = NULL;
cmd_id = skb->data[0]; cmd_id = GET_C2H_CMD_ID(skb->data);
cmd_seq = skb->data[1]; cmd_seq = GET_C2H_SEQ(skb->data);
cmd_len = skb->len - 2; cmd_len = skb->len - C2H_DATA_OFFSET;
cmd_buf = skb->data + 2; cmd_buf = GET_C2H_DATA_PTR(skb->data);
switch (cmd_id) { switch (cmd_id) {
case C2H_DBG: case C2H_DBG:

View File

@ -177,6 +177,11 @@ enum rtl_c2h_evt_v2 {
C2H_V2_CCX_RPT = 0x0F, C2H_V2_CCX_RPT = 0x0F,
}; };
#define GET_C2H_CMD_ID(c2h) ({u8 *__c2h = c2h; __c2h[0]; })
#define GET_C2H_SEQ(c2h) ({u8 *__c2h = c2h; __c2h[1]; })
#define C2H_DATA_OFFSET 2
#define GET_C2H_DATA_PTR(c2h) ({u8 *__c2h = c2h; &__c2h[C2H_DATA_OFFSET]; })
#define GET_TX_REPORT_SN_V1(c2h) (c2h[6]) #define GET_TX_REPORT_SN_V1(c2h) (c2h[6])
#define GET_TX_REPORT_ST_V1(c2h) (c2h[0] & 0xC0) #define GET_TX_REPORT_ST_V1(c2h) (c2h[0] & 0xC0)
#define GET_TX_REPORT_RETRY_V1(c2h) (c2h[2] & 0x3F) #define GET_TX_REPORT_RETRY_V1(c2h) (c2h[2] & 0x3F)