Linux 2.6 字符设备驱动程序分配和释放设备编号
2010-08-25 10:42
176 查看
(1) 静态分配主设备号:register_chrdev_region(dev_t from, unsigned count, const char *name),其中from包含了主、次设备号两个部分。需要静态分配的主设备号必须包含在from中,from的次设备号通常为0。使用该函数前,需要首先
查看Documentation/devices.txt
文件哪些主设备号没有被分配。
(2) 动态分配主设备号:alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name),其中dev是出口参数,保存了动态分配的主设备号。该函数是在insmod之后被调用的,也就是说我们不能事先创建设备文件(因为此时主设备号不知道),需要动态
查看/proc/devices
文件,可利用awk等工具。
(3) register_chrdev_region()和alloc_chrdev_region()都是调用了static struct char_device_struct * __register_chrdev_region
(unsigned int major, unsigned int baseminor, int minorct, const char *name)函数。
(4)
释放设备编号:无论是静态分配设备编号还是动态分配设备编号,释放调用的函数都是
void unregister_chrdev_region(dev_t from, unsigned count)
。
查看Documentation/devices.txt
文件哪些主设备号没有被分配。
(2) 动态分配主设备号:alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name),其中dev是出口参数,保存了动态分配的主设备号。该函数是在insmod之后被调用的,也就是说我们不能事先创建设备文件(因为此时主设备号不知道),需要动态
查看/proc/devices
文件,可利用awk等工具。
(3) register_chrdev_region()和alloc_chrdev_region()都是调用了static struct char_device_struct * __register_chrdev_region
(unsigned int major, unsigned int baseminor, int minorct, const char *name)函数。
(4)
释放设备编号:无论是静态分配设备编号还是动态分配设备编号,释放调用的函数都是
void unregister_chrdev_region(dev_t from, unsigned count)
。
相关文章推荐
- Linux 2.6 字符设备驱动程序
- Linux 2.6 字符设备驱动程序
- Linux 2.6中的字符设备驱动程序结构
- Linux 2.6 字符设备驱动程序
- Linux 2.6 字符设备驱动程序
- Linux 2.6 字符设备驱动程序
- Linux 2.6 字符设备驱动程序
- linux2.6 字符设备驱动程序
- 字符设备分配和释放设备编号register_chrdev_region()、alloc_chrdev_region() 和 register_chrdev()
- Linux 2.6 字符设备驱动程序
- Linux 2.6字符设备驱动程序样例
- Linux 2.6 字符设备驱动程序
- linux字符设备驱动程序(一)----------分配设备号并注册设备
- Linux 2.6 字符设备驱动程序
- Linux 2.6 字符设备驱动程序
- 【转】+【改】Linux 2.6字符设备驱动程序样例
- 基于mini6410的linux驱动学习总结(四 设计字符设备驱动程序)
- Linux字符设备驱动程序的编写框架
- linux简单的字符设备驱动程序
- Linux设备驱动程序第三版学习(2)-字符设备驱动程序源码分析(续)