Andrzej Pietrasiewicz | 1efd54e | 2013-11-07 08:41:26 +0100 | [diff] [blame] | 1 | /* |
| 2 | * u_f.c -- USB function utilities for Gadget stack |
| 3 | * |
| 4 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. |
| 5 | * http://www.samsung.com |
| 6 | * |
| 7 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> |
| 8 | * |
| 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. |
| 12 | */ |
| 13 | |
Andrzej Pietrasiewicz | 1efd54e | 2013-11-07 08:41:26 +0100 | [diff] [blame] | 14 | #include "u_f.h" |
Felipe F. Tonello | e046615 | 2016-08-08 21:30:06 +0100 | [diff] [blame] | 15 | #include <linux/usb/ch9.h> |
Andrzej Pietrasiewicz | 1efd54e | 2013-11-07 08:41:26 +0100 | [diff] [blame] | 16 | |
Felipe F. Tonello | aadbe81 | 2016-08-23 18:24:49 +0100 | [diff] [blame] | 17 | struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len) |
Andrzej Pietrasiewicz | 1efd54e | 2013-11-07 08:41:26 +0100 | [diff] [blame] | 18 | { |
| 19 | struct usb_request *req; |
| 20 | |
| 21 | req = usb_ep_alloc_request(ep, GFP_ATOMIC); |
| 22 | if (req) { |
Felipe F. Tonello | aadbe81 | 2016-08-23 18:24:49 +0100 | [diff] [blame] | 23 | req->length = usb_endpoint_dir_out(ep->desc) ? |
| 24 | usb_ep_align(ep, len) : len; |
Andrzej Pietrasiewicz | 1efd54e | 2013-11-07 08:41:26 +0100 | [diff] [blame] | 25 | req->buf = kmalloc(req->length, GFP_ATOMIC); |
| 26 | if (!req->buf) { |
| 27 | usb_ep_free_request(ep, req); |
| 28 | req = NULL; |
| 29 | } |
| 30 | } |
| 31 | return req; |
| 32 | } |
Felipe Balbi | 0700faa | 2014-04-01 13:19:32 -0500 | [diff] [blame] | 33 | EXPORT_SYMBOL_GPL(alloc_ep_req); |