usb_control_msg(9)
β¨ usb_control_msg β Kernel API Manual, page 9 β¨
ok so like, welcome to the usb_control_msg(9) glow-up bestie π
this is the little kernel man page that lives over in ./drivers/usb/core and honestly? she's kind of a legend. periodt.
πΈ NAME πΈ
usb_control_msg β builds a control urb, sends it off, and waits for completion. that's it, that's the whole vibe π
π¦ SYNOPSIS π¦
int usb_control_msg (struct usb_device *dev , unsigned int pipe , __u8
request , __u8 requesttype , __u16 value , __u16 index , void *data ,
__u16 size , int timeout );
like, nine arguments. she is high-maintenance and we love her for it π«Ά
π ARGUMENTS π
devβ pointer to the usb device you're sending the message to. the main character, fr.pipeβ the endpoint "pipe" you're sending the message to. it's giving delivery route.requestβ the USB message request value.requesttypeβ the USB message request type value.valueβ the USB message value.indexβ the USB message index value.dataβ pointer to the data you're sending.sizeβ length in bytes of the data you're sending. yes, bytes. count them. πtimeoutβ time in msecs to wait for the message to complete before timing out.
π§ CONTEXT π§
task context, might sleep. π΄ lowkey the whole tea right there.
π DESCRIPTION π
ok so what she actually does: this function sends a simple control message to a specified endpoint and then waits for the message to complete β or to time out. no cap, that's the job. β
do NOT use this function from within an interrupt context. π like, seriously, don't.
if you need an asynchronous message, or you need to send a message from within interrupt context, use usb_submit_urb instead. that's the move. π
and if a thread in your driver uses this call, make sure your disconnect method can wait for it to complete. why? because you don't have a handle on the URB being used, so β and this is the crucial part β you can't cancel the request. π no takebacks, no undo button, it's giving commitment issues but in reverse.
π RETURN π
- if it's successful β the number of bytes transferred. slay. π
- otherwise β a negative error number. not slay, but informative. π
π SEE ALSO π
- Kernel file
./drivers/usb/core/message.c usb_control_msg_send(9)usb_control_msg_recv(9)usb_interrupt_msg(9)usb_bulk_msg(9)usb_bulk_msg_killable(9)usb_sg_init(9)usb_sg_wait(9)usb_sg_cancel(9)usb_get_descriptor(9)usb_get_string(9)usb_string(9)usb_cache_string(9)usb_get_status(9)usb_clear_halt(9)usb_disable_endpoint(9)usb_reset_endpoint(9)usb_disable_interface(9)usb_disable_device(9)usb_enable_endpoint(9)usb_enable_interface(9)usb_set_interface(9)usb_reset_configuration(9)usb_set_wireless_status(9)usb_driver_set_configuration(9)cdc_parse_cdc_header(9)
like, the whole friend group showed up. iykyk π
π okay that's the page!! shoutout to ./drivers/usb/core, dated October 2026 β she's serving usb realness and we are obsessed. bye bestie, go send some control messages (respectfully, not from interrupt context) π
π¦ 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