LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"open list:STAGING SUBSYSTEM" <linux-staging@lists.linux.dev>,
	open list <linux-kernel@vger.kernel.org>,
	Pavel Skripkin <paskripkin@gmail.com>
Subject: Re: [PATCH RFC] staging: r8188eu: Use usb_control_msg_recv/send() in usbctrl_vendorreq()
Date: Mon, 23 Aug 2021 12:47:45 +0200	[thread overview]
Message-ID: <8275282.m2tVFbhrJk@localhost.localdomain> (raw)
In-Reply-To: <69bbb80c-2b30-28b9-ad8c-6862a6c3b911@gmail.com>

On Monday, August 23, 2021 10:11:52 AM CEST Pavel Skripkin wrote:
> On 8/23/21 2:02 AM, 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.
> > 
> > This patch is an RFC for different reasons:
> > 
> > 1) I'm not sure if it is needed: while Greg Kroah-Hartman suggested to
> > use the new API in a message to a thread that was about a series of patches
> > submitted by Pavel Skripkin (who decided to not use it), I cannot explain
> > if and why the driver would benefit from this patch.
> > 2) I have doubts about the semantic of the API I use here, so I'd like to
> > know whether or not I'm using them properly.
> > 3) At the moment I cannot test the driver because I don't have my device
> > with me.
> > 4) This patch could probably lead to a slight change in some lines of
> > Pavel's series (for sure in usb_read*()).
> > 
> > I'd like to hear from the Maintainers and other interested people if this
> > patch is worth to be considered and, in this case, if there are suggestions
> > for the purpose to improve it.
> > 
> > Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> > ---
> >   drivers/staging/r8188eu/hal/usb_ops_linux.c | 19 ++++++++++---------
> >   1 file changed, 10 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c
> > index 6a0a24acf292..9e290c1cc449 100644
> > --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c
> > +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c
> > @@ -15,7 +15,7 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata,
> >   	struct adapter	*adapt = pintfhdl->padapter;
> >   	struct dvobj_priv  *dvobjpriv = adapter_to_dvobj(adapt);
> >   	struct usb_device *udev = dvobjpriv->pusbdev;
> > -	unsigned int pipe;
> > +	u8 pipe;
> >   	int status = 0;
> >   	u8 reqtype;
> 
> I think, we can pass REALTEK_USB_VENQT_{READ,WRITE} directly as 
> requesttype argument and get rid of u8 reqtype. + we can define these 
> macros:
> 
> #define
> usbctrl_vendor_read(...)   usbctrl_vendorreq(...,REALTEK_USB_VENQT_READ)
> 
> 
> #define
> usbctrl_vendor_write()    usbctrl_vendorreq(...,REALTEK_USB_VENQT_WRITE)
> 
> 
> This will make code more nice, IMO  :)

Dear Pavel,

I agree in full: nicer and cleaner :)

I'll do that, but please notice that I will also need to change the code of the three 
usb_read*() for calling usbctrl_vendor_read(). Furthermore, "else res = 0;" becomes
unnecessary. Please take these changes into account when you'll send them again
as "regular" patches.

> (Sorry for this formatting, my email client disabled "paste without 
> formatting" option)

Actually I don't see any oddities in the format of your message :)

> >   	u8 *pIo_buf;
> > @@ -47,19 +47,20 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata,
> >   		memset(pIo_buf, 0, len);
> >   
> >   		if (requesttype == 0x01) {
> > -			pipe = usb_rcvctrlpipe(udev, 0);/* read_in */
> >   			reqtype =  REALTEK_USB_VENQT_READ;
> > +			status = usb_control_msg_recv(udev, pipe, REALTEK_USB_VENQT_CMD_REQ,
> > +						      reqtype, value, REALTEK_USB_VENQT_CMD_IDX,
> > +						      pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT,
> > +						      GFP_KERNEL);
> >   		} else {
> > -			pipe = usb_sndctrlpipe(udev, 0);/* write_out */
> >   			reqtype =  REALTEK_USB_VENQT_WRITE;
> > -			memcpy(pIo_buf, pdata, len);
> 
> I guess, this memcpy is needed, since we want to send data from pdata

Oh, dear! How could I have missed that? Two alternatives: either because of working 
during bedtime, or I'm definitely losing my mind... :(
 
> 
> > +			status = usb_control_msg_send(udev, pipe, REALTEK_USB_VENQT_CMD_REQ,
> > +						      reqtype, value, REALTEK_USB_VENQT_CMD_IDX,
> > +						      pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT,
> > +						      GFP_KERNEL);
> >   		}
> >   
> > -		status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ,
> > -					 reqtype, value, REALTEK_USB_VENQT_CMD_IDX,
> > -					 pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
> > -
> > -		if (status == len) {   /*  Success this control transfer. */
> > +		if (!status) {   /*  Success this control transfer. */
> >   			rtw_reset_continual_urb_error(dvobjpriv);
> >   			if (requesttype == 0x01)
> >   				memcpy(pdata, pIo_buf,  len);
> > 
> 
> 
> With regards,
> Pavel Skripkin

Thanks for you review, I really appreciate it.

Regards,

Fabio

P.S.: As I wrote, I have not my ASUS N10 Nano with me and I won't have the opportunity
to test this as well as any other patch until the end of August. I hope to not break anything.
If somebody has time to test the final patch that I'm going to submit, I'd really appreciate it.



  parent reply	other threads:[~2021-08-23 10:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22 23:02 Fabio M. De Francesco
2021-08-23  8:11 ` Pavel Skripkin
2021-08-23  8:30   ` Pavel Skripkin
2021-08-23 10:52     ` Fabio M. De Francesco
2021-08-23 10:47   ` Fabio M. De Francesco [this message]
2021-08-23 11:05     ` Pavel Skripkin
2021-08-24  0:20       ` Fabio M. De Francesco
2021-08-23 21:41     ` Phillip Potter

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=8275282.m2tVFbhrJk@localhost.localdomain \
    --to=fmdefrancesco@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --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 \
    --subject='Re: [PATCH RFC] staging: r8188eu: Use usb_control_msg_recv/send() in usbctrl_vendorreq()' \
    /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

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).