首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在设备驱动程序中添加用户空间标头?

如何在设备驱动程序中添加用户空间标头?
EN

Stack Overflow用户
提问于 2019-11-17 16:01:33
回答 1查看 116关注 0票数 0

我正在尝试通过一个可加载的内核模块执行一些GPIO操作。为此,我尝试使用open()和write()系统调用来访问文件“/sys/class/led1/led1/brightness”,因此我包含了以下头文件。

代码语言:javascript
复制
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

但是在交叉编译项目时,我得到了以下警告和错误。

代码语言:javascript
复制
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的链接,你能帮我吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-17 20:48:18

抱歉,您这样做是错误的-不要试图从内核访问GPIO用户空间接口。相反,请使用内核中的GPIO接口。

有关更多信息,请单击此处:https://lwn.net/Articles/532714/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58898607

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档