STRUCT PINCTRL_OPS(9)
πΈ 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 selectorpins, and the size of the array innum_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 atoffset. π₯dt_node_to_mapβ parse a device tree"pin configuration node", and create mapping table entries for it. These are returned through themapandnum_mapsoutput 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 viadt_node_to_map. The top-levelmappointer 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
- 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