devm_fwnode_gpiod_get_index(9)
π devm_fwnode_gpiod_get_index(9) β the Kernel API Manual, bestie edition π
okay so we're in the Kernel API Manual today and this little icon is genuinely so useful β it's the one that grabs a GPIO descriptor off a specific firmware node and then, and this is the β¨iconicβ¨ part, cleans up after itself. devm = "i gotchu, i'll handle the cleanup." obsessed. π«Ά
β¨ NAME β¨
devm_fwnode_gpiod_get_index β get a GPIO descriptor from a given node π
πΈ SYNOPSIS πΈ
struct gpio_desc * devm_fwnode_gpiod_get_index (struct device *dev ,
struct fwnode_handle *fwnode , const char *con_id , int index , enum
gpiod_flags flags , const char *label );
like, six whole arguments, she's high maintenance but worth it π
π¦ ARGUMENTS π¦
devβ the GPIO consumer. the device that's gonna be using the GPIO, basically the main character here πfwnodeβ the firmware node that contains the GPIO reference. this is where we're looking it up, iykyk πcon_idβ the function within the GPIO consumer. like, which job is this pin doing for you?indexβ the index of the GPIO to obtain in the consumer. when one function has multiple pins, this is your lil "which one" number π’flagsβ the GPIO initialization flags. all the vibes/settings for setup β¨labelβ the label to attach to the requested GPIO. a little name tag so everyone knows who she belongs to π
π DESCRIPTION π
okay here's the whole point, the reason we're all here: GPIO descriptors returned from this function are automatically disposed on driver detach. no cap. you don't have to remember to free them, no manual cleanup era, the devm machinery handles it. it's giving responsible adult energy and honestly? we stan ππ«Ά
π₯ RETURN π₯
so what do you get back, bestie? it's one of these three situations:
- The GPIO descriptor corresponding to the function
con_idof devicedevβ slay, you got your pin π -ENOENTif no GPIO has been assigned to the requested function β basically "girl, there's nothing there" π- or another
IS_ERRcode if an error occurred while trying to acquire the GPIO β something went sideways, check that code π
fr fr: always check it, don't just rawdog the return value. IS_ERR is right there, use her.
π§ SEE ALSO π§
Kernel file ./drivers/gpio/gpiolib-devres.c β the source, go read her, she's gorgeous π
then the whole friend group:
devm_gpiod_get(9)devm_gpiod_get_optional(9)devm_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)
and that's the page!! π this one lives in ./drivers/gpio, dated October 2026, and she's filed under devm_fwnode_gpiod_get_index(9) β mwah, go get those pins bestie ππ
π¦ 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