usb_fill_control_urb(9)
π usb_fill_control_urb(9) β the Kernel API Manual, bestie edition π
Okay so this is a page straight out of the Kernel API Manual, and it's about usb_fill_control_urb β the little glow-up routine that gets a control urb ready to go out into the world. Let's get into it β¨
πΈ NAME πΈ
usb_fill_control_urb β initializes a control urb, periodt π
π¦ SYNOPSIS π¦
void usb_fill_control_urb (struct urb *urb , struct usb_device *dev ,
unsigned int pipe , unsigned char *setup_packet , void *transfer_buffer
, int buffer_length , usb_complete_t complete_fn , void *context );
β¨ ARGUMENTS β¨
urbβ pointer to the urb you're about to initialize. yep, that one π«Άdevβ pointer to thestruct usb_devicefor this urb.pipeβ the endpoint pipe.setup_packetβ pointer to the setup_packet buffer. β οΈ heads up: the buffer must be suitable for DMA.transfer_bufferβ pointer to the transfer buffer. also must be suitable for DMA, no exceptions πbuffer_lengthβ length of the transfer buffer.complete_fnβ pointer to theusb_complete_tfunction.contextβ what to set the urb context to.
π₯ DESCRIPTION π₯
So what does it do? It initializes a control urb with all the proper information needed to submit it to a device. That's the whole gig, and it ate π
Now the part you actually need to internalize, bestie: the transfer buffer and the setup_packet buffer will most likely be filled or read via DMA. The simplest way to get a buffer that can be DMAed to is allocating it via kmalloc or equivalent β even for very small buffers. Like, don't get cute about it, just kmalloc it π
If the buffers are embedded in a bigger structure, there is a risk that the buffer itself, the previous fields and/or the next fields are corrupted due to cache incoherencies β or slowed down if they are evicted from the cache. Not a vibe π
For more information, check struct urb. iykyk π
π SEE ALSO π
Kernel file ./include/linux/usb.h β plus the whole squad, and yes we're listing every single one of them, no cap π
struct usb_host_endpoint(9)struct usb_interface(9)usb_set_intfdata(9)struct usb_interface_cache(9)struct usb_host_config(9)struct usb_device(9)usb_hub_for_each_child(9)usb_interface_claimed(9)usb_make_path(9)USB_DEVICE(9)USB_DEVICE_VER(9)USB_DEVICE_INTERFACE_CLASS(9)USB_DEVICE_INTERFACE_PROTOCOL(9)USB_DEVICE_INTERFACE_NUMBER(9)USB_DEVICE_INFO(9)USB_INTERFACE_INFO(9)USB_DEVICE_AND_INTERFACE_INFO(9)USB_VENDOR_AND_INTERFACE_INFO(9)struct usb_driver(9)struct usb_device_driver(9)struct usb_class_driver(9)module_usb_driver(9)struct urb(9)usb_fill_bulk_urb(9)usb_fill_int_urb(9)usb_urb_dir_in(9)usb_urb_dir_out(9)struct usb_sg_request(9)
And that's the whole page, bestie π«Ά This lil icon comes to you from ./include/linux, dated October 2026, living in the Kernel API Manual β go forth and DMA responsibly π§π
π¦ 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