Hi Pete,

> >      usb-add-urb_free_buffer-flag-and-the-logic-behind-it.patch
> 
> > +++ b/drivers/usb/core/urb.c
> > @@ -13,6 +13,9 @@ static void urb_destroy(struct kref *kre
> >  {
> >     struct urb *urb = to_urb(kref);
> >  
> > +   if (urb->transfer_flags & URB_FREE_BUFFER)
> > +           kfree(urb->transfer_buffer);
> > +
> >     kfree(urb);
> 
> I liked the constructors which kept the URB_FREE_BUFFER outside of grabby
> little hands of drivers, but this is good too, I suppose. I'm going to
> use this right away. Marcel, please let me know if I'm doing it wrong.

actually it seems that Greg didn't like the extra helpers for even
allocating the buffers. We can always add them later.

> --- a/drivers/usb/class/usblp.c
> +++ b/drivers/usb/class/usblp.c
> @@ -330,9 +330,6 @@ static void usblp_bulk_write(struct urb *urb)
>       wake_up(&usblp->wwait);
>       spin_unlock(&usblp->lock);
>  
> -     /* XXX Use usb_setup_bulk_urb when available. Talk to Marcel. */
> -     kfree(urb->transfer_buffer);
> -     urb->transfer_buffer = NULL;    /* Not refcounted, so to be safe... */
>       usb_free_urb(urb);
>  }
>  
> @@ -718,6 +715,7 @@ static ssize_t usblp_write(struct file *file, const char 
> __user *buffer, size_t
>                       usb_sndbulkpipe(usblp->dev,
>                         
> usblp->protocol[usblp->current_protocol].epwrite->bEndpointAddress),
>                       writebuf, transfer_length, usblp_bulk_write, usblp);
> +             writeurb->transfer_flags |= URB_FREE_BUFFER;
>               usb_anchor_urb(writeurb, &usblp->urbs);
>  
>               if (copy_from_user(writebuf, 

I am using it exactly like this. Actually I am also using it for URBs
that I re-submit all the time unless I use the anchor to kill them.

Regards

Marcel



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to