加载驱动模块时Device or resource busy的解决方法

来源:互联网 发布:mac mini 音频输出 编辑:程序博客网 时间:2024/05/01 15:09

加载驱动模块时Device or resource busy的解决方法

加载驱动模块时Device or resource busy的解决方法
insmod或modprobe驱动模块时Device or resource busy的解决方法 

在编译好memdev驱动模块后,通过insmod加载模块时发现以下错误提示: 
#insmod memdev.ko
insmod: error inserting 'memdev.ko': -1 Device or resource busy 


这种情况一般都是驱动的设备号已经被系统使用了。
我回头查看memdev模块的主设备号,我定义的是254,然后查看系统设备列表。
#cat /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
6 lp
7 vcs
10 misc
13 input
21 sg
29 fb
128 ptm
136 pts
180 usb
189 usb_device
254 vmci

Block devices:
1 ramdisk
2 fd
7 loop
8 sd
9 md
22 ide1
65 sd
66 sd
67 sd
68 sd
69 sd
70 sd
71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp

此时发现字符设别驱动的254已经被使用了。

解决方法:更换一个上表未使用的的主设备号,或者直接让系统自动分配。

系统自己分配的,可以用printk打印,然后dmesg看major number,然后再mknod
-----------------------------------------------------------------------------------------

另外值得注意的是,编译内核模块的时候,必须有一个已经配置好并编译过的内核源代码树。否则会出现以下错误:
  Building modules, stage 2.
/xxx/linux-2.6.29/scripts/Makefile.modpost:43: include/config/auto.conf: No such file or directory
make[2]: *** No rule to make target 'include/config/auto.conf'.
make[1]: *** [modules] Error 2
make[1]: Leaving directory '/xxx/linux-2.6.29'
make: *** [all] Error 2 

解决方法:先配置编译内核源代码树,然后再编译内核模块或者驱动模块。

原创粉丝点击