Linux GPIOs handling

谁说胖子不能爱 提交于 2019-12-14 03:14:04

问题


I have some question about Linux kernel and GPIOs. I know that in Linux everything is file so when I do something like

echo 30 > /sys/class/gpio/export

and

echo 1 > /sys/class/gpio/gpio30/value

what really happens? I mean how does sysfs handle that? Does it call system calls implemented in gpiolib?


回答1:


The gpiolib registers the value attribute in this way:

 static const DEVICE_ATTR(value, 0644, gpio_value_show, gpio_value_store);

It creates a device attribute named value, with permission 644; on read it calls gpio_value_show, on write it calls gpio_value_store

What sysfs does, is to redirect read and write to the correspondent function of a sysfs attribute.



来源:https://stackoverflow.com/questions/19548449/linux-gpios-handling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!