我正在尝试通过可加载内核模块执行一些 GPIO 操作。为此,我尝试使用 open() 和 write() 系统调用访问文件“/sys/class/leds/led1/brightness”,因此我包含了以下头文件。
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
但是在交叉编译项目时,我收到以下警告和错误。
guru@guru-G40-80:~/OFC/lnx/projects/V4/source_codes/git/Device-Driver/char_dev_gsm$ make
pwd : /home/guru/OFC/lnx/projects/V4/source_codes/git/Device-Driver/char_dev_gsm
make -C /home/guru/OFC/lnx/projects/V4/source_codes/git/linux-at91/ M=/home/guru/OFC/lnx/projects/V4/source_codes/git/Device-Driver/char_dev_gsm modules
make[1]: Entering directory '/home/guru/OFC/lnx/projects/V4/source_codes/git/linux-at91'
WARNING: Symbol version dump ./Module.symvers
is missing; modules will have no dependencies and modversions.
pwd : /home/guru/OFC/lnx/projects/V4/source_codes/git/Device-Driver/char_dev_gsm
CC [M] /home/guru/OFC/lnx/projects/V4/source_codes/git/Device-Driver/char_dev_gsm/src/pwr_hndl/pwr_hndl.o
/home/guru/OFC/lnx/projects/V4/source_codes/git/Device-Driver/char_dev_gsm/src/pwr_hndl/pwr_hndl.c:5:10: fatal error: sys/stat.h: No such file or directory
#include <sys/stat.h>
^~~~~~~~~~~~
compilation terminated.
这里是 git-hub 的链接:https://github.com/guruprasad-92/Device-Driver.git 你能帮我解决这个问题吗?
最佳答案
抱歉,您做错了 - 不要尝试从内核访问 GPIO 用户空间接口(interface)。相反,请使用内核内 GPIO 接口(interface)。
更多信息请点击:https://lwn.net/Articles/532714/
关于c - 如何在设备驱动程序编程中添加用户空间头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58898607/