Linux Audio

Check our new training course

Loading...
v4.6
 
 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
14#include "u_f.h"
 
15
16struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len)
17{
18	struct usb_request      *req;
19
20	req = usb_ep_alloc_request(ep, GFP_ATOMIC);
21	if (req) {
22		req->length = len ?: default_len;
 
23		req->buf = kmalloc(req->length, GFP_ATOMIC);
24		if (!req->buf) {
25			usb_ep_free_request(ep, req);
26			req = NULL;
27		}
28	}
29	return req;
30}
31EXPORT_SYMBOL_GPL(alloc_ep_req);
v6.2
 1// SPDX-License-Identifier: GPL-2.0
 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 *
 8 * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
 
 
 
 
 9 */
10
11#include "u_f.h"
12#include <linux/usb/ch9.h>
13
14struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len)
15{
16	struct usb_request      *req;
17
18	req = usb_ep_alloc_request(ep, GFP_ATOMIC);
19	if (req) {
20		req->length = usb_endpoint_dir_out(ep->desc) ?
21			usb_ep_align(ep, len) : len;
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}
30EXPORT_SYMBOL_GPL(alloc_ep_req);