2017-11-03 10:28:30 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-11-07 07:41:26 +00:00
|
|
|
/*
|
|
|
|
* u_f.c -- USB function utilities for Gadget stack
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013 Samsung Electronics Co., Ltd.
|
|
|
|
* http://www.samsung.com
|
|
|
|
*
|
2018-12-13 13:24:57 +00:00
|
|
|
* Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
|
2013-11-07 07:41:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "u_f.h"
|
2016-08-08 20:30:06 +00:00
|
|
|
#include <linux/usb/ch9.h>
|
2013-11-07 07:41:26 +00:00
|
|
|
|
2016-08-23 17:24:49 +00:00
|
|
|
struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len)
|
2013-11-07 07:41:26 +00:00
|
|
|
{
|
|
|
|
struct usb_request *req;
|
|
|
|
|
|
|
|
req = usb_ep_alloc_request(ep, GFP_ATOMIC);
|
|
|
|
if (req) {
|
2016-08-23 17:24:49 +00:00
|
|
|
req->length = usb_endpoint_dir_out(ep->desc) ?
|
|
|
|
usb_ep_align(ep, len) : len;
|
2013-11-07 07:41:26 +00:00
|
|
|
req->buf = kmalloc(req->length, GFP_ATOMIC);
|
|
|
|
if (!req->buf) {
|
|
|
|
usb_ep_free_request(ep, req);
|
|
|
|
req = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return req;
|
|
|
|
}
|
2014-04-01 18:19:32 +00:00
|
|
|
EXPORT_SYMBOL_GPL(alloc_ep_req);
|