u_f.c 688 B

12345678910111213141516171819202122232425262728293031
  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 <andrzej.p@samsung.com>
  9. */
  10. #include "u_f.h"
  11. #include <linux/usb/ch9.h>
  12. struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len)
  13. {
  14. struct usb_request *req;
  15. req = usb_ep_alloc_request(ep, GFP_ATOMIC);
  16. if (req) {
  17. req->length = usb_endpoint_dir_out(ep->desc) ?
  18. usb_ep_align(ep, len) : len;
  19. req->buf = kmalloc(req->length, GFP_ATOMIC);
  20. if (!req->buf) {
  21. usb_ep_free_request(ep, req);
  22. req = NULL;
  23. }
  24. }
  25. return req;
  26. }
  27. EXPORT_SYMBOL_GPL(alloc_ep_req);