2 * u_f.c -- USB function utilities for Gadget stack
4 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
7 * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/usb/ch9.h>
17 struct usb_request
*alloc_ep_req(struct usb_ep
*ep
, size_t len
, int default_len
)
19 struct usb_request
*req
;
21 req
= usb_ep_alloc_request(ep
, GFP_ATOMIC
);
23 req
->length
= len
?: default_len
;
24 if (usb_endpoint_dir_out(ep
->desc
))
25 req
->length
= usb_ep_align(ep
, req
->length
);
26 req
->buf
= kmalloc(req
->length
, GFP_ATOMIC
);
28 usb_ep_free_request(ep
, req
);
34 EXPORT_SYMBOL_GPL(alloc_ep_req
);