summaryrefslogtreecommitdiffstats
path: root/drivers/staging/vt6656/card.c
diff options
context:
space:
mode:
authorOscar Carter <oscar.carter@gmx.com>2020-04-20 17:52:46 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-23 13:39:51 +0200
commitbf42304b55f59af5e71c86e46291705023dce62e (patch)
tree1731508648fe913fdb2addc986f0fbfa0c66e898 /drivers/staging/vt6656/card.c
parent9f8c9f4a2e6f23fc6eeecd305bfb40ddc91e0369 (diff)
downloadlinux-stable-bf42304b55f59af5e71c86e46291705023dce62e.tar.gz
linux-stable-bf42304b55f59af5e71c86e46291705023dce62e.tar.bz2
linux-stable-bf42304b55f59af5e71c86e46291705023dce62e.zip
staging: vt6656: Use fls instead of for loop in vnt_update_top_rates
Replace the for loops of the vnt_update_top_rates function by the fls function. The purpose of the two for loops is to find the most significant bit set in a range of bits. So, they can be replace by the fls function (find last set) with a previous mask to define the range. This way avoid the iteration over unnecessary for loops. The header "linux/bits.h" can be remove as it is included in the header "linux/bitops.h". Signed-off-by: Oscar Carter <oscar.carter@gmx.com> Link: https://lore.kernel.org/r/20200420155246.4925-1-oscar.carter@gmx.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vt6656/card.c')
-rw-r--r--drivers/staging/vt6656/card.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 983b1ea399dc..939bf11d5a6f 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -26,7 +26,7 @@
*
*/
-#include <linux/bits.h>
+#include <linux/bitops.h>
#include "device.h"
#include "card.h"
#include "baseband.h"
@@ -223,29 +223,13 @@ void vnt_update_ifs(struct vnt_private *priv)
void vnt_update_top_rates(struct vnt_private *priv)
{
- u8 top_ofdm = RATE_24M, top_cck = RATE_1M;
- u8 i;
+ int pos;
- /*Determines the highest basic rate.*/
- for (i = RATE_54M; i >= RATE_6M; i--) {
- if (priv->basic_rates & BIT(i)) {
- top_ofdm = i;
- break;
- }
- }
-
- priv->top_ofdm_basic_rate = top_ofdm;
-
- for (i = RATE_11M;; i--) {
- if (priv->basic_rates & BIT(i)) {
- top_cck = i;
- break;
- }
- if (i == RATE_1M)
- break;
- }
+ pos = fls(priv->basic_rates & GENMASK(RATE_54M, RATE_6M));
+ priv->top_ofdm_basic_rate = pos ? (pos - 1) : RATE_24M;
- priv->top_cck_basic_rate = top_cck;
+ pos = fls(priv->basic_rates & GENMASK(RATE_11M, RATE_1M));
+ priv->top_cck_basic_rate = pos ? (pos - 1) : RATE_1M;
}
bool vnt_ofdm_min_rate(struct vnt_private *priv)