STRUCT USB_INTERFACE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

struct usb_interface β€” bestie, this is literally the thing USB device drivers talk to πŸ’…

✨ SYNOPSIS ✨

struct usb_interface {
    struct usb_host_interface *altsetting;
    struct usb_host_interface *cur_altsetting;
    unsigned num_altsetting;
    struct usb_interface_assoc_descriptor *intf_assoc;
    int minor;
    enum usb_interface_condition condition;
    unsigned sysfs_files_created:1;
    unsigned ep_devs_created:1;
    unsigned unregistering:1;
    unsigned needs_remote_wakeup:1;
    unsigned needs_altsetting0:1;
    unsigned needs_binding:1;
    unsigned resetting_device:1;
    unsigned authorized:1;
    enum usb_wireless_status wireless_status;
    struct work_struct wireless_status_work;
    struct device dev;
    struct device *usb_dev;
    struct work_struct reset_ws;
 };

πŸŽ€ Members πŸŽ€

okay so here's the whole cast, no skips, iykyk πŸ‘‘

  • altsetting β€” an array of interface structures, one for every alternate setting that could get selected. each one comes with its own set of endpoint configurations. and bestie? they will be in no particular order 😭 so don't come for the indices.
  • cur_altsetting β€” the current altsetting. the one on main character duty rn ✨
  • num_altsetting β€” how many altsettings are defined.
  • intf_assoc β€” interface association descriptor 🫢
  • minor β€” the minor number assigned to this interface if this interface is bound to a driver that uses the USB major number. if this interface doesn't use the USB major, this field should be unused. the driver should set this value in the driver's probe function, after it's been assigned a minor number from the USB core by calling usb_register_dev.
  • condition β€” the binding state of the interface: not bound, binding (in probe), bound to a driver, or unbinding (in disconnect). it's giving relationship status πŸ’€
  • sysfs_files_created β€” sysfs attributes exist.
  • ep_devs_created β€” endpoint child pseudo-devices exist.
  • unregistering β€” flag set when the interface is being unregistered.
  • needs_remote_wakeup β€” flag set when the driver requires remote-wakeup capability during autosuspend.
  • needs_altsetting0 β€” flag set when a set-interface request for altsetting 0 has been deferred.
  • needs_binding β€” flag set when the driver should be re-probed or unbound following a reset or suspend operation it doesn't support. the way that driver just can't handle it πŸ™ˆ
  • resetting_device β€” USB core reset the device, so use alt setting 0 as current; needs bandwidth alloc after reset.
  • authorized β€” this allows you to (de)authorize individual interfaces instead of a whole device β€” in contrast to the device authorization. lowkey powerful πŸ’…
  • wireless_status β€” if the USB device uses a receiver/emitter combo, whether the emitter is connected.
  • wireless_status_work β€” used for scheduling wireless status changes from atomic context.
  • dev β€” the driver model's view of this device.
  • usb_dev β€” if an interface is bound to the USB major, this will point to the sysfs representation for that device.
  • reset_ws β€” used for scheduling resets from atomic context.

πŸ”₯ Description πŸ”₯

USB device drivers attach to interfaces on a physical device. each interface encapsulates a single high level function β€” like feeding an audio stream to a speaker, or reporting a change in a volume control 🎧 each one is like its own lil personality fr fr. many USB devices only have one interface, so slay for them. the protocol used to talk to an interface's endpoints can be defined in a usb "class" specification, or by a product's vendor. and note: the (default) control endpoint is part of every interface, but it is never listed among the interface's descriptors πŸ‘€ don't go looking for it.

the driver that's bound to the interface can use standard driver model calls such as dev_get_drvdata on the dev member of this structure. super chill.

each interface may have alternate settings ✨ the initial configuration of a device sets altsetting 0, but the device driver can change that setting using usb_set_interface. alternate settings are often used to control the use of periodic endpoints β€” like by having different endpoints use different amounts of reserved USB bandwidth. all standards-conformant USB devices that use isochronous endpoints will use them in non-default settings. periodt.

the USB specification says alternate setting numbers must run from 0 to one less than the total number of alternate settings. but some devices manage to mess this up 😭 and the structures aren't necessarily stored in numerical order anyhow. so use usb_altnum_to_altsetting to look up an alternate setting in the altsetting array based on its number. trust the lookup, not the vibes.

🌈 SEE ALSO 🌈

Kernel file ./include/linux/usb.h β€” struct usb_host_endpoint(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_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)


and that's the whole page bestie 🫢 this one lives over in ./include/linux, dated October 2026 β€” go off, kernel API manual πŸ‘‘πŸ’–

πŸ“¦ where this page comes from