usb_get_descriptor(9)
β¨ usb_get_descriptor β¨
okay bestie, welcome to the Kernel API Manual β today's main character is usb_get_descriptor(9), the function that just... goes and asks a USB device for its descriptor. no cap, it's a whole vibe π
π NAME π
usb_get_descriptor β issues a generic GET_DESCRIPTOR request π¦
πΈ SYNOPSIS πΈ
int usb_get_descriptor (struct usb_device *dev , unsigned char type ,
unsigned char index , void *buf , int size );
π ARGUMENTS π
devβ the device whose descriptor is being retrieved π like, whose paperwork are we pullingtypeβ the descriptor type (one of theUSB_DT_*fam) π·οΈindexβ the number of the descriptor π’ which one in the lineup, bestiebufβ where to put the descriptor π₯ the drop-off spotsizeβ how big is"buf"? π literally the capacity check, don't overflow it fr fr
π§ CONTEXT π§
task context, and it might sleep. π΄ so like, give it a comfy bed, not a frantic hallway
π DESCRIPTION π
So what does it do? Gets a USB descriptor. simple as that, slay. β¨
Convenience functions exist to simplify getting some types of descriptors β because the kernel devs are thoughtful like that π«Ά. Use usb_get_string or usb_string for USB_DT_STRING π. Device descriptors (USB_DT_DEVICE) and configuration descriptors (USB_DT_CONFIG) are already part of the device structure β so like, they're already in the group chat, no need to re-request them π.
In addition to a number of USB-standard descriptors, some devices also use class-specific or vendor-specific descriptors π β yes, devices love to have their own little custom lore, iykyk.
β οΈ Heads up bestie: this call is synchronous, and it may not be used in an interrupt context. Periodt. Do not try it in interrupt context, it's giving undefined chaos and we don't do that here π
β RETURN β
The number of bytes received on success π β or else the status code returned by the underlying usb_control_msg call. So if it's not a happy byte count, that status code is the tea you're getting π΅
π₯ SEE ALSO π₯
Kernel file ./drivers/usb/core/message.c, plus the whole friend group:
usb_control_msg(9)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_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)
and that's the whole page, bestie π«Άπ this lil masterpiece lives in ./drivers/usb/core, and it's stamped October 2026 β mwah, iconic, no notes πβ¨π
π¦ 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