]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: ath12k: refactor ath12k_wmi_tlv_parse_alloc()
authorDmitry Antipov <dmantipov@yandex.ru>
Tue, 19 Dec 2023 09:10:18 +0000 (12:10 +0300)
committerKalle Valo <quic_kvalo@quicinc.com>
Thu, 11 Jan 2024 11:19:29 +0000 (13:19 +0200)
Since 'ath12k_wmi_tlv_parse_alloc()' always operates on 'skb->data,
skb->len' tuple, it may be simplified to pass the only 'skb' argument
instead (which implies refactoring of 'ath12k_pull_bcn_tx_status_ev()',
'ath12k_pull_chan_info_ev()' and 'ath12k_pull_pdev_temp_ev()' in the
same way). This is an ath12k counterpart of the recently submitted
ath11k patch and compile tested only as well.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20231219091022.70861-1-dmantipov@yandex.ru
drivers/net/wireless/ath/ath12k/wmi.c

index 11cc3005c0f983502c0392c52168b27d0a83c83e..553d2566b3f7badb018440aefd187ff05bcebfb6 100644 (file)
@@ -359,8 +359,8 @@ static int ath12k_wmi_tlv_parse(struct ath12k_base *ar, const void **tb,
 }
 
 static const void **
-ath12k_wmi_tlv_parse_alloc(struct ath12k_base *ab, const void *ptr,
-                          size_t len, gfp_t gfp)
+ath12k_wmi_tlv_parse_alloc(struct ath12k_base *ab,
+                          struct sk_buff *skb, gfp_t gfp)
 {
        const void **tb;
        int ret;
@@ -369,7 +369,7 @@ ath12k_wmi_tlv_parse_alloc(struct ath12k_base *ab, const void *ptr,
        if (!tb)
                return ERR_PTR(-ENOMEM);
 
-       ret = ath12k_wmi_tlv_parse(ab, tb, ptr, len);
+       ret = ath12k_wmi_tlv_parse(ab, tb, skb->data, skb->len);
        if (ret) {
                kfree(tb);
                return ERR_PTR(ret);
@@ -4374,7 +4374,7 @@ static int ath12k_pull_vdev_start_resp_tlv(struct ath12k_base *ab, struct sk_buf
        const struct wmi_vdev_start_resp_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -4452,7 +4452,7 @@ static int ath12k_pull_reg_chan_list_ext_update_ev(struct ath12k_base *ab,
 
        ath12k_dbg(ab, ATH12K_DBG_WMI, "processing regulatory ext channel list\n");
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -4738,7 +4738,7 @@ static int ath12k_pull_peer_del_resp_ev(struct ath12k_base *ab, struct sk_buff *
        const struct wmi_peer_delete_resp_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -4770,7 +4770,7 @@ static int ath12k_pull_vdev_del_resp_ev(struct ath12k_base *ab,
        const struct wmi_vdev_delete_resp_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -4790,15 +4790,15 @@ static int ath12k_pull_vdev_del_resp_ev(struct ath12k_base *ab,
        return 0;
 }
 
-static int ath12k_pull_bcn_tx_status_ev(struct ath12k_base *ab, void *evt_buf,
-                                       u32 len, u32 *vdev_id,
-                                       u32 *tx_status)
+static int ath12k_pull_bcn_tx_status_ev(struct ath12k_base *ab,
+                                       struct sk_buff *skb,
+                                       u32 *vdev_id, u32 *tx_status)
 {
        const void **tb;
        const struct wmi_bcn_tx_status_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, evt_buf, len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -4826,7 +4826,7 @@ static int ath12k_pull_vdev_stopped_param_tlv(struct ath12k_base *ab, struct sk_
        const struct wmi_vdev_stopped_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -4970,7 +4970,7 @@ static int ath12k_pull_mgmt_tx_compl_param_tlv(struct ath12k_base *ab,
        const struct wmi_mgmt_tx_compl_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5141,7 +5141,7 @@ static int ath12k_pull_scan_ev(struct ath12k_base *ab, struct sk_buff *skb,
        const struct wmi_scan_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5174,7 +5174,7 @@ static int ath12k_pull_peer_sta_kickout_ev(struct ath12k_base *ab, struct sk_buf
        const struct wmi_peer_sta_kickout_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5201,7 +5201,7 @@ static int ath12k_pull_roam_ev(struct ath12k_base *ab, struct sk_buff *skb,
        const struct wmi_roam_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5245,14 +5245,14 @@ exit:
        return idx;
 }
 
-static int ath12k_pull_chan_info_ev(struct ath12k_base *ab, u8 *evt_buf,
-                                   u32 len, struct wmi_chan_info_event *ch_info_ev)
+static int ath12k_pull_chan_info_ev(struct ath12k_base *ab, struct sk_buff *skb,
+                                   struct wmi_chan_info_event *ch_info_ev)
 {
        const void **tb;
        const struct wmi_chan_info_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, evt_buf, len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5291,7 +5291,7 @@ ath12k_pull_pdev_bss_chan_info_ev(struct ath12k_base *ab, struct sk_buff *skb,
        const struct wmi_pdev_bss_chan_info_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5331,7 +5331,7 @@ ath12k_pull_vdev_install_key_compl_ev(struct ath12k_base *ab, struct sk_buff *sk
        const struct wmi_vdev_install_key_compl_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5362,7 +5362,7 @@ static int ath12k_pull_peer_assoc_conf_ev(struct ath12k_base *ab, struct sk_buff
        const struct wmi_peer_assoc_conf_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5384,13 +5384,13 @@ static int ath12k_pull_peer_assoc_conf_ev(struct ath12k_base *ab, struct sk_buff
 }
 
 static int
-ath12k_pull_pdev_temp_ev(struct ath12k_base *ab, u8 *evt_buf,
-                        u32 len, const struct wmi_pdev_temperature_event *ev)
+ath12k_pull_pdev_temp_ev(struct ath12k_base *ab, struct sk_buff *skb,
+                        const struct wmi_pdev_temperature_event *ev)
 {
        const void **tb;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, evt_buf, len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -5725,8 +5725,7 @@ static void ath12k_bcn_tx_status_event(struct ath12k_base *ab, struct sk_buff *s
 {
        u32 vdev_id, tx_status;
 
-       if (ath12k_pull_bcn_tx_status_ev(ab, skb->data, skb->len,
-                                        &vdev_id, &tx_status) != 0) {
+       if (ath12k_pull_bcn_tx_status_ev(ab, skb, &vdev_id, &tx_status) != 0) {
                ath12k_warn(ab, "failed to extract bcn tx status");
                return;
        }
@@ -6110,7 +6109,7 @@ static void ath12k_chan_info_event(struct ath12k_base *ab, struct sk_buff *skb)
        /* HW channel counters frequency value in hertz */
        u32 cc_freq_hz = ab->cc_freq_hz;
 
-       if (ath12k_pull_chan_info_ev(ab, skb->data, skb->len, &ch_info_ev) != 0) {
+       if (ath12k_pull_chan_info_ev(ab, skb, &ch_info_ev) != 0) {
                ath12k_warn(ab, "failed to extract chan info event");
                return;
        }
@@ -6395,7 +6394,7 @@ static void ath12k_pdev_ctl_failsafe_check_event(struct ath12k_base *ab,
        const struct wmi_pdev_ctl_failsafe_chk_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -6460,7 +6459,7 @@ ath12k_wmi_pdev_csa_switch_count_status_event(struct ath12k_base *ab,
        const u32 *vdev_ids;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -6494,7 +6493,7 @@ ath12k_wmi_pdev_dfs_radar_detected_event(struct ath12k_base *ab, struct sk_buff
        struct ath12k *ar;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);
@@ -6546,7 +6545,7 @@ ath12k_wmi_pdev_temperature_event(struct ath12k_base *ab,
        struct ath12k *ar;
        struct wmi_pdev_temperature_event ev = {0};
 
-       if (ath12k_pull_pdev_temp_ev(ab, skb->data, skb->len, &ev) != 0) {
+       if (ath12k_pull_pdev_temp_ev(ab, skb, &ev) != 0) {
                ath12k_warn(ab, "failed to extract pdev temperature event");
                return;
        }
@@ -6573,7 +6572,7 @@ static void ath12k_fils_discovery_event(struct ath12k_base *ab,
        const struct wmi_fils_discovery_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab,
@@ -6603,7 +6602,7 @@ static void ath12k_probe_resp_tx_status_event(struct ath12k_base *ab,
        const struct wmi_probe_resp_tx_status_event *ev;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab,
@@ -6635,7 +6634,7 @@ static void ath12k_rfkill_state_change_event(struct ath12k_base *ab,
        const void **tb;
        int ret;
 
-       tb = ath12k_wmi_tlv_parse_alloc(ab, skb->data, skb->len, GFP_ATOMIC);
+       tb = ath12k_wmi_tlv_parse_alloc(ab, skb, GFP_ATOMIC);
        if (IS_ERR(tb)) {
                ret = PTR_ERR(tb);
                ath12k_warn(ab, "failed to parse tlv: %d\n", ret);