From: Joe Perches <joe@perches.com>
To: Michael Straube <straube.linux@gmail.com>, gregkh@linuxfoundation.org
Cc: hdegoede@redhat.com, Larry.Finger@lwfinger.net,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included
Date: Sat, 12 Sep 2020 11:22:08 -0700 [thread overview]
Message-ID: <f5fdb27843143dfefb1a1a416dab63931fef6d41.camel@perches.com> (raw)
In-Reply-To: <20200912084520.8383-1-straube.linux@gmail.com>
On Sat, 2020-09-12 at 10:45 +0200, Michael Straube wrote:
> Refactor cckrates_included() and cckratesonly_included() to simplify
> the code and improve readability.
>
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
> drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> index a5790a648a5b..4e0d86b2e2e0 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> @@ -56,11 +56,12 @@ static u8 rtw_basic_rate_ofdm[3] = {
>
> int cckrates_included(unsigned char *rate, int ratelen)
> {
> - int i;
> + int i;
>
> for (i = 0; i < ratelen; i++) {
> - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
> - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
> + u8 r = rate[i] & 0x7f;
> +
> + if (r == 2 || r == 4 || r == 11 || r == 22)
> return true;
> }
>
> @@ -69,11 +70,12 @@ int cckrates_included(unsigned char *rate, int ratelen)
>
> int cckratesonly_included(unsigned char *rate, int ratelen)
> {
> - int i;
> + int i;
>
> for (i = 0; i < ratelen; i++) {
> - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
> - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
> + u8 r = rate[i] & 0x7f;
> +
> + if (r != 2 && r != 4 && r != 11 && r != 22)
> return false;
It would be simpler to add and use an inline like:
static bool is_cckrate(unsigned char rate)
{
rate &= 0x7f;
return rate == 2 || rate == 4 || rate == 11 || rate == 22;
}
so these could be
bool cckrates_included(unsigned char *rate, int ratelen)
{
int i;
for (i = 0; i < ratelen; i++) {
if (is_cckrate(rate[i])
return true;
}
return false;
}
bool cckratesonly_included(unsigned char *rate, int ratelen)
{
int i;
if (i <= 0)
return false;
for (i = 0; i < ratelen; i++) {
if (!is_cckrate(rate[i])
return false;
}
return true;
}
next prev parent reply other threads:[~2020-09-12 18:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-12 8:45 Michael Straube
2020-09-12 8:45 ` [PATCH 2/5] staging: rtl8723bs: make cckrates{only}_included static Michael Straube
2020-09-12 8:45 ` [PATCH 3/5] staging: rtl8723bs: convert cckrates{only}_included to bool Michael Straube
2020-09-12 8:45 ` [PATCH 4/5] staging: rtl8723bs: remove comparsions to true Michael Straube
2020-09-12 8:45 ` [PATCH 5/5] staging: rtl8723bs: remove 5 GHz code Michael Straube
2020-09-12 18:22 ` Joe Perches [this message]
2020-09-12 18:43 ` [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Joe Perches
2020-09-13 8:16 ` Michael Straube
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=f5fdb27843143dfefb1a1a416dab63931fef6d41.camel@perches.com \
--to=joe@perches.com \
--cc=Larry.Finger@lwfinger.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=straube.linux@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
all inboxes | Powered by JetHome®