From: Dan Carpenter <dan.carpenter@oracle.com>
To: Walter Harms <wharms@bfs.de>
Cc: Colin King <colin.king@canonical.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging: rtl8723bs: core: remove redundant zero'ing of counter variable k
Date: Mon, 24 Feb 2020 14:27:35 +0300 [thread overview]
Message-ID: <20200224112735.GC3286@kadam> (raw)
In-Reply-To: <5f875f84e6014d2bb5b78f71dc2831a2@bfs.de>
On Mon, Feb 24, 2020 at 11:07:55AM +0000, Walter Harms wrote:
> diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c
> index 3b8848182221..bdb6ff8aab7d 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_efuse.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c
> @@ -244,10 +244,8 @@ u16 Address)
> while (!(Bytetemp & 0x80)) {
> Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
> k++;
> - if (k == 1000) {
> - k = 0;
> + if (k == 1000)
> break;
> - }
>
> IMHO this is confusing to read, i suggest:
>
> for(k=0;k<1000;k++) {
> Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
> if ( Bytetemp & 0x80 )
> break;
> }
>
The problem with the original code is that the variable is named "k"
instead of "retry". It should be:
do {
Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3);
} while (!(Bytetemp & 0x80)) && ++retry < 1000);
> NTL is am wondering what will happen if k==1000
> and Bytetemp is still invalid. Will rtw_read8() fail or
> simply return invalid data ?
Yeah. That was my thought reviewing this patch as well.
It should probably return 0xff on failure.
if (retry >= 1000)
return 0xff;
regards,
dan carpenter
next prev parent reply other threads:[~2020-02-24 11:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-23 15:28 [PATCH] staging: rtl8723bs: core: remove redundant zero'ing of counter variable k Colin King
2020-02-24 11:07 ` AW: " Walter Harms
2020-02-24 11:27 ` Dan Carpenter [this message]
2020-02-24 11:36 ` Walter Harms
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=20200224112735.GC3286@kadam \
--to=dan.carpenter@oracle.com \
--cc=colin.king@canonical.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wharms@bfs.de \
/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).