public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Phillip Potter <phil@philpotter.co.uk>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: gregkh@linuxfoundation.org, Larry.Finger@lwfinger.net,
	paskripkin@gmail.com, straube.linux@gmail.com, martin@kaiser.cx,
	abdun.nihaal@gmail.com, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: r8188eu: convert rtw_pwr_wakeup to correct error code semantics
Date: Mon, 25 Jul 2022 22:03:02 +0100	[thread overview]
Message-ID: <Yt8FBtHnNCGSZAf/@equinox> (raw)
In-Reply-To: <20220725104027.GO2338@kadam>

On Mon, Jul 25, 2022 at 01:40:27PM +0300, Dan Carpenter wrote:
> On Sun, Jul 24, 2022 at 05:30:55PM +0100, Phillip Potter wrote:
> > Convert the rtw_pwr_wakeup function to use 0 on success and -EPERM on
> > error - in all places where we handle this response, we use either -1 or
> > -EPERM currently anyway, which are equivalent. Also, for other places
> > along the same call chain where we are using -1, use -EPERM.
> > 
> 
> I can't get behind a change to -EPERM.  Try to pick an appropriate
> error code.  I'm not going to be very strict on it, but we have to at
> least *try*.
> 
> Probably, leave the return -1; lines alone.  Fixing that seems like an
> unrelated change.  We need to do this kind of change but I got bitten by
> it before so I want to avoid that next time.  My reviews will hopefully
> be more careful now.
> 
> > This gets the driver closer to removal of the non-standard _SUCCESS and
> > _FAIL definitions, which are inverted compared to the standard in-kernel
> > error code mechanism.
> > 
> > Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
> > ---
> >  drivers/staging/r8188eu/core/rtw_p2p.c       |  4 +--
> >  drivers/staging/r8188eu/core/rtw_pwrctrl.c   | 10 +++---
> >  drivers/staging/r8188eu/os_dep/ioctl_linux.c | 32 ++++++++++----------
> >  3 files changed, 23 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c
> > index c306aafa183b..bd654d4ff8b4 100644
> > --- a/drivers/staging/r8188eu/core/rtw_p2p.c
> > +++ b/drivers/staging/r8188eu/core/rtw_p2p.c
> > @@ -1888,7 +1888,7 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role)
> >  
> >  	if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) {
> >  		/* leave IPS/Autosuspend */
> > -		if (rtw_pwr_wakeup(padapter) == _FAIL) {
> > +		if (rtw_pwr_wakeup(padapter)) {
> >  			ret = _FAIL;
> >  			goto exit;
> >  		}
> 
> Fine.  The caller now changes from negative error codes to _SUCCESS/_FAIL.
> Later we will transition this to normal error codes so we'll update it
> to preserve the error code from rtw_pwr_wakeup() at that point.
> 
> > diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > index 930bb4aea435..e0ae0c3c51f8 100644
> > --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > @@ -689,7 +689,7 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
> >  
> >  
> >  
> > -	if (_FAIL == rtw_pwr_wakeup(padapter)) {
> > +	if (rtw_pwr_wakeup(padapter)) {
> >  		ret = -EPERM;
> >  		goto exit;
> >  	}
> 
> This code is returning negative error codes so it should preserve the
> code from rtw_pwr_wakeup().
> 
> 	ret = rtw_pwr_wakeup(padapter);
> 	if (ret)
> 		goto exit;
> 
> > @@ -933,13 +933,13 @@ static int rtw_wx_set_wap(struct net_device *dev,
> >  
> >  
> >  
> > -	if (_FAIL == rtw_pwr_wakeup(padapter)) {
> > -		ret = -1;
> > +	if (rtw_pwr_wakeup(padapter)) {
> > +		ret = -EPERM;
> 
> Same.
> 
> >  		goto exit;
> >  	}
> >  
> >  	if (!padapter->bup) {
> > -		ret = -1;
> > +		ret = -EPERM;
> 
> Unrelated.
> 
> >  		goto exit;
> >  	}
> >  
> 
> [ snip ]
> 
> > @@ -1252,13 +1252,13 @@ static int rtw_wx_set_essid(struct net_device *dev,
> >  
> >  	uint ret = 0, len;
> >  
> > -	if (_FAIL == rtw_pwr_wakeup(padapter)) {
> > -		ret = -1;
> > +	if (rtw_pwr_wakeup(padapter)) {
> > +		ret = -EPERM;
> 
> Preserve the error code.
> 
> >  		goto exit;
> >  	}
> 
> regards,
> dan carpenter

Hi Dan,

Thanks very much for the review. I'll get a V2 sent out shortly.

Regards,
Phil

      reply	other threads:[~2022-07-25 21:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-24 16:30 [PATCH] staging: r8188eu: convert rtw_pwr_wakeup to correct error code semantics Phillip Potter
2022-07-24 18:39 ` Philipp Hortmann
2022-07-25 21:05   ` Phillip Potter
2022-07-25 10:40 ` Dan Carpenter
2022-07-25 21:03   ` Phillip Potter [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=Yt8FBtHnNCGSZAf/@equinox \
    --to=phil@philpotter.co.uk \
    --cc=Larry.Finger@lwfinger.net \
    --cc=abdun.nihaal@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=paskripkin@gmail.com \
    --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