u_f.c 814 B

123456789101112131415161718192021222324252627282930313233
  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. #include <linux/usb/gadget.h>
  14. #include "u_f.h"
  15. struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len)
  16. {
  17. struct usb_request *req;
  18. req = usb_ep_alloc_request(ep, GFP_ATOMIC);
  19. if (req) {
  20. req->length = len ?: default_len;
  21. req->buf = kmalloc(req->length, GFP_ATOMIC);
  22. if (!req->buf) {
  23. usb_ep_free_request(ep, req);
  24. req = NULL;
  25. }
  26. }
  27. return req;
  28. }
  29. EXPORT_SYMBOL_GPL(alloc_ep_req);