Commit 3b706841 authored by Madhumitha Prabakaran's avatar Madhumitha Prabakaran Committed by Greg Kroah-Hartman

Staging: rtlwifi: Cleanup crc16_ccitt()

crc16_ccitt() function does "BIT(0) << i" instead of "BIT(i)".
Using !! is slightly shorter than "foo ? 1: 0" and remove unnecessary
parentheses to make the code simple.

Issue suggested by Coccinelle.
Signed-off-by: default avatarMadhumitha Prabakaran <madhumithabiw@gmail.com>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d5d68227
...@@ -341,25 +341,25 @@ static u16 crc16_ccitt(u8 data, u16 crc) ...@@ -341,25 +341,25 @@ static u16 crc16_ccitt(u8 data, u16 crc)
u16 result; u16 result;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
crc_bit15 = ((crc & BIT(15)) ? 1 : 0); crc_bit15 = !!(crc & BIT(15));
data_bit = (data & (BIT(0) << i) ? 1 : 0); data_bit = !!(data & BIT(i));
shift_in = crc_bit15 ^ data_bit; shift_in = crc_bit15 ^ data_bit;
result = crc << 1; result = crc << 1;
if (shift_in == 0) if (shift_in == 0)
result &= (~BIT(0)); result &= ~BIT(0);
else else
result |= BIT(0); result |= BIT(0);
crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in; crc_bit11 = !!(crc & BIT(11)) ^ shift_in;
if (crc_bit11 == 0) if (crc_bit11 == 0)
result &= (~BIT(12)); result &= ~BIT(12);
else else
result |= BIT(12); result |= BIT(12);
crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in; crc_bit4 = !!(crc & BIT(4)) ^ shift_in;
if (crc_bit4 == 0) if (crc_bit4 == 0)
result &= (~BIT(5)); result &= ~BIT(5);
else else
result |= BIT(5); result |= BIT(5);
......
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