加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux-kernel – gpiod_ * vs Linux内核中的gpio_ *方法

发布时间:2020-12-14 00:32:14 所属栏目:Linux 来源:网络整理
导读:Linux设备驱动程序编程中的哪个GPIO API更受欢迎,在什么条件下:gpio_set_value()或gpiod_set_value()? 一个采用GPIO desc作为对象,而另一个采用从设备树解析的GPIO. 解决方法 对于所有新驱动程序,建议使用gpiod_ * API.旧的gpio_ * API现在被视为已弃用.
Linux设备驱动程序编程中的哪个GPIO API更受欢迎,在什么条件下:gpio_set_value()或gpiod_set_value()?

一个采用GPIO desc作为对象,而另一个采用从设备树解析的GPIO.

解决方法

对于所有新驱动程序,建议使用gpiod_ * API.旧的gpio_ * API现在被视为已弃用.

从this提交:

gpiolib: export descriptor-based GPIO interface

This patch exports the gpiod_* family of API functions,a safer
alternative to the legacy GPIO interface. Differences between the gpiod
and legacy gpio APIs are:

  • gpio works with integers,whereas gpiod operates on opaque handlers
    which cannot be forged or used before proper acquisition
  • gpiod get/set functions are aware of the active low state of a GPIO
  • gpio consumers should now include <linux/gpio/consumer.h> to access
    the new interface,whereas chips drivers will use
    <linux/gpio/driver.h>

The legacy gpio API is now built as inline functions on top of gpiod.

有关新gpiod API的详细信息,请参阅下一链接:

> [LWN article] GPIO in the kernel: future directions
> [Kernel documentation] GPIO Descriptor Consumer Interface

(以及this提交时添加的其余gpiod内核文档)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读