RE: [PATCH v7 17/19] staging: r8188eu: shorten calls chain of rtw_read{8,16,32}()

From: David Laight
Date: Fri Sep 17 2021 - 11:01:39 EST


From: Greg Kroah-Hartman
> Sent: 17 September 2021 15:50
...
> > +static int usb_read(struct intf_hdl *intfhdl, u16 addr, void *data, u8 size)
> > +{
> > + struct adapter *adapt = intfhdl->padapter;
> > + struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt);
> > + struct usb_device *udev = dvobjpriv->pusbdev;
> > + int status;
> > + u8 *io_buf; /* Pointer to I/O buffer */
>
> As you "know" size is not going to be larger than 4 (hint, you should
> prboably check it), just use bytes off of the stack here, and you can
> ignore this buffer entirely. That will hopefully allow you in the
> future to get rid of that buffer as odds are it will not be needed
> anymore.

Isn't that likely to be the buffer that gets dma'd to/from?
In which case it can't be on-stack.
Certainly that is a common problem with usb drivers.

Give the size of the urb? structure allocated for each transfer
adding a bounce buffer area in it for short transfers would
surely be sane.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)