struct wmi_init_cmd *cmd;
        struct sk_buff *buf;
        struct wmi_resource_config config = {};
-       u32 len, val;
+       u32 val;
 
        config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS);
        config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS);
        config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC);
        config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES);
 
-       len = sizeof(*cmd) +
-             (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
-
-       buf = ath10k_wmi_alloc_skb(ar, len);
+       buf = ath10k_wmi_alloc_skb(ar, struct_size(cmd, mem_chunks.items,
+                                                  ar->wmi.num_mem_chunks));
        if (!buf)
                return ERR_PTR(-ENOMEM);
 
        struct wmi_init_cmd_10x *cmd;
        struct sk_buff *buf;
        struct wmi_resource_config_10x config = {};
-       u32 len, val;
+       u32 val;
 
        config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
        config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
        config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
        config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
 
-       len = sizeof(*cmd) +
-             (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
-
-       buf = ath10k_wmi_alloc_skb(ar, len);
+       buf = ath10k_wmi_alloc_skb(ar, struct_size(cmd, mem_chunks.items,
+                                                  ar->wmi.num_mem_chunks));
        if (!buf)
                return ERR_PTR(-ENOMEM);
 
        struct wmi_init_cmd_10_2 *cmd;
        struct sk_buff *buf;
        struct wmi_resource_config_10x config = {};
-       u32 len, val, features;
+       u32 val, features;
 
        config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
        config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
        config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
        config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
 
-       len = sizeof(*cmd) +
-             (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
-
-       buf = ath10k_wmi_alloc_skb(ar, len);
+       buf = ath10k_wmi_alloc_skb(ar, struct_size(cmd, mem_chunks.items,
+                                                  ar->wmi.num_mem_chunks));
        if (!buf)
                return ERR_PTR(-ENOMEM);
 
        struct wmi_init_cmd_10_4 *cmd;
        struct sk_buff *buf;
        struct wmi_resource_config_10_4 config = {};
-       u32 len;
 
        config.num_vdevs = __cpu_to_le32(ar->max_num_vdevs);
        config.num_peers = __cpu_to_le32(ar->max_num_peers);
        config.iphdr_pad_config = __cpu_to_le32(TARGET_10_4_IPHDR_PAD_CONFIG);
        config.qwrap_config = __cpu_to_le32(TARGET_10_4_QWRAP_CONFIG);
 
-       len = sizeof(*cmd) +
-             (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
-
-       buf = ath10k_wmi_alloc_skb(ar, len);
+       buf = ath10k_wmi_alloc_skb(ar, struct_size(cmd, mem_chunks.items,
+                                                  ar->wmi.num_mem_chunks));
        if (!buf)
                return ERR_PTR(-ENOMEM);
 
        struct sk_buff *skb;
        struct wmi_channel_arg *ch;
        struct wmi_channel *ci;
-       int len;
        int i;
 
-       len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
-
-       skb = ath10k_wmi_alloc_skb(ar, len);
+       skb = ath10k_wmi_alloc_skb(ar, struct_size(cmd, chan_info, arg->n_channels));
        if (!skb)
                return ERR_PTR(-EINVAL);