devm_fwnode_...get_optional(9)
π devm_fwnode_gpiod_get_optional β obtain an optional GPIO from firmware node π
okay so bestie, welcome to the devm_fwnode_...get_optional(9) page from the Kernel API Manual β¨ (yes the title is a whole abbreviation situation, the full name is devm_fwnode_gpiod_get_optional, and likeβ¦ it's a mouthful but we move π
).
β¨ SYNOPSIS β¨
struct gpio_desc * devm_fwnode_gpiod_get_optional (struct device *dev ,
struct fwnode_handle *fwnode , const char *con_id , enum gpiod_flags
flags , const char *label );
like just look at that signature, she's got five arguments and she's serving π
π«Ά ARGUMENTS π«Ά
devβ the GPIO consumer. the main character, basically πfwnodeβ handle of the firmware node π¦con_idβ the function within the GPIO consumer πΈflagsβ GPIO initialization flags, the little settings gremlins βοΈβ¨labelβ the label you attach to the requested GPIO π
π DESCRIPTION π
so this function is lowkey made for drivers that get their configuration from opaque firmware π β like, the driver doesn't know the details, it just asks the firmware and the firmware knows. iykyk.
and here's the iconic part: the GPIO descriptors you get back from this function are automatically disposed on driver detach π§β¨ like bestie it cleans up after itself, no manual freeing, we love a self-sufficient queen π
π₯ RETURN π₯
so what do you get back? it's giving multiple possibilities, keep up:
- the GPIO descriptor corresponding to the optional function
con_idof devicedevπ NULLif 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, don't just assume it worked π
π¦ SEE ALSO π¦
- Kernel file
./include/linux/gpio/consumer.h struct gpio_descs(9)enum gpiod_flags(9)
and that's the whole vibe bestie, go forth and get those optional GPIOs ππ
sign-off szn: this lil masterpiece comes from the ./include/linux/gpio source, dated October 2026, and it's filed under devm_fwnode_...get_optional(9) β periodt π
β¨π
π¦ 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