STRUCT USB_ROLE_SWITCH_DESC(9)
β¨ 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β iftrue, userspace may change the role throughsysfsπ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: ifusb2_port,usb3_portandudcare included in the description, the reference count for them should be incremented by the caller ofusb_role_switch_registerbefore 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
- 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