Commit 3032eb46 authored by Michael Straube's avatar Michael Straube Committed by Greg Kroah-Hartman

staging: r8188eu: replace ternary operator with min, max, abs macros

Replace some ternary operators with the min(), max() or abs() macros
to improve readability.

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Signed-off-by: default avatarMichael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20221031153743.8801-1-straube.linux@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent aa69ca7d
...@@ -476,8 +476,7 @@ static uint rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen) ...@@ -476,8 +476,7 @@ static uint rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
{ {
uint len; uint len;
len = rtw_remainder_len(pfile); len = min(rtw_remainder_len(pfile), rlen);
len = (rlen > len) ? len : rlen;
if (rmem) if (rmem)
skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len); skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len);
......
...@@ -583,7 +583,7 @@ static bool phy_SimularityCompare_8188E( ...@@ -583,7 +583,7 @@ static bool phy_SimularityCompare_8188E(
tmp2 = resulta[c2][i]; tmp2 = resulta[c2][i];
} }
diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); diff = abs(tmp1 - tmp2);
if (diff > MAX_TOLERANCE) { if (diff > MAX_TOLERANCE) {
if ((i == 2 || i == 6) && !sim_bitmap) { if ((i == 2 || i == 6) && !sim_bitmap) {
......
...@@ -199,7 +199,7 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) ...@@ -199,7 +199,7 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm)
Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i] / dm_fat_tbl->AuxAnt_Cnt[i]) : 0; Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i] / dm_fat_tbl->AuxAnt_Cnt[i]) : 0;
TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT; TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT;
/* 2 Select MaxRSSI for DIG */ /* 2 Select MaxRSSI for DIG */
LocalMaxRSSI = (Main_RSSI > Aux_RSSI) ? Main_RSSI : Aux_RSSI; LocalMaxRSSI = max(Main_RSSI, Aux_RSSI);
if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40)) if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40))
AntDivMaxRSSI = LocalMaxRSSI; AntDivMaxRSSI = LocalMaxRSSI;
if (LocalMaxRSSI > MaxRSSI) if (LocalMaxRSSI > MaxRSSI)
...@@ -211,7 +211,7 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) ...@@ -211,7 +211,7 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm)
else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0)) else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0))
Aux_RSSI = Main_RSSI; Aux_RSSI = Main_RSSI;
LocalMinRSSI = (Main_RSSI > Aux_RSSI) ? Aux_RSSI : Main_RSSI; LocalMinRSSI = min(Main_RSSI, Aux_RSSI);
if (LocalMinRSSI < MinRSSI) { if (LocalMinRSSI < MinRSSI) {
MinRSSI = LocalMinRSSI; MinRSSI = LocalMinRSSI;
RxIdleAnt = TargetAnt; RxIdleAnt = TargetAnt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment