【问题标题】:Creating a device file: Linux device driver创建设备文件:Linux设备驱动
【发布时间】:2012-05-26 00:59:03
【问题描述】:

在不使用mknodMAKEDEV 的情况下,当我不知道次要编号和主要编号(即使用动态注册)时如何创建设备文件。

【问题讨论】:

标签: linux kernel driver device


【解决方案1】:

假设您想在插入时为 char 设备动态分配主设备号,请使用:

int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name);

来自 Linux 设备驱动程序第 3 版。谷歌它,你可以免费获得整本书以及大量用于搞乱驱动程序的优秀源代码。

【讨论】:

    【解决方案2】:

    此外,LDD3 中提供的代码现在已过时。所以,使用这个 github repo 下载 LDD3 的示例代码:https://github.com/martinezjavier/ldd3

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      相关资源
      最近更新 更多