staging: rtl8188eu: explicitly convert from __le16 to integer
authorKristina Martšenko <kristina.martsenko@gmail.com>
Tue, 11 Mar 2014 18:58:14 +0000 (20:58 +0200)
committerPeter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Thu, 13 Mar 2014 23:24:19 +0000 (16:24 -0700)
BA_para_set (of type __le16) is implicitly cast into an integer for
bitwise operations, after which the result is converted back into a
__le16. Make the initial cast explicit to make the code clearer. In
addition, refactor the code for readability.

This also removes five sparse warnings of the following type:
drivers/staging/rtl8188eu//core/rtw_mlme_ext.c:6114:70: warning: restricted __le16 degrades to integer

Signed-off-by: Kristina Martšenko <kristina.martsenko@gmail.com>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c

index 4942759..21f2f87 100644 (file)
@@ -6109,17 +6109,26 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
                case 1: /* ADDBA rsp */
                        pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->ADDBA_req.dialog_token), &(pattrib->pktlen));
                        pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&status), &(pattrib->pktlen));
+
+                       BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f;
                        rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor);
-                       if (MAX_AMPDU_FACTOR_64K == max_rx_ampdu_factor)
-                               BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */
-                       else if (MAX_AMPDU_FACTOR_32K == max_rx_ampdu_factor)
-                               BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0800); /* 32 buffer size */
-                       else if (MAX_AMPDU_FACTOR_16K == max_rx_ampdu_factor)
-                               BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0400); /* 16 buffer size */
-                       else if (MAX_AMPDU_FACTOR_8K == max_rx_ampdu_factor)
-                               BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0200); /* 8 buffer size */
-                       else
-                               BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */
+                       switch (max_rx_ampdu_factor) {
+                       case MAX_AMPDU_FACTOR_64K:
+                               BA_para_set |= 0x1000; /* 64 buffer size */
+                               break;
+                       case MAX_AMPDU_FACTOR_32K:
+                               BA_para_set |= 0x0800; /* 32 buffer size */
+                               break;
+                       case MAX_AMPDU_FACTOR_16K:
+                               BA_para_set |= 0x0400; /* 16 buffer size */
+                               break;
+                       case MAX_AMPDU_FACTOR_8K:
+                               BA_para_set |= 0x0200; /* 8 buffer size */
+                               break;
+                       default:
+                               BA_para_set |= 0x1000; /* 64 buffer size */
+                               break;
+                       }
 
                        if (pregpriv->ampdu_amsdu == 0)/* disabled */
                                BA_para_set = BA_para_set & ~BIT(0);