alloc_ep_req(9)
π alloc_ep_req β Kernel API Manual, section 9 π
okay bestie, welcome to alloc_ep_req(9), straight out of the Kernel API Manual (section 9, we love a numbered era). this one's a lil USB gadget helper and it's honestly so much chiller than it sounds, i promise π«Ά
β¨ NAME β¨
alloc_ep_req β returns a usb_request allocated by the gadget driver, and allocates the request's buffer. that's it, that's the whole gig π
πΈ SYNOPSIS πΈ
struct usb_request * alloc_ep_req (struct usb_ep *ep , size_t len );
π¦ ARGUMENTS π¦
epβ the endpoint you're allocating ausb_requestfor, bestie. point it at the right one πlenβ the suggested size for theusb_request's buffer. suggested, okay, remember that word, it's gonna matter in a sec π
π DESCRIPTION π
so here's the tea π: if ep's direction is OUT, the len you pass in gets aligned to ep's wMaxPacketSize. like, it's not gonna be exactly what you asked for, so don't come for her when the number's different.
and this is the part where i hold your hand: to avoid memory leaks or drops, always use the usb_request's length β that's req->length β to refer to the allocated buffer size. always always always. not your original len, not vibes, not what you remember passing in. req->length. periodt π
also, requests allocated viaalloc_ep_reqmust be freed byfree_ep_req. this is not a suggestion, this is the law. no main character energy where you free it some other way, you will leak and it will be tragic π
π SEE ALSO π
- Kernel file
./include/linux/usb/func_utils.hβ go read it, iykyk π§
and that's the page!! sending u off with the cutest sign-off i got: this lil doc lives in ./include/linux/usb, dated October 2026, so it's basically from the future and still slaying β¨π
π₯
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms