STRUCT CI_ROLE_DRIVER(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 an int (*)(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 a void (*)(struct ci_hdrc *) and it stops this role. the reverse of start, as you might have guessed, you genius.
  • suspend β€” the system suspend handler for this role 😴 signature is void (*)(struct ci_hdrc *ci) β€” note the parameter is literally named ci here, keep it, it's canon.
  • resume β€” the system resume handler for this role πŸŒ… and hear me out, its signature is void (*)(struct ci_hdrc *ci, bool power_lost) β€” that extra bool power_lost is 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 ⚑ returns irqreturn_t, takes a struct 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 a const 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:

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