Commit f0deefa6 authored by Colin Ian King's avatar Colin Ian King Committed by Greg Kroah-Hartman

staging: r8188eu: Fix while-loop that iterates only once

The while-loop only iterates once becase the post increment test of count
being non-zero is false on the first iteration because count is zero. Fix
this by using a for-loop instead. Static analysis found the issue on the
count > POLLING_LLT_THRESHOLD check always being false since the loop
currently just iterates once.

Thanks to David Laight for suggesting using for-loop instead to improve
the readability of the fix.
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210630065647.5641-1-colin.king@canonical.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e7ca5907
...@@ -168,14 +168,14 @@ void rtw_hal_notch_filter(struct adapter *adapter, bool enable) ...@@ -168,14 +168,14 @@ void rtw_hal_notch_filter(struct adapter *adapter, bool enable)
static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data)
{ {
s32 status = _SUCCESS; s32 status = _SUCCESS;
s32 count = 0; s32 count;
u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS);
u16 LLTReg = REG_LLT_INIT; u16 LLTReg = REG_LLT_INIT;
usb_write32(padapter, LLTReg, value); usb_write32(padapter, LLTReg, value);
/* polling */ /* polling */
do { for (count = 0; ; count++) {
value = usb_read32(padapter, LLTReg); value = usb_read32(padapter, LLTReg);
if (_LLT_OP_VALUE(value) == _LLT_NO_ACTIVE) if (_LLT_OP_VALUE(value) == _LLT_NO_ACTIVE)
break; break;
...@@ -185,7 +185,7 @@ static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) ...@@ -185,7 +185,7 @@ static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data)
break; break;
} }
udelay(5); udelay(5);
} while (count++); }
return status; return status;
} }
......
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