Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * u_f.c -- USB function utilities for Gadget stack
0004  *
0005  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
0006  *      http://www.samsung.com
0007  *
0008  * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
0009  */
0010 
0011 #include "u_f.h"
0012 #include <linux/usb/ch9.h>
0013 
0014 struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len)
0015 {
0016     struct usb_request      *req;
0017 
0018     req = usb_ep_alloc_request(ep, GFP_ATOMIC);
0019     if (req) {
0020         req->length = usb_endpoint_dir_out(ep->desc) ?
0021             usb_ep_align(ep, len) : len;
0022         req->buf = kmalloc(req->length, GFP_ATOMIC);
0023         if (!req->buf) {
0024             usb_ep_free_request(ep, req);
0025             req = NULL;
0026         }
0027     }
0028     return req;
0029 }
0030 EXPORT_SYMBOL_GPL(alloc_ep_req);