Rework some conditions to bail out of functions faster therby decreasing overall indent. This patch should not cause any negative side effect (except for different execution time). Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@xxxxxxxxx> --- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 8 +- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 197 +++++++++++++------------ drivers/staging/rtl8192e/rtllib_rx.c | 99 +++++++------ drivers/staging/rtl8192e/rtllib_softmac.c | 128 ++++++++-------- 4 files changed, 216 insertions(+), 216 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 6802294..2f21bdc 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -932,10 +932,10 @@ start: rCCK0_TxFilter1, bMaskByte2); for (i = 0; i < CCKTxBBGainTableLength; i++) { - if (TempCCk == dm_cck_tx_bb_gain[i][0]) { - priv->CCKPresentAttentuation_20Mdefault = (u8)i; - break; - } + if (TempCCk != dm_cck_tx_bb_gain[i][0]) + continue; + priv->CCKPresentAttentuation_20Mdefault = (u8)i; + break; } priv->CCKPresentAttentuation_40Mdefault = 0; priv->CCKPresentAttentuation_difference = 0; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index d71459f..2f4a96c 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -2034,9 +2034,6 @@ static void dm_init_rxpath_selection(struct net_device *dev) } } -#define PWDB_IN_RANGE ((cur_cck_pwdb < tmp_cck_max_pwdb) && \ - (cur_cck_pwdb > tmp_cck_sec_pwdb)) - static void dm_rxpath_sel_byrssi(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2069,53 +2066,60 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) for (i = 0; i < RF90_PATH_MAX; i++) { if (!DM_RxPathSelTable.DbgMode) - DM_RxPathSelTable.rf_rssi[i] = priv->stats.rx_rssi_percentage[i]; - - if (priv->brfpath_rxenable[i]) { - rf_num++; - cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i]; - - if (rf_num == 1) { - max_rssi_index = min_rssi_index = sec_rssi_index = i; - tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi; - } else if (rf_num == 2) { - if (cur_rf_rssi >= tmp_max_rssi) { - tmp_max_rssi = cur_rf_rssi; - max_rssi_index = i; - } else { - tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi; - sec_rssi_index = min_rssi_index = i; - } + DM_RxPathSelTable.rf_rssi[i] = + priv->stats.rx_rssi_percentage[i]; + if (!priv->brfpath_rxenable[i]) + continue; + + rf_num++; + cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i]; + + if (rf_num == 1) { + sec_rssi_index = i; + max_rssi_index = i; + min_rssi_index = i; + tmp_sec_rssi = cur_rf_rssi; + tmp_max_rssi = cur_rf_rssi; + tmp_min_rssi = cur_rf_rssi; + } else if (rf_num == 2) { + if (cur_rf_rssi >= tmp_max_rssi) { + tmp_max_rssi = cur_rf_rssi; + max_rssi_index = i; } else { - if (cur_rf_rssi > tmp_max_rssi) { - tmp_sec_rssi = tmp_max_rssi; - sec_rssi_index = max_rssi_index; - tmp_max_rssi = cur_rf_rssi; - max_rssi_index = i; - } else if (cur_rf_rssi == tmp_max_rssi) { - tmp_sec_rssi = cur_rf_rssi; - sec_rssi_index = i; - } else if ((cur_rf_rssi < tmp_max_rssi) && - (cur_rf_rssi > tmp_sec_rssi)) { + tmp_sec_rssi = cur_rf_rssi; + tmp_min_rssi = cur_rf_rssi; + sec_rssi_index = i; + min_rssi_index = i; + } + } else { + if (cur_rf_rssi > tmp_max_rssi) { + tmp_sec_rssi = tmp_max_rssi; + sec_rssi_index = max_rssi_index; + tmp_max_rssi = cur_rf_rssi; + max_rssi_index = i; + } else if (cur_rf_rssi == tmp_max_rssi) { + tmp_sec_rssi = cur_rf_rssi; + sec_rssi_index = i; + } else if ((cur_rf_rssi < tmp_max_rssi) && + (cur_rf_rssi > tmp_sec_rssi)) { + tmp_sec_rssi = cur_rf_rssi; + sec_rssi_index = i; + } else if (cur_rf_rssi == tmp_sec_rssi) { + if (tmp_sec_rssi == tmp_min_rssi) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; - } else if (cur_rf_rssi == tmp_sec_rssi) { - if (tmp_sec_rssi == tmp_min_rssi) { - tmp_sec_rssi = cur_rf_rssi; - sec_rssi_index = i; - } - } else if ((cur_rf_rssi < tmp_sec_rssi) && - (cur_rf_rssi > tmp_min_rssi)) { - ; - } else if (cur_rf_rssi == tmp_min_rssi) { - if (tmp_sec_rssi == tmp_min_rssi) { - tmp_min_rssi = cur_rf_rssi; - min_rssi_index = i; - } - } else if (cur_rf_rssi < tmp_min_rssi) { + } + } else if ((cur_rf_rssi < tmp_sec_rssi) && + (cur_rf_rssi > tmp_min_rssi)) { + ; + } else if (cur_rf_rssi == tmp_min_rssi) { + if (tmp_sec_rssi == tmp_min_rssi) { tmp_min_rssi = cur_rf_rssi; min_rssi_index = i; } + } else if (cur_rf_rssi < tmp_min_rssi) { + tmp_min_rssi = cur_rf_rssi; + min_rssi_index = i; } } } @@ -2123,66 +2127,63 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) rf_num = 0; if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { for (i = 0; i < RF90_PATH_MAX; i++) { - if (priv->brfpath_rxenable[i]) { - rf_num++; - cur_cck_pwdb = - DM_RxPathSelTable.cck_pwdb_sta[i]; + if (!priv->brfpath_rxenable[i]) + continue; - if (rf_num == 1) { + rf_num++; + cur_cck_pwdb = DM_RxPathSelTable.cck_pwdb_sta[i]; + + if (rf_num == 1) { + cck_rx_ver2_max_index = i; + cck_rx_ver2_min_index = i; + cck_rx_ver2_sec_index = i; + tmp_cck_max_pwdb = cur_cck_pwdb; + tmp_cck_min_pwdb = cur_cck_pwdb; + tmp_cck_sec_pwdb = cur_cck_pwdb; + continue; + } + + if (rf_num == 2) { + if (cur_cck_pwdb >= tmp_cck_max_pwdb) { + tmp_cck_max_pwdb = cur_cck_pwdb; cck_rx_ver2_max_index = i; + } else { + tmp_cck_sec_pwdb = cur_cck_pwdb; + tmp_cck_min_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; cck_rx_ver2_min_index = i; + } + continue; + } + + if (cur_cck_pwdb > tmp_cck_max_pwdb) { + tmp_cck_sec_pwdb = tmp_cck_max_pwdb; + cck_rx_ver2_sec_index = cck_rx_ver2_max_index; + tmp_cck_max_pwdb = cur_cck_pwdb; + cck_rx_ver2_max_index = i; + } else if (cur_cck_pwdb == tmp_cck_max_pwdb) { + tmp_cck_sec_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; + } else if ((cur_cck_pwdb < tmp_cck_max_pwdb) && + (cur_cck_pwdb > tmp_cck_sec_pwdb)) { + tmp_cck_sec_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; + } else if (cur_cck_pwdb == tmp_cck_sec_pwdb) { + if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) { + tmp_cck_sec_pwdb = cur_cck_pwdb; cck_rx_ver2_sec_index = i; - tmp_cck_max_pwdb = cur_cck_pwdb; + } + } else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && + (cur_cck_pwdb > tmp_cck_min_pwdb)) { + ; + } else if (cur_cck_pwdb == tmp_cck_min_pwdb) { + if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) { tmp_cck_min_pwdb = cur_cck_pwdb; - tmp_cck_sec_pwdb = cur_cck_pwdb; - } else if (rf_num == 2) { - if (cur_cck_pwdb >= tmp_cck_max_pwdb) { - tmp_cck_max_pwdb = cur_cck_pwdb; - cck_rx_ver2_max_index = i; - } else { - tmp_cck_sec_pwdb = cur_cck_pwdb; - tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; - cck_rx_ver2_min_index = i; - } - } else { - if (cur_cck_pwdb > tmp_cck_max_pwdb) { - tmp_cck_sec_pwdb = - tmp_cck_max_pwdb; - cck_rx_ver2_sec_index = - cck_rx_ver2_max_index; - tmp_cck_max_pwdb = cur_cck_pwdb; - cck_rx_ver2_max_index = i; - } else if (cur_cck_pwdb == - tmp_cck_max_pwdb) { - tmp_cck_sec_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; - } else if (PWDB_IN_RANGE) { - tmp_cck_sec_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; - } else if (cur_cck_pwdb == - tmp_cck_sec_pwdb) { - if (tmp_cck_sec_pwdb == - tmp_cck_min_pwdb) { - tmp_cck_sec_pwdb = - cur_cck_pwdb; - cck_rx_ver2_sec_index = - i; - } - } else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && - (cur_cck_pwdb > tmp_cck_min_pwdb)) { - ; - } else if (cur_cck_pwdb == tmp_cck_min_pwdb) { - if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) { - tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_min_index = i; - } - } else if (cur_cck_pwdb < tmp_cck_min_pwdb) { - tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_min_index = i; - } + cck_rx_ver2_min_index = i; } - + } else if (cur_cck_pwdb < tmp_cck_min_pwdb) { + tmp_cck_min_pwdb = cur_cck_pwdb; + cck_rx_ver2_min_index = i; } } } diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 5371667..a66d8dc 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1256,51 +1256,52 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, for (i = 0; i < rxb->nr_subframes; i++) { struct sk_buff *sub_skb = rxb->subframes[i]; - if (sub_skb) { - /* convert hdr + possible LLC headers into Ethernet header */ - ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; - if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and - * replace EtherType - */ - skb_pull(sub_skb, SNAP_SIZE); - ether_addr_copy_unaligned(skb_push(sub_skb, - ETH_ALEN), - src); - ether_addr_copy_unaligned(skb_push(sub_skb, - ETH_ALEN), - dst); - } else { - u16 len; - /* Leave Ethernet header part of hdr and full payload */ - len = sub_skb->len; - memcpy(skb_push(sub_skb, 2), &len, 2); - ether_addr_copy_unaligned(skb_push(sub_skb, - ETH_ALEN), - src); - ether_addr_copy_unaligned(skb_push(sub_skb, - ETH_ALEN), - dst); - } + if (!sub_skb) + continue; + + /* convert hdr + possible LLC headers into Ethernet header */ + ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; + if (sub_skb->len >= 8 && + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0 + )) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and + * replace EtherType + */ + skb_pull(sub_skb, SNAP_SIZE); + ether_addr_copy_unaligned(skb_push(sub_skb, ETH_ALEN), + src); + ether_addr_copy_unaligned(skb_push(sub_skb, ETH_ALEN), + dst); + } else { + u16 len; + /* Leave Ethernet header part of + * hdr and full payload + */ + len = sub_skb->len; + memcpy(skb_push(sub_skb, 2), &len, 2); + ether_addr_copy_unaligned(skb_push(sub_skb, ETH_ALEN), + src); + ether_addr_copy_unaligned(skb_push(sub_skb, ETH_ALEN), + dst); + } - ieee->stats.rx_packets++; - ieee->stats.rx_bytes += sub_skb->len; + ieee->stats.rx_packets++; + ieee->stats.rx_bytes += sub_skb->len; - if (is_multicast_ether_addr(dst)) - ieee->stats.multicast++; + if (is_multicast_ether_addr(dst)) + ieee->stats.multicast++; - /* Indicate the packets to upper layer */ - memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); - sub_skb->protocol = eth_type_trans(sub_skb, dev); - sub_skb->dev = dev; - sub_skb->dev->stats.rx_packets++; - sub_skb->dev->stats.rx_bytes += sub_skb->len; - sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ - netif_rx(sub_skb); - } + /* Indicate the packets to upper layer */ + memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); + sub_skb->protocol = eth_type_trans(sub_skb, dev); + sub_skb->dev = dev; + sub_skb->dev->stats.rx_packets++; + sub_skb->dev->stats.rx_bytes += sub_skb->len; + /* 802.11 crc not sufficient */ + sub_skb->ip_summed = CHECKSUM_NONE; + netif_rx(sub_skb); } kfree(rxb); } @@ -1722,13 +1723,13 @@ static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element rc = rtllib_read_qos_param_element(¶m_element, info_element); - if (rc == 0) { - rtllib_qos_convert_ac_to_parameters(¶m_element, - &(network->qos_data)); - network->flags |= NETWORK_HAS_QOS_PARAMETERS; - network->qos_data.param_count = - param_element.info_element.ac_info & 0x0F; - } + if (rc != 0) + return rc; + rtllib_qos_convert_ac_to_parameters(¶m_element, + &(network->qos_data)); + network->flags |= NETWORK_HAS_QOS_PARAMETERS; + network->qos_data.param_count = + param_element.info_element.ac_info & 0x0F; } if (rc == 0) { diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 3c62638..65e8dbe 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2246,79 +2246,77 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, u8 *ies; struct rtllib_assoc_response_frame *assoc_resp; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + struct rtllib_network *network; RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + if (!((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && - (ieee->iw_mode == IW_MODE_INFRA)) { - errcode = assoc_parse(ieee, skb, &aid); - if (0 == errcode) { - struct rtllib_network *network = - kzalloc(sizeof(struct rtllib_network), - GFP_ATOMIC); - - if (!network) - return 1; - ieee->state = RTLLIB_LINKED; - ieee->assoc_id = aid; - ieee->softmac_stats.rx_ass_ok++; - /* station support qos */ - /* Let the register setting default with Legacy station */ - assoc_resp = (struct rtllib_assoc_response_frame *)skb->data; - if (ieee->current_network.qos_data.supported == 1) { - if (rtllib_parse_info_param(ieee, assoc_resp->info_element, - rx_stats->len - sizeof(*assoc_resp), - network, rx_stats)) { - kfree(network); - return 1; - } - memcpy(ieee->pHTInfo->PeerHTCapBuf, - network->bssht.bdHTCapBuf, - network->bssht.bdHTCapLen); - memcpy(ieee->pHTInfo->PeerHTInfoBuf, - network->bssht.bdHTInfoBuf, - network->bssht.bdHTInfoLen); - if (ieee->handle_assoc_response != NULL) - ieee->handle_assoc_response(ieee->dev, - (struct rtllib_assoc_response_frame *)header, - network); - } - kfree(network); + (ieee->iw_mode == IW_MODE_INFRA))) + return 0; - kfree(ieee->assocresp_ies); - ieee->assocresp_ies = NULL; - ies = &(assoc_resp->info_element[0].id); - ieee->assocresp_ies_len = (skb->data + skb->len) - ies; - ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, - GFP_ATOMIC); - if (ieee->assocresp_ies) - memcpy(ieee->assocresp_ies, ies, - ieee->assocresp_ies_len); - else { - netdev_info(ieee->dev, - "%s()Warning: can't alloc memory for assocresp_ies\n", - __func__); - ieee->assocresp_ies_len = 0; - } - rtllib_associate_complete(ieee); - } else { - /* aid could not been allocated */ - ieee->softmac_stats.rx_ass_err++; - netdev_info(ieee->dev, - "Association response status code 0x%x\n", - errcode); - RTLLIB_DEBUG_MGMT( - "Association response status code 0x%x\n", - errcode); - if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) - queue_delayed_work_rsl(ieee->wq, - &ieee->associate_procedure_wq, 0); - else - rtllib_associate_abort(ieee); + errcode = assoc_parse(ieee, skb, &aid); + if (errcode) { + /* aid could not been allocated */ + ieee->softmac_stats.rx_ass_err++; + netdev_info(ieee->dev, + "Association response status code 0x%x\n", + errcode); + RTLLIB_DEBUG_MGMT("Association response status code 0x%x\n", + errcode); + if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, + 0); + else + rtllib_associate_abort(ieee); + return 0; + } + + network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + if (!network) + return 1; + + ieee->state = RTLLIB_LINKED; + ieee->assoc_id = aid; + ieee->softmac_stats.rx_ass_ok++; + /* station support qos */ + /* Let the register setting default with Legacy station */ + assoc_resp = (struct rtllib_assoc_response_frame *)skb->data; + if (ieee->current_network.qos_data.supported == 1) { + if (rtllib_parse_info_param(ieee, assoc_resp->info_element, + rx_stats->len - sizeof(*assoc_resp), + network, rx_stats)) { + kfree(network); + return 1; } + memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, + network->bssht.bdHTCapLen); + memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, + network->bssht.bdHTInfoLen); + if (ieee->handle_assoc_response != NULL) + ieee->handle_assoc_response(ieee->dev, + (struct rtllib_assoc_response_frame *)header, + network); + } + kfree(network); + + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; + ies = &(assoc_resp->info_element[0].id); + ieee->assocresp_ies_len = (skb->data + skb->len) - ies; + ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, + GFP_ATOMIC); + if (ieee->assocresp_ies) { + memcpy(ieee->assocresp_ies, ies, ieee->assocresp_ies_len); + } else { + netdev_info(ieee->dev, + "%s()Warning: can't alloc memory for assocresp_ies\n", + __func__); + ieee->assocresp_ies_len = 0; } + rtllib_associate_complete(ieee); return 0; } -- 1.8.4.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel