Skip to content

Commit d317d05

Browse files
tchardinggregkh
authored andcommitted
staging: ks7010: move check and break to top of loop
Function uses an if statement within a for loop to guard a block of code. If 'if' statement conditional evaluates to false, loop breaks. The same logic can be expressed by inverting the conditional and breaking when new conditional evaluates to true. This allows the subsequent code to be indented one level less, aiding readability. Reduced indentation also allows for the code to be laid out more clearly and fixes two checkpatch warnings. Invert if statement conditional, break from for loop if new conditional evaluates to true. Reduce indentation in subsequent code, fix whitespace issues. Do not change program logic. Signed-off-by: Tobin C. Harding <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eb8c4e5 commit d317d05

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

drivers/staging/ks7010/ks_hostif.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,33 +2147,27 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
21472147
/* rate mask by phy setting */
21482148
if (priv->reg.phy_type == D_11B_ONLY_MODE) {
21492149
for (i = 0; i < priv->reg.rate_set.size; i++) {
2150-
if (IS_11B_RATE(priv->reg.rate_set.body[i])) {
2151-
if ((priv->reg.rate_set.body[i] & RATE_MASK) >=
2152-
TX_RATE_5M)
2153-
rate_octet[i] =
2154-
priv->reg.rate_set.
2155-
body[i] & RATE_MASK;
2156-
else
2157-
rate_octet[i] =
2158-
priv->reg.rate_set.body[i];
2159-
} else {
2150+
if (!IS_11B_RATE(priv->reg.rate_set.body[i]))
21602151
break;
2152+
2153+
if ((priv->reg.rate_set.body[i] & RATE_MASK) >= TX_RATE_5M) {
2154+
rate_octet[i] = priv->reg.rate_set.body[i] &
2155+
RATE_MASK;
2156+
} else {
2157+
rate_octet[i] = priv->reg.rate_set.body[i];
21612158
}
21622159
}
21632160

21642161
} else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
21652162
for (i = 0; i < priv->reg.rate_set.size; i++) {
2166-
if (IS_11BG_RATE(priv->reg.rate_set.body[i])) {
2167-
if (IS_OFDM_EXT_RATE
2168-
(priv->reg.rate_set.body[i]))
2169-
rate_octet[i] =
2170-
priv->reg.rate_set.
2171-
body[i] & RATE_MASK;
2172-
else
2173-
rate_octet[i] =
2174-
priv->reg.rate_set.body[i];
2175-
} else {
2163+
if (!IS_11BG_RATE(priv->reg.rate_set.body[i]))
21762164
break;
2165+
2166+
if (IS_OFDM_EXT_RATE(priv->reg.rate_set.body[i])) {
2167+
rate_octet[i] = priv->reg.rate_set.body[i] &
2168+
RATE_MASK;
2169+
} else {
2170+
rate_octet[i] = priv->reg.rate_set.body[i];
21772171
}
21782172
}
21792173
}

0 commit comments

Comments
 (0)