这个例子限定了内核版本(2.4.20)和条件(devfs),所以这里没有考虑任何错误处理和移植问题。这是为了尽量简洁。大家将来如果真要做驱动,可不能这么简单了,要考虑好多问题的。
i do not think u code is binded to 2.4.20. maybe every 2.4.x can. for considering the different kernel. i recommend the sysdep.h in ldd2 examples. about the SET_MODULE_OWNER see it from module.h
409 #ifdef CONFIG_MODULES
410 #define SET_MODULE_OWNER(some_struct) do { (some_struct)->owner = THIS_MODULE; } while (0)
411 #else
412 #define SET_MODULE_OWNER(some_struct) do { } while (0)
413 #endif
no tricky here. set the owner pointer to the module struct. 我用以上例子时出现如下错误,是2.4.18-14内核,insmod dragonfly.o
dragonfly.o: init_module: Device or resource busy
Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters.
You may find more information in syslog or the output from dmesg
而且我还发现devfs_register就会出现这样的问题,请指教 u error come from this
"if (!df_devfs_dir) return -EBUSY; "
but i am not sure why 2.4.18-14 have this problem. can u change it to normal register_chrdev
页:
1
[2]