Dragonfly 发表于 2003-5-26 03:13:36

说明4:
这个例子限定了内核版本(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.

Dragonfly 发表于 2003-5-26 03:21:57

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.

gxqing 发表于 2003-6-9 17:25:52

我用以上例子时出现如下错误,是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就会出现这样的问题,请指教

Dragonfly 发表于 2003-6-9 21:52:59

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]
查看完整版本: 编写一个简单的驱动程序