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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 17, 2021 at 03:01:27PM +0000, David Laight wrote:
> 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.

Yes it was a problem, which is why the USB core function called here
does not require that and makes sure to allocate the buffer itself so
that all will be fine.

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

USB speeds are slow you will never notice the difference for control
messages.

thanks,

greg k-h




[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux