devm_gpiod_get()¶
Purpose¶
Gets a GPIO descriptor by function name from firmware data such as Device Tree.
Header¶
Prototype¶
Parameters¶
dev: device used for lookup and managed cleanup.con_id: GPIO function name, mapped to<con_id>-gpios.flags: initial direction/value flags.
Return Value¶
- Success: returns a GPIO descriptor.
- Failure: returns an error pointer; check with
IS_ERR().
Minimal Example¶
priv->led = devm_gpiod_get(dev, "led", GPIOD_OUT_LOW);
if (IS_ERR(priv->led))
return PTR_ERR(priv->led);
Common Pitfalls¶
"led"maps to theled-gpiosDevice Tree property.- Do not hardcode GPIO numbers in portable drivers.
- Use descriptor-based GPIO APIs such as
gpiod_set_value().