linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Pavel Skripkin <paskripkin@gmail.com>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: Re: [PATCH v3 1/2] staging: r8188eu: Use usb_control_msg_recv/send() in usbctrl_vendorreq()
Date: Thu, 26 Aug 2021 16:45:33 +0200	[thread overview]
Message-ID: <YSepDdf+nHekuIxA@kroah.com> (raw)
In-Reply-To: <47945171.69uSEkksVi@localhost.localdomain>

On Thu, Aug 26, 2021 at 04:24:35PM +0200, Fabio M. De Francesco wrote:
> On Thursday, August 26, 2021 12:48:37 PM CEST Greg Kroah-Hartman wrote:
> > On Wed, Aug 25, 2021 at 05:53:10AM +0200, Fabio M. De Francesco wrote:
> > > Replace usb_control_msg() with the new usb_control_msg_recv() and
> > > usb_control_msg_send() API of USB Core in usbctrl_vendorreq().
> > > Remove no more needed variables. Move out of an if-else block
> > > some code that it is no more dependent on status < 0. Remove
> > > redundant code depending on status > 0 or status == len.
> > > 
> > > Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> > > ---
> > > 
> > > v2->v3: Restore the test for success of usb_control_message_recv/send
> > > that was inadvertently removed. Issue reported by Pavel Skripkin.
> > > 
> > > v1->v2: According to suggestions by Christophe JAILLET 
> > > <christophe.jaillet@wanadoo.fr>, remove 'pipe' and pass an explicit 0
> > > to the new API. According to suggestions by Pavel Skripkin 
> > > <paskripkin@gmail.com>, remove an extra if-else that is no more needed, 
> > > since status can be 0 and < 0 and there is no 3rd state, like it was before.
> > > Many thanks to them and also to Phillip Potter <phil@philpotter.co.uk>
> > > who kindly offered his time for the purpose of testing v1.
> > > 
> > >  drivers/staging/r8188eu/hal/usb_ops_linux.c | 45 ++++++++-------------
> > >  1 file changed, 17 insertions(+), 28 deletions(-)
> > 
> > This doesn't apply to my tree at all.  Please rebase and resend.
> 
> This series cannot apply to your tree until another one of mine is applied 
> ("staging: r8188eu: Remove _enter/_exit_critical_mutex()"). This series builds
> on the previous patch.

When you do that, please let me know somehow that this is the case,
otherwise how am I supposed to guess that?

> > But first, are you sure you want to use these new functions here?  This
> > is a "common" function that is called from different places for
> > different things.  How about unwinding the callers of this function
> > first, to see if they really need all of the complexity in this function
> > at all, and if not, then call the real USB function in those locations
> > instead.
> 
> I think it could be fine to simply refactor usbctrl_vendorreq() to use the newer
> API with no necessity to directly use them at least in six different places in
> hal/usb_ops_linux.c. The only users of this helper are usb_read8/16/32() and
> usb_write8/16/32(). Why do you prefer using usb_control_msg_recv/send() 
> directly in the callers? I guess it would lead to redundant code, more or less
> the same code repeated again and again within the above-mentioned six callers.
> What do we improve by doing as you suggest? What am I missing?

If you unwind the mess, you will find that the code will be much easier
to understand.

As an example, look at usb_write8().  Where is it ever called?  Why do
we have it at all?  It's only used in 1 place, and then that function
unwinds into rtw_write8(), which is used in a lot of places, and never
checked at all, making the majority of the logic in this function
totally unneeded and useless.

Same for rtw_write16() and rtw_write32().  After unwinding the mess you
see that the logic you are working to try to clean up in this patch
series is pretty much not used / needed at all, right?  So why do it?

Unwind the mess into a useful set of functions the driver can actually
call that is not 2-4 function pointers deep and then we can talk about
unifying things, if they are really needed.  But right now, it's
impossible to tell.

good luck!

greg k-h

  reply	other threads:[~2021-08-26 14:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25  3:53 [PATCH v3 0/2] staging: r8188eu: Use new usb_control_msg_recv/send() Fabio M. De Francesco
2021-08-25  3:53 ` [PATCH v3 1/2] staging: r8188eu: Use usb_control_msg_recv/send() in usbctrl_vendorreq() Fabio M. De Francesco
2021-08-25  9:01   ` Pavel Skripkin
2021-08-26 10:48   ` Greg Kroah-Hartman
2021-08-26 14:24     ` Fabio M. De Francesco
2021-08-26 14:45       ` Greg Kroah-Hartman [this message]
2021-08-26 15:43         ` Fabio M. De Francesco
2021-08-26 18:18   ` Pavel Skripkin
2021-08-26 18:56     ` Fabio M. De Francesco
2021-08-26 19:12       ` Pavel Skripkin
2021-08-25  3:53 ` [PATCH v3 2/2] staging: r8188eu: Make clean-ups " Fabio M. De Francesco

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=YSepDdf+nHekuIxA@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=Larry.Finger@lwfinger.net \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=fmdefrancesco@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=paskripkin@gmail.com \
    --cc=phil@philpotter.co.uk \
    /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).