2013-11-07 14:41:26 +07:00
|
|
|
/*
|
|
|
|
* 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 "u_f.h"
|
2016-08-09 03:30:06 +07:00
|
|
|
#include <linux/usb/ch9.h>
|
2013-11-07 14:41:26 +07:00
|
|
|
|
2016-08-09 03:30:05 +07:00
|
|
|
struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len, int default_len)
|
2013-11-07 14:41:26 +07:00
|
|
|
{
|
|
|
|
struct usb_request *req;
|
|
|
|
|
|
|
|
req = usb_ep_alloc_request(ep, GFP_ATOMIC);
|
|
|
|
if (req) {
|
|
|
|
req->length = len ?: default_len;
|
2016-08-09 03:30:06 +07:00
|
|
|
if (usb_endpoint_dir_out(ep->desc))
|
|
|
|
req->length = usb_ep_align(ep, req->length);
|
2013-11-07 14:41:26 +07:00
|
|
|
req->buf = kmalloc(req->length, GFP_ATOMIC);
|
|
|
|
if (!req->buf) {
|
|
|
|
usb_ep_free_request(ep, req);
|
|
|
|
req = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return req;
|
|
|
|
}
|
2014-04-02 01:19:32 +07:00
|
|
|
EXPORT_SYMBOL_GPL(alloc_ep_req);
|