diff options
author | Madhumitha Prabakaran <madhumithabiw@gmail.com> | 2019-04-04 22:51:27 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-04-16 14:44:30 +0300 |
commit | 3b706841c29f1cf2f8f3484713288aa2c375677b (patch) | |
tree | d54349a2bafc0f581a5e51daa5d130f766827471 | |
parent | d5d682270f35cc324f7074c3d615b5bf8222df16 (diff) | |
download | linux-3b706841c29f1cf2f8f3484713288aa2c375677b.tar.xz |
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: Madhumitha Prabakaran <madhumithabiw@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/rtlwifi/core.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c index a9902818ae7e..2cce65368f92 100644 --- a/drivers/staging/rtlwifi/core.c +++ b/drivers/staging/rtlwifi/core.c @@ -341,25 +341,25 @@ static u16 crc16_ccitt(u8 data, u16 crc) u16 result; for (i = 0; i < 8; i++) { - crc_bit15 = ((crc & BIT(15)) ? 1 : 0); - data_bit = (data & (BIT(0) << i) ? 1 : 0); + crc_bit15 = !!(crc & BIT(15)); + data_bit = !!(data & BIT(i)); shift_in = crc_bit15 ^ data_bit; result = crc << 1; if (shift_in == 0) - result &= (~BIT(0)); + result &= ~BIT(0); else result |= BIT(0); - crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in; + crc_bit11 = !!(crc & BIT(11)) ^ shift_in; if (crc_bit11 == 0) - result &= (~BIT(12)); + result &= ~BIT(12); else result |= BIT(12); - crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in; + crc_bit4 = !!(crc & BIT(4)) ^ shift_in; if (crc_bit4 == 0) - result &= (~BIT(5)); + result &= ~BIT(5); else result |= BIT(5); |