lkml.org 
[lkml]   [2020]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: vt6656: Use fls instead of for loop in vnt_update_top_rates
On Sun, Apr 19, 2020 at 12:09:21PM +0200, Oscar Carter wrote:
> - for (i = RATE_11M;; i--) {
> - if (priv->basic_rates & (u16)(1 << 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-- : RATE_24M;
^^^^^
Argh... Come on. I don't want to have to break out the C standard to
see if this is defined behavior and where the sequence points are. A
pre-op would be clear but the most clear thing is to write it like this:

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-- : RATE_1M;
^^^^^
Same.

regards,
dan carpenter

\
 
 \ /
  Last update: 2020-04-20 14:15    [W:0.069 / U:1.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site