linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pavel Skripkin <paskripkin@gmail.com>
Cc: gregkh@linuxfoundation.org, Larry.Finger@lwfinger.net,
	phil@philpotter.co.uk, straube.linux@gmail.com,
	fmdefrancesco@gmail.com, linux-kernel@vger.kernel.org,
	linux-staging@lists.linux.dev
Subject: Re: [PATCH 3/4] staging: r8188eu: add error handling of rtw_read32
Date: Thu, 19 May 2022 08:43:56 +0300	[thread overview]
Message-ID: <20220519054356.GU4009@kadam> (raw)
In-Reply-To: <5cab10528fed7d440ee57f93183d18c9de998adb.1652911343.git.paskripkin@gmail.com>

On Thu, May 19, 2022 at 01:12:01AM +0300, Pavel Skripkin wrote:
> diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c
> index a2691c7f96f6..7105122c2ba0 100644
> --- a/drivers/staging/r8188eu/core/rtw_efuse.c
> +++ b/drivers/staging/r8188eu/core/rtw_efuse.c
> @@ -47,9 +47,18 @@ ReadEFuseByte(
>  
>  	/* Check bit 32 read-ready */
>  	retry = 0;
> -	value32 = rtw_read32(Adapter, EFUSE_CTRL);
> -	while (!(((value32 >> 24) & 0xff) & 0x80)  && (retry < 10000)) {
> -		value32 = rtw_read32(Adapter, EFUSE_CTRL);
> +	res = rtw_read32(Adapter, EFUSE_CTRL, &value32);
> +	if (res)
> +		return;
> +
> +	while (retry < 10000) {
> +		res = rtw_read32(Adapter, EFUSE_CTRL, &value32);
> +		if (res)
> +			continue;

Forever loop.  Always put the ++ in side the while ().  Apparently,
Smatch does not catch this.  #Idea #Oppurtunity

> +
> +		if (((value32 >> 24) & 0xff) & 0x80)
> +			break;
> +
>  		retry++;
>  	}

[ snip ]

> @@ -215,7 +222,10 @@ static int fw_free_to_go(struct adapter *padapter)
>  	/*  polling for FW ready */
>  	counter = 0;
>  	do {
> -		value32 = rtw_read32(padapter, REG_MCUFWDL);
> +		res = rtw_read32(padapter, REG_MCUFWDL, &value32);
> +		if (res)
> +			continue;
> +
>  		if (value32 & WINTINI_RDY)
>  			return _SUCCESS;
>  		udelay(5);

You really want to do this delay on each iteration.  So write it like
so:

		res = rtw_read32(padapter, REG_MCUFWDL, &value32);
		if (!res && value32 & WINTINI_RDY)
			return _SUCCESS;
		udelay(5);


> diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
> index d4e59fab367c..e54d4139466d 100644
> --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
> +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
> @@ -6023,6 +6023,7 @@ static void mlme_join(struct adapter *adapter, int type)
>  	struct mlme_priv *mlmepriv = &adapter->mlmepriv;
>  	u8 retry_limit = 0x30, reg;
>  	int res;
> +	u32 reg32;


The reg32 should got before the res so it's in reverse Christmas tree
order.

[ snip ]

> @@ -245,8 +246,18 @@ static void efuse_read_phymap_from_txpktbuf(
>  		} while (time_before(jiffies, timeout));
>  
>  		/* data from EEPROM needs to be in LE */
> -		lo32 = cpu_to_le32(rtw_read32(adapter, REG_PKTBUF_DBG_DATA_L));
> -		hi32 = cpu_to_le32(rtw_read32(adapter, REG_PKTBUF_DBG_DATA_H));
> +		res = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_L, &reg32);
> +		if (res)
> +			return;
> +
> +		lo32 = cpu_to_le32(reg32);
> +
> +

Double blank line.  Checkpatch?

> @@ -596,12 +611,16 @@ static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data)
>  	s32	count = 0;
>  	u32	value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS);
>  	u16	LLTReg = REG_LLT_INIT;
> +	int res;
>  
>  	rtw_write32(padapter, LLTReg, value);
>  
>  	/* polling */
>  	do {
> -		value = rtw_read32(padapter, LLTReg);
> +		res = rtw_read32(padapter, LLTReg, &value);
> +		if (res)
> +			continue;

This continue has the potential to lead to a forever loop.  The limit
check needs to be a part of the do while() condition.  Probably send
that patch first, by itself as a clean up before adding this continue.

> +
>  		if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value))
>  			break;
>  

regards,
dan carpenter


  reply	other threads:[~2022-05-19  5:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18 22:11 [PATCH 0/4] staging: r8188eu: add error handling of usb read errors Pavel Skripkin
2022-05-18 22:11 ` [PATCH 1/4] staging: r8188eu: add error handling of rtw_read8 Pavel Skripkin
2022-05-19  1:34   ` kernel test robot
2022-05-19  4:33   ` Dan Carpenter
2022-05-19  5:43     ` Pavel Skripkin
2022-05-19  5:49       ` Dan Carpenter
2022-05-18 22:11 ` [PATCH 2/4] staging: r8188eu: add error handling of rtw_read16 Pavel Skripkin
2022-05-19  4:47   ` Dan Carpenter
2022-05-18 22:12 ` [PATCH 3/4] staging: r8188eu: add error handling of rtw_read32 Pavel Skripkin
2022-05-19  5:43   ` Dan Carpenter [this message]
2022-05-19  5:48     ` Pavel Skripkin
2022-05-18 22:12 ` [PATCH 4/4] MAINTAINERS: add myself as r8188eu reviewer Pavel Skripkin
2022-05-19  5:46   ` Dan Carpenter

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=20220519054356.GU4009@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=fmdefrancesco@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=paskripkin@gmail.com \
    --cc=phil@philpotter.co.uk \
    --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;
as well as URLs for NNTP newsgroup(s).