答:gpiod_get_index()本质上和gpio_request()是一个功能,是申请gpio的,只是它是从device tree去查找, 因此看到第二个参数”con_id”是字符串类型,也就是gpio的名字。 例如在显示驱动看到的去查找名字为”enable”的gpio panel-simple.c: panel->enable_gpio = devm_gpiod_get_optional(dev,"enable",0); ...
devm_fwnode_gpiod_get 函数首先根据传入的 fwnode、con_id 和index 参数,在设备树或 ACPI 表中查找对应的 GPIO。找到后,它会调用底层的 GPIO 子系统函数来获取 GPIO 描述符(gpio_desc)。然后,它会使用设备资源管理函数(devres_alloc 和devres_add)来管理这个 GPIO 描述符,确保在设备驱动程序卸载时自动释放资源...
priv->ulpi_reset = devm_gpiod_get_optional(dev->parent, "reset", GPIOD_ACTIVE_LOW); /* property is optional, don't return error! */ if (priv->ulpi_reset) { /* Toggle ulpi to reset the phy. */ rc = dm_gpio_set_value(priv->ulpi_reset, 1); ...
*devm_fwnode_get_index_gpiod_from_child(struct device *dev, return desc; } -EXPORT_SYMBOL(devm_fwnode_get_index_gpiod_from_child); +EXPORT_SYMBOL(devm_fwnode_gpiod_get_index); /** * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional() diff --git a/include/l...
可以看到devm_gpiod_get_optional只是对gpiod_get_index的包装而已,并且index为0。index参数后面会提。 函数参数: structgpio_desc *__must_check devm_gpiod_get_index(structdevice *dev,constchar*con_id, unsignedintidx,enumgpiod_flags flags); ...
[gpio]devm_gpiod_get_optional用法 2018-08-16 09:54 −... aaronGao 0 12457 optional 2019-12-23 00:08 −optional - 在实际开发中,我们经常会遇到无效值的情况,例如函数并不是总能返回有效值,很多函数正确执行了,但结果却不是合理的值,如果用数学语言开解释的话,就是返回值位于函数解空间之外。
可以看到devm_gpiod_get_optional只是对gpiod_get_index的包装而已,并且index为0。index参数后面会提。 函数参数: structgpio_desc *__must_check devm_gpiod_get_index(structdevice *dev,constchar*con_id, unsignedintidx,enumgpiod_flags flags); ...