STRUCT CI_ROLE_DRIVER(9)
π struct ci_role_driver β host/gadget role driver π
okay so this is from the kernel API manual, struct ci_role_driver(9), and it is literally the little switchboard that tells the ChipIdea USB controller whether it's being a host today or a gadget today π«Ά think of it as the role-assignment sheet but make it C.
β¨ SYNOPSIS β¨
bestie. look at this struct. it's giving "five function pointers and a name, and that's the whole personality":
struct ci_role_driver {
int (*start)(struct ci_hdrc *);
void (*stop)(struct ci_hdrc *);
void (*suspend)(struct ci_hdrc *ci);
void (*resume)(struct ci_hdrc *ci, bool power_lost);
irqreturn_t (*irq)(struct ci_hdrc *);
const char *name;
};
no cap, that's the entire thing. every role (host or gadget) fills in these slots and the core calls them at the right moments. iconic behavior tbh π
πΈ Members πΈ
startβ the "we're so on" callback π it's anint (*)(struct ci_hdrc *)and it starts this role. the moment the controller commits to being host or gadget, this runs.stopβ the "ok we're done here" callback π it's avoid (*)(struct ci_hdrc *)and it stops this role. the reverse ofstart, as you might have guessed, you genius.suspendβ the system suspend handler for this role π΄ signature isvoid (*)(struct ci_hdrc *ci)β note the parameter is literally namedcihere, keep it, it's canon.resumeβ the system resume handler for this role π and hear me out, its signature isvoid (*)(struct ci_hdrc *ci, bool power_lost)β that extrabool power_lostis fr fr carrying information about whether the power went bye-bye during the sleep. don't drop it.irqβ the irq handler for this role β‘ returnsirqreturn_t, takes astruct ci_hdrc *, and gets called when interrupts happen. this is the main character of the hot path ngl.nameβ the role name string π·οΈ and the original is very specific about what it looks like:(host/gadget). it's aconst char *, so it's a pointer to chars that nobody's allowed to touch. rude but valid.
π¦ SEE ALSO π¦
the kernel file ./drivers/usb/chipidea/ci.h and its whole friend group β go say hi, they all hang out together:
struct ci_hw_ep(9)struct hw_bank(9)struct ci_hdrc(9)hw_read_id_reg(9)hw_write_id_reg(9)hw_read(9)hw_write(9)hw_test_and_clear(9)hw_test_and_write(9)ci_otg_is_fsm_mode(9)
like, lowkey a whole squad π
π friendly reminder that this page lives in ./drivers/usb/chipidea β that's the directory, iykyk, go look there if you want the real source. π
ok that's the whole page, mwah π this little manual page shipped October 2026 out of the ./drivers/usb/chipidea source tree, and it signs off as struct ci_role_driver(9) β catch you in the next one, bestie! πβ¨π
π¦ 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