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