gpiod_get_array_optional(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– gpiod_get_array_optional πŸ’–

okay so real talk, this is a page from the Kernel API Manual β€” yes we're in kernel land, bestie, put your hair up β€” and it's about gpiod_get_array_optional, which grabs you multiple GPIOs from a multi-index GPIO function. icon behavior tbh πŸŽ€


✨ SYNOPSIS ✨

struct gpio_descs * gpiod_get_array_optional (struct device *dev , const
char *con_id , enum gpiod_flags flags );

like, look at her. she's giving "i return a whole struct of descriptors" energy and honestly? slay πŸ’…


🌸 ARGUMENTS 🌸

  • dev β€” the GPIO consumer. and get this: it can be NULL for system-global GPIOs. so if you've got no device, no problem, she still ate πŸ’–
  • con_id β€” the function within the GPIO consumer. basically which function you're asking about, iykyk.
  • flags β€” optional GPIO initialization flags. optional! she's flexible like that ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is literally the same as gpiod_get_array, no cap. same energy, same vibe, same everything β€” with exactly one iconic difference: when no GPIO was assigned to the requested function, she returns NULL instead of getting all dramatic about it. lowkey the most chill function in the whole gpio library ngl 🫢

that's it. that's the whole personality. NULL = "no GPIOs were assigned bestie, we're good, not an error" ✨


πŸ’€ RETURN πŸ’€

what you get back, in order of drama:

  • the GPIO descriptors corresponding to the function con_id of device dev β€” the main character outcome πŸ‘‘
  • NULL if no GPIO has been assigned to the requested function β€” the "it's fine, everything's fine" outcome 🌸
  • or another IS_ERR code if an error occurred while trying to acquire the GPIOs β€” the "okay something actually went wrong" outcome 😭
bestie please check that IS_ERR value, do not just rawdog the pointer fr fr

🌈 SEE ALSO 🌈

this list is long long, but we don't skip anything on this page, periodt. she's in the kernel file ./drivers/gpio/gpiolib.c:

like yeah. all of them. read them, memorise them, or at least know they exist πŸ’œ


🧚 and when you're done using these descriptors, gpiod_put_array(9) is right there β€” free your GPIOs, bestie, don't leak them, that's not the vibe πŸ™ˆ

okay that's the whole page!! πŸ“ this little gem lives in ./drivers/gpio, and the page itself is dated October 2026 β€” so yeah, she's from the future and still slaying. bye bestie, go grab your GPIO arrays πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from