STRUCT PINCTRL_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 struct pinctrl_ops β€” global pin control ops πŸ’…

okay bestie, welcome to the Kernel API Manual (the 9 section, kernel internals only, we're fancy here) and today's main character is struct pinctrl_ops. This is the global pin control operations struct β€” the one that pin controller drivers are supposed to implement. Yes, you, the driver author, you're the one filling in these function pointers. No cap. ✨


πŸŽ€ NAME

struct pinctrl_ops β€” global pin control operations, to be implemented by pin controller drivers.


πŸ¦‹ SYNOPSIS

struct pinctrl_ops {
    int (*get_groups_count) (struct pinctrl_dev *pctldev);
    const char *(*get_group_name) (struct pinctrl_dev *pctldev, unsigned int selector);
    int (*get_group_pins) (struct pinctrl_dev *pctldev, unsigned int selector, const unsigned int **pins, unsigned int *num_pins);
    void (*pin_dbg_show) (struct pinctrl_dev *pctldev, struct seq_file *s, unsigned int offset);
    int (*dt_node_to_map) (struct pinctrl_dev *pctldev, struct device_node *np_config, struct pinctrl_map **map, unsigned int *num_maps);
    void (*dt_free_map) (struct pinctrl_dev *pctldev, struct pinctrl_map *map, unsigned int num_maps);
 };

look at that function pointer buffet 😭 every single one of these is a slot you can fill in, and the kernel will politely call them for you. iconic.


πŸ’– Members

okay so here's the breakdown of every hook, one by one, no skipping, we do not leave anyone on read 🫢

  • get_groups_count β€” returns the count of total number of groups registered. that's it, that's the whole vibe. a number, pointing at how many groups you got. πŸ“
  • get_group_name β€” return the group name of the pin group. literally just hand back the name, bestie, the kernel's asking nicely. ✨
  • get_group_pins β€” return an array of pins corresponding to a certain group selector pins, and the size of the array in num_pins. so: the pins themselves, plus how many there are. two-for-one deal, we love efficiency πŸ’…
  • pin_dbg_show β€” optional debugfs display hook that will provide per-device info for a certain pin in debugfs. optional, queen β€” if you don't wanna, you don't gotta. but if you do, debugfs gets a little per-device info dump for the pin at offset. πŸ”₯
  • dt_node_to_map β€” parse a device tree "pin configuration node", and create mapping table entries for it. These are returned through the map and num_maps output parameters. This function is optional, and may be omitted for pinctrl drivers that do not support device tree. so if you're a non-DT driver, feel free to ghost this one πŸ™ˆ (but if you do support device tree, this is the whole assignment, fr fr)
  • dt_free_map β€” free mapping table entries created via dt_node_to_map. The top-level map pointer must be freed, along with any dynamically allocated members of the mapping table entries themselves. This function is optional, and may be omitted for pinctrl drivers that do not support device tree. ⚠️ note the must β€” if you allocated, you free, and you free the top-level pointer and the dynamically allocated members inside each entry. no leaks on my watch, periodt. πŸ’€

🌈 SEE ALSO

Kernel file ./include/linux/pinctrl/pinctrl.h, plus these absolute legends:

  • struct pingroup(9)
  • struct pinctrl_pin_desc(9)
  • struct pinctrl_gpio_range(9)
  • struct pinctrl_desc(9)
  • struct pinfunction(9)

go read them, they're all connected, iykyk 🧚


✨ reminder from your group chat: every function pointer in here is one you implement, not one you call. and the optional ones are genuinely optional β€” but dt_free_map has a must in it and musts are not a vibe check you can fail. πŸ‘‘

that's the whole page babes πŸ’œ source lives at ./include/linux/pinctrl, stamping it October 2026, and the header says struct pinctrl_ops(9) from the Kernel API Manual β€” so go forth, implement your pinctrl_ops, and slay πŸ’…πŸŽ€

πŸ“¦ where this page comes from