STRUCT USB_ROLE_SWITCH_DESC(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

struct usb_role_switch_desc β€” the USB Role Switch Descriptor πŸ’…

okay so basically this is a kernel API manual page, bestie β€” it's from the struct usb_role_switch_desc(9) family, and it's literally just describing one lil struct and every field inside it. no cap, that's the whole vibe. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole thing, character for character, so you can copy it and slay:

struct usb_role_switch_desc {
    struct fwnode_handle *fwnode;
    struct device *usb2_port;
    struct device *usb3_port;
    struct device *udc;
    usb_role_switch_set_t set;
    usb_role_switch_get_t get;
    bool allow_userspace_control;
    void *driver_data;
    const char *name;
 };

she's giving "small struct, big responsibilities" honestly 😭


🌸 Members 🌸

okay now the main character energy β€” every single field, one by one, no skips:

  • fwnode β€” the device node that gets associated with the role switch πŸ”—
  • usb2_port β€” optional reference to the host controller port device (USB2) πŸ“
  • usb3_port β€” optional reference to the host controller port device (USB3) πŸ“
  • udc β€” optional reference to the peripheral controller device 🌈
  • set β€” the callback for setting the role πŸ”₯
  • get β€” the callback for getting the role (optional, king) πŸ‘‘
  • allow_userspace_control β€” if true, userspace may change the role through sysfs πŸ‘€
  • driver_data β€” private data pointer, mind your business 🫢
  • name β€” name for the switch (optional) πŸŽ€

πŸ’œ Description πŸ’œ

so like, the way this works: usb2_port and usb3_port will point to the USB host port, and udc points to the USB device controller behind the USB connector with the role switch. that's the picture, periodt. ✨

⚠️ okay this is the important bit, bestie, don't skip it: if usb2_port, usb3_port and udc are included in the description, the reference count for them should be incremented by the caller of usb_role_switch_register before registering the switch. the way that's not optional… yeah. do it in that order fr fr 🫑

🧚 SEE ALSO 🧚

  • kernel file ./include/linux/usb/role.h β€” go read it, iykyk πŸ“–

and that's a wrap, bestie!! 🌟 this page lives in ./include/linux/usb, dated October 2026, and it's literally the struct usb_role_switch_desc(9) page β€” iconic, ate, no crumbs. see you in the group chat πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from