linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Oscar Carter <oscar.carter@gmx.com>
Cc: Forest Bond <forest@alittletooquiet.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Malcolm Priestley <tvboxspy@gmail.com>,
	"John B . Wyatt IV" <jbwyatt4@gmail.com>,
	linux-kernel@vger.kernel.org,
	Colin Ian King <colin.king@canonical.com>
Subject: Re: [PATCH] staging: vt6656: Use fls instead of for loop in vnt_update_top_rates
Date: Mon, 20 Apr 2020 15:10:59 +0300	[thread overview]
Message-ID: <20200420121059.GC2659@kadam> (raw)
In-Reply-To: <20200419100921.5421-1-oscar.carter@gmx.com>

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


  reply	other threads:[~2020-04-20 12:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-19 10:09 [PATCH] staging: vt6656: Use fls instead of for loop in vnt_update_top_rates Oscar Carter
2020-04-20 12:10 ` Dan Carpenter [this message]
2020-04-20 15:02   ` Oscar Carter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200420121059.GC2659@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=colin.king@canonical.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=forest@alittletooquiet.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbwyatt4@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oscar.carter@gmx.com \
    --cc=tvboxspy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).