staging: wilc1000: use 'struct' to pack cfg header frame in wilc_wlan_cfg_commit()
authorAjay Singh <ajay.kathat@microchip.com>
Thu, 17 Jan 2019 13:21:15 +0000 (13:21 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Jan 2019 09:39:15 +0000 (10:39 +0100)
Make use of 'struct' to pack cfg header in wilc_wlan_cfg_commit()
instead of byte by byte filling.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wilc_wfi_netdevice.h
drivers/staging/wilc1000/wilc_wlan.c
drivers/staging/wilc1000/wilc_wlan.h

index c6685c0c238bd0cad1aff367d28ed0d9d907cb46..a3400c14c30857aeea40c74bde511d1ef30f8724 100644 (file)
@@ -251,7 +251,7 @@ struct wilc {
        struct mutex cfg_cmd_lock;
        struct wilc_cfg_frame cfg_frame;
        u32 cfg_frame_offset;
-       int cfg_seq_no;
+       u8 cfg_seq_no;
 
        u8 *rx_buffer;
        u32 rx_buffer_offset;
index 3c5e9e030cadcff05cde6f37dc3c63ec5fc6f2b4..16b6c55524321b52cd1ac9e57e2ba843adbe34f0 100644 (file)
@@ -1092,24 +1092,19 @@ static int wilc_wlan_cfg_commit(struct wilc_vif *vif, int type,
 {
        struct wilc *wilc = vif->wilc;
        struct wilc_cfg_frame *cfg = &wilc->cfg_frame;
-       int total_len = wilc->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE;
-       int seq_no = wilc->cfg_seq_no % 256;
-       int driver_handler = (u32)drv_handler;
+       int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr);
 
        if (type == WILC_CFG_SET)
-               cfg->wid_header[0] = 'W';
+               cfg->hdr.cmd_type = 'W';
        else
-               cfg->wid_header[0] = 'Q';
-       cfg->wid_header[1] = seq_no;
-       cfg->wid_header[2] = (u8)total_len;
-       cfg->wid_header[3] = (u8)(total_len >> 8);
-       cfg->wid_header[4] = (u8)driver_handler;
-       cfg->wid_header[5] = (u8)(driver_handler >> 8);
-       cfg->wid_header[6] = (u8)(driver_handler >> 16);
-       cfg->wid_header[7] = (u8)(driver_handler >> 24);
-       wilc->cfg_seq_no = seq_no;
-
-       if (!wilc_wlan_txq_add_cfg_pkt(vif, &cfg->wid_header[0], total_len))
+               cfg->hdr.cmd_type = 'Q';
+
+       cfg->hdr.seq_no = wilc->cfg_seq_no % 256;
+       cfg->hdr.total_len = cpu_to_le16(t_len);
+       cfg->hdr.driver_handler = cpu_to_le32(drv_handler);
+       wilc->cfg_seq_no = cfg->hdr.seq_no;
+
+       if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len))
                return -1;
 
        return 0;
index 27667131de1aa21ecc43559d040d99723a7e61c2..c8ca13b346910d9a1aca3f29de4c5bc97210928f 100644 (file)
@@ -14,7 +14,6 @@
  *      Mac eth header length
  *
  ********************************************/
-#define DRIVER_HANDLER_SIZE            4
 #define MAX_MAC_HDR_LEN                        26 /* QOS_MAC_HDR_LEN */
 #define SUB_MSDU_HEADER_LENGTH         14
 #define SNAP_HDR_LEN                   8
@@ -251,14 +250,21 @@ struct wilc_hif_func {
 
 #define MAX_CFG_FRAME_SIZE     1468
 
+struct wilc_cfg_cmd_hdr {
+       u8 cmd_type;
+       u8 seq_no;
+       __le16 total_len;
+       __le32 driver_handler;
+};
+
 struct wilc_cfg_frame {
-       u8 wid_header[8];
+       struct wilc_cfg_cmd_hdr hdr;
        u8 frame[MAX_CFG_FRAME_SIZE];
 };
 
 struct wilc_cfg_rsp {
-       int type;
-       u32 seq_no;
+       u8 type;
+       u8 seq_no;
 };
 
 struct wilc;