插入模块时出现以下错误信息:
[root@zlg tmp]# insmod usbpll.ko
yll:usb init
sys_init_module: 'usbpll'->init suspiciously returned 17, it should follow 0/-E convention
sys_init_module: loading module anyway...
[] (dump_stack+0x0/0x14) from [] (sys_init_module+0x118/0x188)
[] (sys_init_module+0x0/0x188) from [] (ret_fast_syscall+0x0/0x2c)
r7:00000080 r6:00000000 r5:00000000 r4:00000000
原因:
init函数没有返回值。
修正方法:
增加模块init函数的返回值。
代码分析:
sys_init_module中有这么一段代码:
-
- if (mod->init != NULL)
- ret = do_one_initcall(mod->init);
- if (ret < 0) {
-
-
- mod->state = MODULE_STATE_GOING;
- synchronize_sched();
- module_put(mod);
- blocking_notifier_call_chain(&module_notify_list,
- MODULE_STATE_GOING, mod);
- mutex_lock(&module_mutex);
- free_module(mod);
- mutex_unlock(&module_mutex);
- wake_up(&module_wq);
- return ret;
- }
- if (ret > 0) {
- printk(KERN_WARNING "%s: '%s'->init suspiciously returned %d, "
- "it should follow 0/-E convention/n"
- KERN_WARNING "%s: loading module anyway.../n",
- __func__, mod->name, ret,
- __func__);
- dump_stack();
- }
从上面的代码可以看出,模块的init函数只能返回0或者负的错误 码。返回一个正值就会打印出
“sys_init_module: 'usbpll'->init suspiciously returned 17, it should follow 0/-E convention”类似的话。
阅读(4098) | 评论(0) | 转发(2) |