devm_gpiod_...ray_optional(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… devm_gpiod_...ray_optional β€” straight from the Kernel API Manual, bestie

okay so before we even get into it: yes the title is literally devm_gpiod_...ray_optional(9) with the dots and everything, that's not me being lazy, that's the actual page name, the middle got squished like a text message from someone typing too fast 😭 anyway. intent is giving "kernel dev who wants ALL the GPIOs, but responsibly." let's get into it ✨


✨ NAME ✨

devm_gpiod_get_array_optional β€” it's the resource-managed glow-up of gpiod_get_array_optional(). same energy, but the cleanup is handled for you 🫢


πŸŽ€ SYNOPSIS πŸŽ€

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

bestie look at that signature. struct gpio_descs * coming back at you, three args going in. iconic behavior fr fr πŸ’…


🌸 ARGUMENTS 🌸

  • dev β€” the GPIO consumer. like, the device that's about to be obsessed with some GPIOs πŸ‘‘
  • con_id β€” the function within the GPIO consumer. the name-tag that says which function we're talking about ✨
  • flags β€” optional GPIO initialization flags. optional optional, they're right there in the name πŸŽ€

πŸ¦‹ DESCRIPTION πŸ¦‹

so this is the managed version of gpiod_get_array_optional, no cap. the GPIO descriptors you get back from this function? they get automatically disposed on driver detach. you don't have to clean up after yourself, the kernel does it for you. main character energy honestly 🫢

if you want the full tea on how it actually behaves and what it returns, go read gpiod_get_array_optional β€” this one is literally pointing you there πŸ’–


πŸ”₯ RETURN πŸ”₯

here's the vibe check on what you get back:

  • the GPIO descriptors corresponding to the function con_id of device dev β€” slay, you got your array 🌈
  • NULL if no GPIO has been assigned to the requested function β€” no GPIOs, no problem, no drama πŸ™ˆ
  • or another IS_ERR code if an error happened while trying to acquire the GPIOs β€” read it, don't ignore it, that's the whole point πŸ’€

⭐ SEE ALSO ⭐

go down the rabbit hole, i promise it's worth it 🧚


πŸ’œ friendly reminder from your favorite kernel bestie: this whole page lives at ./drivers/gpio, and it's dated October 2026 β€” so when you cite it, cite it cute. oh and the page name is still devm_gpiod_...ray_optional(9), dots and all, i don't make the rules, i just vibe with them πŸŽ€

that's the whole page, you ate that, periodt πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from