usb: gadget: factor out alloc_ep_req
alloc_ep_req() is a function repeated in several modules. Make a common implementation and use it. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:

committed by
Felipe Balbi

parent
a01091e5ce
commit
1efd54eab2
32
drivers/usb/gadget/u_f.c
Normal file
32
drivers/usb/gadget/u_f.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* u_f.c -- USB function utilities for Gadget stack
|
||||
*
|
||||
* Copyright (c) 2013 Samsung Electronics Co., Ltd.
|
||||
* http://www.samsung.com
|
||||
*
|
||||
* Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/usb/gadget.h>
|
||||
#include "u_f.h"
|
||||
|
||||
struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len)
|
||||
{
|
||||
struct usb_request *req;
|
||||
|
||||
req = usb_ep_alloc_request(ep, GFP_ATOMIC);
|
||||
if (req) {
|
||||
req->length = len ?: default_len;
|
||||
req->buf = kmalloc(req->length, GFP_ATOMIC);
|
||||
if (!req->buf) {
|
||||
usb_ep_free_request(ep, req);
|
||||
req = NULL;
|
||||
}
|
||||
}
|
||||
return req;
|
||||
}
|
||||
EXPORT_SYMBOL(alloc_ep_req);
|
Reference in New Issue
Block a user