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 1/4] staging: r8188eu: add error handling of rtw_read8
Date: Thu, 19 May 2022 08:49:38 +0300	[thread overview]
Message-ID: <20220519054938.GR29930@kadam> (raw)
In-Reply-To: <ff322920-6ddd-159d-b2f2-c0e4fc2e518f@gmail.com>

On Thu, May 19, 2022 at 08:43:23AM +0300, Pavel Skripkin wrote:
> > > +
> > > +	if (reg & RAM_DL_SEL) { /* 8051 RAM code */
> > >  		rtw_write8(padapter, REG_MCUFWDL, 0x00);
> > >  		rtw_reset_8051(padapter);
> > >  	}
> > > @@ -278,7 +303,14 @@ int rtl8188e_firmware_download(struct adapter *padapter)
> > >  	fwdl_timeout = jiffies + msecs_to_jiffies(500);
> > >  	while (1) {
> > >  		/* reset the FWDL chksum */
> > > -		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_CHKSUM_RPT);
> > > +		res = rtw_read8(padapter, REG_MCUFWDL, &reg);
> > > +		if (res == -ENODEV)
> > > +			break;
> > > +
> > > +		if (res)
> > > +			continue;
> > 
> > This continue is wrong.  If res = -EPERM then it's a forever loop.
> > Let's just break for every error.
> > 
> 
> I was trying to avoid strict breaking the loop on any error, since I am
> afraid this might break the driver.
> 
> What about:
> 
> 	do {
> 		/* reset the FWDL chksum */
> 		ret = rtw_read8(padapter, REG_MCUFWDL, &reg);
> 		if (ret == -ENODEV || ret == -EPERM)
> 			break;
> 
> 		if (ret) {
> 			ret == _FAIL;
> 			continue;
> 		}
> 
> 		rtw_write8(padapter, REG_MCUFWDL, reg | FWDL_CHKSUM_RPT);
> 
> 		ret = write_fw(padapter, fw_data, fw_size);
> 	} while (!(ret == _SUCCESS ||
> 		    (time_after(jiffies, fwdl_timeout) && write_fw_retry++ >= 3)))
> 
> The idea is to break only on fatal errors to make things less strict
> 

This is too complicated.

Treat all the errors the same, and use one time out condition.  Either
based on the jiffies or the retry count.

regards,
dan carpenter


  reply	other threads:[~2022-05-19  5:51 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 [this message]
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
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=20220519054938.GR29930@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).