From: Malcolm Priestley <tvboxspy@gmail.com>
To: Stefano Brivio <sbrivio@redhat.com>, Oscar Carter <oscar.carter@gmx.com>
Cc: Forest Bond <forest@alittletooquiet.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Quentin Deslandes <quentin.deslandes@itdev.co.uk>,
"John B . Wyatt IV" <jbwyatt4@gmail.com>,
Colin Ian King <colin.king@canonical.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: vt6656: Refactor the vnt_ofdm_min_rate function
Date: Sun, 19 Apr 2020 20:11:49 +0100 [thread overview]
Message-ID: <1c118ba5-627e-17ee-7f21-100e2eb67cf1@gmail.com> (raw)
In-Reply-To: <20200419195534.1463ddcd@elisabeth>
Hi all
On 19/04/2020 18:55, Stefano Brivio wrote:
> Hi Oscar,
>
> On Sat, 18 Apr 2020 15:45:53 +0200
> Oscar Carter <oscar.carter@gmx.com> wrote:
>
>> Replace the for loop by a ternary operator whose condition is an AND
>> bitmask against the priv->basic_rates variable.
>>
>> The purpose of the for loop was to check if any of bits from RATE_54M to
>> RATE_6M was set, but it's not necessary to check every individual bit.
>> The same result can be achieved using only one single mask which
>> comprises all the commented bits.
<snip>
>>
>> -int vnt_ofdm_min_rate(struct vnt_private *priv)
>> +bool vnt_ofdm_min_rate(struct vnt_private *priv)
>> {
>> - int ii;
>> -
>> - for (ii = RATE_54M; ii >= RATE_6M; ii--) {
>> - if ((priv->basic_rates) & ((u16)BIT(ii)))
>> - return true;
>> - }
>> -
>> - return false;
>> + return priv->basic_rates & GENMASK(RATE_54M, RATE_6M) ? true : false;
>
> priv->basic_rates & GENMASK(RATE_54M, RATE_6M) is already true if
> non-zero and false otherwise. Note that I haven't checked if the
> rest is correct.
>
Yes only 1 or more needs to be true and it is false when none present.
I have run-time checked the patch and it does function as before.
Regards
Malcolm.
prev parent reply other threads:[~2020-04-19 19:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 13:45 [PATCH] staging: vt6656: Refactor the vnt_ofdm_min_rate function Oscar Carter
2020-04-19 17:55 ` Stefano Brivio
2020-04-19 19:11 ` Malcolm Priestley [this message]
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=1c118ba5-627e-17ee-7f21-100e2eb67cf1@gmail.com \
--to=tvboxspy@gmail.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=quentin.deslandes@itdev.co.uk \
--cc=sbrivio@redhat.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