STRUCT GPIO_DESC(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct gpio_desc(9) β€” like, the actual Kernel API Manual, bestie ✨

okay so we're in the Kernel API Manual today and the main character is struct gpio_desc β€” the opaque descriptor for a GPIO πŸ‘‘ no cap, that's the whole vibe.


πŸŽ€ NAME πŸŽ€

struct gpio_desc β€” an opaque descriptor for a GPIO. that's it, that's the tweet πŸ¦‹


✨ SYNOPSIS ✨

here's the whole glow-up, copy it exactly, don't touch a single space or the compiler WILL clock you πŸ’€

struct gpio_desc {
    struct gpio_device      *gdev;
    unsigned long           flags;
  #define GPIOD_FLAG_REQUESTED            0  ;
  #define GPIOD_FLAG_IS_OUT               1  ;
  #define GPIOD_FLAG_EXPORT               2  ;
  #define GPIOD_FLAG_SYSFS                3  ;
  #define GPIOD_FLAG_ACTIVE_LOW           6  ;
  #define GPIOD_FLAG_OPEN_DRAIN           7  ;
  #define GPIOD_FLAG_OPEN_SOURCE          8  ;
  #define GPIOD_FLAG_USED_AS_IRQ          9  ;
  #define GPIOD_FLAG_IRQ_IS_ENABLED       10 ;
  #define GPIOD_FLAG_IS_HOGGED            11 ;
  #define GPIOD_FLAG_TRANSITORY           12 ;
  #define GPIOD_FLAG_PULL_UP              13 ;
  #define GPIOD_FLAG_PULL_DOWN            14 ;
  #define GPIOD_FLAG_BIAS_DISABLE         15 ;
  #define GPIOD_FLAG_EDGE_RISING          16 ;
  #define GPIOD_FLAG_EDGE_FALLING         17 ;
  #define GPIOD_FLAG_EVENT_CLOCK_REALTIME 18 ;
  #define GPIOD_FLAG_EVENT_CLOCK_HTE      19 ;
  #define GPIOD_FLAG_SHARED               20 ;
  #define GPIOD_FLAG_SHARED_PROXY         21 ;
    struct gpio_desc_label *label;
    const char              *name;
  #ifdef CONFIG_OF_DYNAMIC;
    struct device_node      *hog;
  #endif;
  #ifdef CONFIG_GPIO_CDEV;
    unsigned int            debounce_period_us;
  #endif;
 };

🫢 Members 🫢

the whole squad, one by one, iykyk:

  • gdev β€” pointer to the parent GPIO device. the mothership πŸ›Έ
  • flags β€” binary descriptor flags. yes, binary, as in bits go brrr πŸ”₯
  • label β€” name of the consumer. who's using this line, fr fr
  • name β€” line name. the line's own little name tag 🏷️
  • hog β€” pointer to the device node that hogs this line (if any). greedy little thing, love that for it πŸ™ˆ
  • debounce_period_us β€” debounce period in microseconds. tiny tiny time, iconic ⏱️

πŸ’– Description πŸ’–

okay so the lore: these are obtained using gpiod_get and are preferable to the old integer-based handles. we don't do integer handles anymore bestie, that's so last season πŸ’…

and here's the part that eats: contrary to integers, a pointer to a struct gpio_desc is guaranteed to be valid until the GPIO is released. so you can hold onto it like a best friend promise 🫢 lowkey the whole point.


🌈 SEE ALSO 🌈

go read these next, bestie, i'm obsessed:

  • Kernel file ./drivers/gpio/gpiolib.h
  • struct gpio_device(9)
  • struct gpio_array(9)

ngl the descriptor is opaque β€” so like, admire it from the outside, don't go poking at its internals like it's your business. 🧚

and that's the page, periodt πŸŽ€ this cutie lives in ./drivers/gpio and it's dated October 2026 β€” struct gpio_desc(9), slay, bye πŸ’œ

πŸ“¦ where this page comes from