Commit ad93cc9f authored by Narcisa Ana Maria Vasile's avatar Narcisa Ana Maria Vasile Committed by Greg Kroah-Hartman
Browse files

staging: rtl8712: Restructure code for clarity



Invert if statements to be able to return immediately in case of error,
and to avoid additional else branch.

Improve layout of function since there is more horizontal space now.

This was found using the following Coccinelle script:

@disable neg_if@
expression e,E;
statement S;
@@

*if (e)
    S
    else { return -E; }

    @disable neg_if@
    expression e,E;
    statement S;
    identifier l;
    @@

    *if
(e)
    S
    else
{ rc = -E; goto l; }

Signed-off-by: default avatarNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 09e1aa1a
Loading
Loading
Loading
Loading
+33 −36
Original line number Diff line number Diff line
@@ -1406,9 +1406,9 @@ static int r8711_wx_get_rate(struct net_device *dev,
	u16 mcs_rate = 0;

	i = 0;
	if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
		p = r8712_get_ie(&pcur_bss->IEs[12],
				 _HT_CAPABILITY_IE_, &ht_ielen,
	if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE))
		return -ENOLINK;
	p = r8712_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen,
			 pcur_bss->IELength - 12);
	if (p && ht_ielen > 0) {
		ht_cap = true;
@@ -1433,17 +1433,14 @@ static int r8711_wx_get_rate(struct net_device *dev,
		if (mcs_rate & 0x8000 /* MCS15 */
		    &&
		    rf_type == RTL8712_RF_2T2R)
				max_rate = (bw_40MHz) ? ((short_GI) ? 300 :
					    270) : ((short_GI) ? 144 : 130);
			max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) :
			((short_GI) ? 144 : 130);
		else /* default MCS7 */
				max_rate = (bw_40MHz) ? ((short_GI) ? 150 :
					    135) : ((short_GI) ? 72 : 65);
			max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) :
			((short_GI) ? 72 : 65);
		max_rate *= 2; /* Mbps/2 */
	}
	wrqu->bitrate.value = max_rate * 500000;
	} else {
		return -ENOLINK;
	}
	return 0;
}