staging: rtl8192e: Use macro to represent fragmentation threshold
authorMateusz Kulikowski <mateusz.kulikowski@gmail.com>
Mon, 19 Oct 2015 20:00:20 +0000 (22:00 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Oct 2015 02:23:13 +0000 (19:23 -0700)
Add CMDPACKET_FRAG_SIZE macro and use it as fragmentation threshold
in send_cmd_pkt functions.
This makes rt_firmware::cmdpacket_frag_thresold and
 rtl92e_init_fw_param() obsolete.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h
drivers/staging/rtl8192e/rtl8192e/rtl_core.h

index 5ff7f2d..3de1b25 100644 (file)
@@ -23,9 +23,7 @@ bool rtl92e_send_cmd_pkt(struct net_device *dev, u32 type, const void *data,
 
        bool                            rt_status = true;
        struct r8192_priv *priv = rtllib_priv(dev);
-       u16                             frag_threshold;
        u16                             frag_length = 0, frag_offset = 0;
-       struct rt_firmware *pfirmware = priv->pFirmware;
        struct sk_buff          *skb;
        unsigned char           *seg_ptr;
        struct cb_desc *tcb_desc;
@@ -34,12 +32,10 @@ bool rtl92e_send_cmd_pkt(struct net_device *dev, u32 type, const void *data,
        struct tx_fwinfo_8190pci *pTxFwInfo = NULL;
 
        RT_TRACE(COMP_CMDPKT, "%s(),buffer_len is %d\n", __func__, len);
-       rtl92e_init_fw_param(dev);
-       frag_threshold = pfirmware->cmdpacket_frag_thresold;
 
        do {
-               if ((len - frag_offset) > frag_threshold) {
-                       frag_length = frag_threshold;
+               if ((len - frag_offset) > CMDPACKET_FRAG_SIZE) {
+                       frag_length = CMDPACKET_FRAG_SIZE;
                        bLastIniPkt = 0;
 
                } else {
index dab67c1..f88e112 100644 (file)
 #include "r8192E_firmware.h"
 #include <linux/firmware.h>
 
-void rtl92e_init_fw_param(struct net_device *dev)
-{
-       struct r8192_priv *priv = rtllib_priv(dev);
-       struct rt_firmware *pfirmware = priv->pFirmware;
-
-       pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(
-                                            MAX_TRANSMIT_BUFFER_SIZE);
-}
-
 static bool _rtl92e_fw_download_code(struct net_device *dev,
                                     u8 *code_virtual_address, u32 buffer_len)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
-       u16                 frag_threshold;
        u16                 frag_length, frag_offset = 0;
        int                 i;
-
-       struct rt_firmware *pfirmware = priv->pFirmware;
        struct sk_buff      *skb;
        unsigned char       *seg_ptr;
        struct cb_desc *tcb_desc;
        u8                  bLastIniPkt;
 
-       rtl92e_init_fw_param(dev);
-       frag_threshold = pfirmware->cmdpacket_frag_thresold;
        do {
-               if ((buffer_len - frag_offset) > frag_threshold) {
-                       frag_length = frag_threshold;
+               if ((buffer_len - frag_offset) > CMDPACKET_FRAG_SIZE) {
+                       frag_length = CMDPACKET_FRAG_SIZE;
                        bLastIniPkt = 0;
 
                } else {
index 10aac8c..186c65d 100644 (file)
@@ -15,8 +15,6 @@
 #ifndef __INC_FIRMWARE_H
 #define __INC_FIRMWARE_H
 
-#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v)   (4*(v/4) - 8)
-
 #define RTL8192E_BOOT_IMG_FW   "RTL8192E/boot.img"
 #define RTL8192E_MAIN_IMG_FW   "RTL8192E/main.img"
 #define RTL8192E_DATA_IMG_FW   "RTL8192E/data.img"
@@ -48,7 +46,6 @@ enum firmware_status {
 
 struct rt_firmware {
        enum firmware_status firmware_status;
-       u16               cmdpacket_frag_thresold;
 #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000
 #define MAX_FW_INIT_STEP               3
        u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE];
@@ -56,6 +53,4 @@ struct rt_firmware {
 };
 
 bool rtl92e_init_fw(struct net_device *dev);
-void rtl92e_init_fw_param(struct net_device *dev);
-
 #endif
index 1ddf42a..a7777a3 100644 (file)
@@ -91,6 +91,8 @@
        (1600 + (MAX_802_11_HEADER_LENGTH + ENCRYPTION_MAX_OVERHEAD) *  \
         MAX_FRAGMENT_COUNT)
 
+#define CMDPACKET_FRAG_SIZE (4 * (MAX_TRANSMIT_BUFFER_SIZE / 4) - 8)
+
 #define DEFAULT_FRAG_THRESHOLD 2342U
 #define MIN_FRAG_THRESHOLD     256U
 #define DEFAULT_BEACONINTERVAL 0x64U