diff options
Diffstat (limited to 'include/linux/usb/gadget.h')
| -rw-r--r-- | include/linux/usb/gadget.h | 25 | 
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 0f28c5512fcb..3aaf19e77558 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -15,6 +15,7 @@  #ifndef __LINUX_USB_GADGET_H  #define __LINUX_USB_GADGET_H +#include <linux/cleanup.h>  #include <linux/configfs.h>  #include <linux/device.h>  #include <linux/errno.h> @@ -32,6 +33,7 @@ struct usb_ep;  /**   * struct usb_request - describes one i/o request + * @ep: The associated endpoint set by usb_ep_alloc_request().   * @buf: Buffer used for data.  Always provide this; some controllers   *	only use PIO, or don't use DMA for some endpoints.   * @dma: DMA address corresponding to 'buf'.  If you don't set this @@ -98,6 +100,7 @@ struct usb_ep;   */  struct usb_request { +	struct usb_ep		*ep;  	void			*buf;  	unsigned		length;  	dma_addr_t		dma; @@ -291,6 +294,28 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep)  /*-------------------------------------------------------------------------*/ +/** + * free_usb_request - frees a usb_request object and its buffer + * @req: the request being freed + * + * This helper function frees both the request's buffer and the request object + * itself by calling usb_ep_free_request(). Its signature is designed to be used + * with DEFINE_FREE() to enable automatic, scope-based cleanup for usb_request + * pointers. + */ +static inline void free_usb_request(struct usb_request *req) +{ +	if (!req) +		return; + +	kfree(req->buf); +	usb_ep_free_request(req->ep, req); +} + +DEFINE_FREE(free_usb_request, struct usb_request *, free_usb_request(_T)) + +/*-------------------------------------------------------------------------*/ +  struct usb_dcd_config_params {  	__u8  bU1devExitLat;	/* U1 Device exit Latency */  #define USB_DEFAULT_U1_DEV_EXIT_LAT	0x01	/* Less then 1 microsec */  | 
