[PATCH v2 19/21] staging: rtl8192e: Fix LONG_LINE in rtllib_parse_mife_generic()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simplify function to make checkpatch.pl happy. Changes:
- Helper variables used
- Local variable names compacted
- Conditions were rephrased to return quickly (and decrease indent).

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@xxxxxxxxx>
---
 drivers/staging/rtl8192e/rtllib_rx.c | 170 +++++++++++++++++------------------
 1 file changed, 85 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 0bf0163..2e4fd33 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -1806,141 +1806,141 @@ static inline void rtllib_extract_country_ie(
 }
 
 static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
-				      struct rtllib_info_element *info_element,
+				      struct rtllib_info_element *info,
 				      struct rtllib_network *network,
 				      u16 *tmp_htcap_len,
 				      u16 *tmp_htinfo_len)
 {
 	u16 ht_realtek_agg_len = 0;
 	u8  ht_realtek_agg_buf[MAX_IE_LEN];
+	struct bss_ht *bssht = &network->bssht;
 
-	if (!rtllib_parse_qos_info_param_IE(info_element, network))
+	if (!rtllib_parse_qos_info_param_IE(info, network))
 		return;
 
-	if (info_element->len >= 4 &&
-	    info_element->data[0] == 0x00 && info_element->data[1] == 0x50 &&
-	    info_element->data[2] == 0xf2 && info_element->data[3] == 0x01) {
-		network->wpa_ie_len = min(info_element->len + 2,
-					  MAX_WPA_IE_LEN);
-		memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
+	if (info->len >= 4 &&
+	    info->data[0] == 0x00 && info->data[1] == 0x50 &&
+	    info->data[2] == 0xf2 && info->data[3] == 0x01) {
+		network->wpa_ie_len = min(info->len + 2, MAX_WPA_IE_LEN);
+		memcpy(network->wpa_ie, info, network->wpa_ie_len);
 		return;
 	}
 
-	if (info_element->len == 7 && info_element->data[0] == 0x00 &&
-	    info_element->data[1] == 0xe0 && info_element->data[2] == 0x4c &&
-	    info_element->data[3] == 0x01 && info_element->data[4] == 0x02)
+	if (info->len == 7 &&
+	    info->data[0] == 0x00 && info->data[1] == 0xe0 &&
+	    info->data[2] == 0x4c && info->data[3] == 0x01 &&
+	    info->data[4] == 0x02)
 		network->Turbo_Enable = 1;
 
 	if (*tmp_htcap_len == 0) {
-		if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
-		    info_element->data[1] == 0x90 &&
-		    info_element->data[2] == 0x4c &&
-		    info_element->data[3] == 0x033) {
-			*tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
+		if (info->len >= 4 &&
+		    info->data[0] == 0x00 && info->data[1] == 0x90 &&
+		    info->data[2] == 0x4c && info->data[3] == 0x33) {
+			*tmp_htcap_len = min_t(u8, info->len, MAX_IE_LEN);
 			if (*tmp_htcap_len != 0) {
-				network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
-				network->bssht.bdHTCapLen = min_t(u16, *tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
-				memcpy(network->bssht.bdHTCapBuf,
-				       info_element->data,
-				       network->bssht.bdHTCapLen);
+				bssht->bdHTSpecVer = HT_SPEC_VER_EWC;
+				bssht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
+						     sizeof(bssht->bdHTCapBuf));
+				memcpy(bssht->bdHTCapBuf, info->data,
+				       bssht->bdHTCapLen);
 			}
 		}
 		if (*tmp_htcap_len != 0) {
-			network->bssht.bdSupportHT = true;
-			network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+			bssht->bdSupportHT = true;
+			bssht->bdHT1R = ((((struct ht_capab_ele *)
+					   (bssht->bdHTCapBuf))->MCS[1]) == 0);
 		} else {
-			network->bssht.bdSupportHT = false;
-			network->bssht.bdHT1R = false;
+			bssht->bdSupportHT = false;
+			bssht->bdHT1R = false;
 		}
 	}
 
 
 	if (*tmp_htinfo_len == 0) {
-		if (info_element->len >= 4 && info_element->data[0] == 0x00 &&
-		    info_element->data[1] == 0x90 &&
-		    info_element->data[2] == 0x4c &&
-		    info_element->data[3] == 0x034) {
-			*tmp_htinfo_len = min_t(u8, info_element->len,
-						MAX_IE_LEN);
+		if (info->len >= 4 && info->data[0] == 0x00 &&
+		    info->data[1] == 0x90 &&
+		    info->data[2] == 0x4c &&
+		    info->data[3] == 0x034) {
+			*tmp_htinfo_len = min_t(u8, info->len, MAX_IE_LEN);
 			if (*tmp_htinfo_len != 0) {
-				network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
-				network->bssht.bdHTInfoLen = min_t(u16, *tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
-				memcpy(network->bssht.bdHTInfoBuf,
-				       info_element->data,
-				       network->bssht.bdHTInfoLen);
+				bssht->bdHTSpecVer = HT_SPEC_VER_EWC;
+				bssht->bdHTInfoLen = min_t(u16, *tmp_htinfo_len,
+							   sizeof(bssht->bdHTInfoBuf));
+				memcpy(bssht->bdHTInfoBuf, info->data,
+				       bssht->bdHTInfoLen);
 			}
 
 		}
 	}
 
 	if (ieee->aggregation) {
-		if (network->bssht.bdSupportHT) {
-			if (info_element->len >= 4 &&
-			    info_element->data[0] == 0x00 &&
-			    info_element->data[1] == 0xe0 &&
-			    info_element->data[2] == 0x4c &&
-			    info_element->data[3] == 0x02) {
-				ht_realtek_agg_len = min_t(u8,
-							   info_element->len,
+		if (bssht->bdSupportHT) {
+			if (info->len >= 4 &&
+			    info->data[0] == 0x00 && info->data[1] == 0xe0 &&
+			    info->data[2] == 0x4c && info->data[3] == 0x02) {
+				ht_realtek_agg_len = min_t(u8, info->len,
 							   MAX_IE_LEN);
-				memcpy(ht_realtek_agg_buf, info_element->data,
-				       info_element->len);
+				memcpy(ht_realtek_agg_buf, info->data,
+				       info->len);
 			}
 			if (ht_realtek_agg_len >= 5) {
 				network->realtek_cap_exit = true;
-				network->bssht.bdRT2RTAggregation = true;
+				bssht->bdRT2RTAggregation = true;
 
 				if ((ht_realtek_agg_buf[4] == 1) &&
 				    (ht_realtek_agg_buf[5] & 0x02))
-					network->bssht.bdRT2RTLongSlotTime = true;
+					bssht->bdRT2RTLongSlotTime = true;
 
 				if ((ht_realtek_agg_buf[4] == 1) &&
-				    (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
-					network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
+				    (ht_realtek_agg_buf[5] &
+				     RT_HT_CAP_USE_92SE))
+					bssht->RT2RT_HT_Mode |=
+							RT_HT_CAP_USE_92SE;
 			}
 		}
 		if (ht_realtek_agg_len >= 5) {
 			if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP))
-				network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
+				bssht->RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
 		}
 	}
 
-	if ((info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	     info_element->data[1] == 0x05 && info_element->data[2] == 0xb5) ||
-	     (info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	     info_element->data[1] == 0x0a && info_element->data[2] == 0xf7) ||
-	     (info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	     info_element->data[1] == 0x10 && info_element->data[2] == 0x18)) {
+	/* For all capabilities below:
+	 * - We need at least 3 bytes of info data
+	 * - First byte must be 0
+	 */
+	if (info->len < 3 || info->data[0] != 0x00)
+		return;
+
+	if ((info->data[1] == 0x05 && info->data[2] == 0xb5) ||
+	    (info->data[1] == 0x0a && info->data[2] == 0xf7) ||
+	    (info->data[1] == 0x10 && info->data[2] == 0x18)) {
 		network->broadcom_cap_exist = true;
 	}
 
-	if (info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	    info_element->data[1] == 0x0c && info_element->data[2] == 0x43)
+	if (info->data[1] == 0x0c && info->data[2] == 0x43)
 		network->ralink_cap_exist = true;
 
-	if ((info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	     info_element->data[1] == 0x03 && info_element->data[2] == 0x7f) ||
-	     (info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	     info_element->data[1] == 0x13 && info_element->data[2] == 0x74))
+	if ((info->data[1] == 0x03 && info->data[2] == 0x7f) ||
+	    (info->data[1] == 0x13 && info->data[2] == 0x74))
 		network->atheros_cap_exist = true;
 
-	if ((info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	     info_element->data[1] == 0x50 && info_element->data[2] == 0x43))
+	if (info->data[1] == 0x50 && info->data[2] == 0x43)
 		network->marvell_cap_exist = true;
 
-	if (info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	    info_element->data[1] == 0x40 && info_element->data[2] == 0x96)
+	if (info->data[1] == 0x40 && info->data[2] == 0x96)
 		network->cisco_cap_exist = true;
 
-	if (info_element->len >= 3 && info_element->data[0] == 0x00 &&
-	    info_element->data[1] == 0x0a && info_element->data[2] == 0xf5)
+	if (info->data[1] == 0x0a && info->data[2] == 0xf5)
 		network->airgo_cap_exist = true;
 
-	if (info_element->len > 4 && info_element->data[0] == 0x00 &&
-	    info_element->data[1] == 0x40 && info_element->data[2] == 0x96 &&
-	    info_element->data[3] == 0x01) {
-		if (info_element->len == 6) {
-			memcpy(network->CcxRmState, &info_element[4], 2);
+	/* For all capabilities below we need at least 4 bytes of data */
+	if (info->len < 4)
+		return;
+
+	if (info->data[1] == 0x40 && info->data[2] == 0x96 &&
+	    info->data[3] == 0x01) {
+		if (info->len == 6) {
+			memcpy(network->CcxRmState, &info[4], 2);
 			if (network->CcxRmState[0] != 0)
 				network->bCcxRmEnable = true;
 			else
@@ -1960,24 +1960,24 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
 			network->bCcxRmEnable = false;
 		}
 	}
-	if (info_element->len > 4  && info_element->data[0] == 0x00 &&
-	    info_element->data[1] == 0x40 && info_element->data[2] == 0x96 &&
-	    info_element->data[3] == 0x03) {
-		if (info_element->len == 5) {
+
+	if (info->data[1] == 0x40 && info->data[2] == 0x96 &&
+	    info->data[3] == 0x03) {
+		if (info->len == 5) {
 			network->bWithCcxVerNum = true;
-			network->BssCcxVerNumber = info_element->data[4];
+			network->BssCcxVerNumber = info->data[4];
 		} else {
 			network->bWithCcxVerNum = false;
 			network->BssCcxVerNumber = 0;
 		}
 	}
-	if (info_element->len > 4  && info_element->data[0] == 0x00 &&
-	    info_element->data[1] == 0x50 && info_element->data[2] == 0xf2 &&
-	    info_element->data[3] == 0x04) {
+
+	if (info->data[1] == 0x50 && info->data[2] == 0xf2 &&
+	    info->data[3] == 0x04) {
 		RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n",
-				  info_element->len);
-		network->wzc_ie_len = min(info_element->len+2, MAX_WZC_IE_LEN);
-		memcpy(network->wzc_ie, info_element, network->wzc_ie_len);
+				  info->len);
+		network->wzc_ie_len = min(info->len+2, MAX_WZC_IE_LEN);
+		memcpy(network->wzc_ie, info, network->wzc_ie_len);
 	}
 }
 
-- 
1.8.4.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux