devm_gpiod_get(9)
πΈ 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_idof devicedevβ the slay case π -ENOENTif no GPIO has been assigned to the requested function π- or another
IS_ERRcode 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:
devm_gpiod_get_optional(9)devm_gpiod_get_index(9)devm_fwnode_gpiod_get_index(9)devm_gpiod_get_index_optional(9)devm_gpiod_get_array(9)devm_gpiod_get_array_optional(9)devm_gpiod_put(9)devm_gpiod_unhinge(9)devm_gpiod_put_array(9)devm_gpiochip_add_data_with_key(9)
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
- 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