STRUCT USB_DEVICE_DRIVER(9)
π struct usb_device_driver(9) β the Kernel API Manual, bestie edition π
okay so. welcome to struct usb_device_driver(9), the little struct that tells usbcore "hey, this thing? it's a USB device driver, not a USB interface driver, iykyk." it's giving main character energy in ./include/linux/usb.h and honestly it ate. π¦
β¨ SYNOPSIS β¨
struct usb_device_driver {
const char *name;
bool (*match) (struct usb_device *udev);
int (*probe) (struct usb_device *udev);
void (*disconnect) (struct usb_device *udev);
int (*suspend) (struct usb_device *udev, pm_message_t message);
int (*resume) (struct usb_device *udev, pm_message_t message);
int (*choose_configuration) (struct usb_device *udev);
const struct attribute_group **dev_groups;
struct device_driver driver;
const struct usb_device_id *id_table;
unsigned int supports_autosuspend:1;
unsigned int generic_subclass:1;
};
like, look at her. all those function pointers? she's literally the blueprint. π«Ά
πΈ Members πΈ
nameβ the driver name, and bestie it needs to be unique among USB drivers. normally it should be the same as the module name, no cap.matchβ if you set it, it's used for better device/driver matching. β¨probeβ called to see if the driver is even willing to manage a particular device. if it is,probereturns zero and usesdev_set_drvdatato associate driver-specific data with the device. if it's like "no thanks babe," you return a negative errno value. rude but valid.disconnectβ called when the device is no longer accessible, usually because it has been (or is being) disconnected, or because the driver's module is being unloaded. π it's the sad goodbye function.suspendβ called when the device is going to be suspended by the system. π€resumeβ called when the device is being resumed by the system. β she's back!!choose_configurationβ if non-NULL, it's called instead of the defaultusb_choose_configuration. and the cute part? if this returns an error then we'll go on to call the normalusb_choose_configurationanyway. so it's like a soft override, not a hard takeover. π§dev_groupsβ attributes attached to the device that will be created once it is bound to the driver. πdriverβ the driver-model core driver structure. the foundation, the moment, the base layer.id_tableβ used withmatchto select a better matching driver at probe time. πsupports_autosuspendβ if set to0, the USB core will not allow autosuspend for devices bound to this driver. so like, flip it to zero and no napping allowed. πgeneric_subclassβ if set to1, the generic USB driver'sprobe,disconnect,resumeandsuspendfunctions will be called in addition to the driver's own, so this part of the setup does not need to be replicated. it's giving "don't do the work twice, queen" π
π Description π
USB device drivers must provide a name β that's literally the only non-negotiable. all the other driver fields are optional. so yes bestie, you can absolutely do the bare minimum here and she'll still compile. π
π SEE ALSO π
bestie the reading list is long, but we're getting through it together, fr fr:
- Kernel file
./include/linux/usb.h 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_class_driver(9)module_usb_driver(9)struct urb(9)usb_fill_control_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)
ok that's the whole page, no skipped sections, every single flag accounted for. go be a good USB device driver bestie, ily π«Άπ
this one comes straight out of ./include/linux and it's dated October 2026 β catch you in the next struct usb_device_driver(9) era, mwah ππ
π¦ 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