usb_role_switch_register(9)
β¨ usb_role_switch_register(9) β the glow-up edition β¨
okay so bestie, welcome to the Kernel API Manual for usb_role_switch_register(9) β yes it's a whole vibe, and yes we're gonna understand it together π
πΈ NAME πΈ
usb_role_switch_register β literally just Register USB Role Switch, slay π
π SYNOPSIS π
struct usb_role_switch * usb_role_switch_register (struct device *parent
, const struct usb_role_switch_desc *desc );
π¦ ARGUMENTS π¦
parentβ the Parent device for the switch π«Ά like, this is its home, its main character origin storydescβ Description of the switch, i.e. all the deets about what this switch actually is
π DESCRIPTION π
okay so here's the tea: a USB Role Switch is a device that's capable of choosing the role for the USB connector. it's giving "which one of us is the host and which one of us is the device" energy, and it gets to decide π₯
now, the way that this plays out depends on your platform, and it's kind of a two-flavor situation:
- on platforms where the USB controller is dual-role capable, the controller driver will need to register the switch. yep, the controller driver is doing the registering in that case, periodt.
- on platforms where the USB host and USB device controllers behind the connector are separate, there will be a mux, and the driver for that mux will need to register the switch. so the mux driver is the one doing the registering there. no cap.
as for what you get back: this function Returns a handle to a new role switch or ERR_PTR π so like, always check it, bestie, don't just assume it worked.
also important: the content of desc is copied. it's not holding onto your pointer, it made its own lil copy, iconic behavior ngl π
π SEE ALSO π
Kernel file ./drivers/usb/roles/class.c and all its friends, fr fr:
usb_role_switch_set_role(9)usb_role_switch_get_role(9)usb_role_switch_get(9)fwnode_usb_role_switch_get(9)usb_role_switch_put(9)usb_role_switch_find_by_fwnode(9)usb_role_switch_unregister(9)usb_role_switch_set_drvdata(9)usb_role_switch_get_drvdata(9)
okay that's the whole page, you ate that π this beauty lives in ./drivers/usb/roles and the version/date on this one is October 2026 β go forth and register those switches, bestie, i'm obsessed π
π¦ 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