devm_gpiod_get(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 devm_gpiod_get β€” Kernel API Manual, but make it a group chat πŸ’…

okay bestie so we're in the devm_gpiod_get(9) page, a.k.a. the resource-managed version of gpiod_get(), and honestly? she's iconic. πŸŽ€


✨ NAME ✨

devm_gpiod_get β€” it's literally gpiod_get(), but resource-managed. the "devm" prefix is doing the whole "don't worry, I got you" thing. 🫢


🌈 SYNOPSIS 🌈

struct gpio_desc * devm_gpiod_get (struct device *dev , const char
*con_id , enum gpiod_flags flags );

three args, one gorgeous little descriptor pointer back. that's the vibe check. ⭐


πŸ’– ARGUMENTS πŸ’–

  • dev β€” the GPIO consumer. like, the device that's about to be obsessed with some GPIOs. main character energy. πŸ‘‘
  • con_id β€” the function within the GPIO consumer. which specific job is this GPIO doing? iykyk.
  • flags β€” optional GPIO initialization flags. optional!! but they're there if you want them. ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

so this is the managed gpiod_get. the way that the GPIO descriptors you get back from this function are automatically disposed on driver detach?? no cap, that's the whole point. 🧚

for the detailed tea on behavior and return values, go read gpiod_get. she has the full story, this one's just the managed remix. πŸ’œ


πŸ”₯ RETURN πŸ”₯

  • the GPIO descriptor corresponding to the function con_id of device dev β€” the slay case πŸŽ€
  • -ENOENT if no GPIO has been assigned to the requested function 😭
  • or another IS_ERR code if an error occurred while trying to acquire the GPIO πŸ’€
fr fr, check for errors. a pointer that's secretly an IS_ERR code is not the plot twist you want in your driver.

🌸 SEE ALSO 🌸

kernel file ./drivers/gpio/gpiolib-devres.c, plus the whole friend group:


sticker on the last page of the notebook: source ./drivers/gpio, dated October 2026, signed devm_gpiod_get(9). study hard bestie, you're gonna eat this exam up. πŸ’…πŸŒΈπŸ’–

πŸ“¦ where this page comes from