Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2600395
  • 博文数量: 333
  • 博客积分: 4817
  • 博客等级: 上校
  • 技术积分: 4413
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-28 10:51
文章分类

全部博文(333)

文章存档

2017年(20)

2016年(57)

2015年(27)

2014年(20)

2013年(21)

2012年(164)

2011年(24)

分类: LINUX

2012-02-16 17:27:20

插入模块时出现以下错误信息:

[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中有这么一段代码:

  1. /* Start the module */  
  2. if (mod->init != NULL)  
  3.     ret = do_one_initcall(mod->init);  
  4. if (ret < 0) {  
  5.     /* Init routine failed: abort.  Try to protect us from 
  6.                   buggy refcounters. */  
  7.     mod->state = MODULE_STATE_GOING;  
  8.     synchronize_sched();  
  9.     module_put(mod);  
  10.     blocking_notifier_call_chain(&module_notify_list,  
  11.                      MODULE_STATE_GOING, mod);  
  12.     mutex_lock(&module_mutex);  
  13.     free_module(mod);  
  14.     mutex_unlock(&module_mutex);  
  15.     wake_up(&module_wq);  
  16.     return ret;  
  17. }  
  18. if (ret > 0) {  
  19.     printk(KERN_WARNING "%s: '%s'->init suspiciously returned %d, "  
  20.                 "it should follow 0/-E convention/n"  
  21.            KERN_WARNING "%s: loading module anyway.../n",  
  22.            __func__, mod->name, ret,  
  23.            __func__);  
  24.     dump_stack();  
  25. }  
 

从上面的代码可以看出,模块的init函数只能返回0或者负的错误 码。返回一个正值就会打印出

“sys_init_module: 'usbpll'->init suspiciously returned 17, it should follow 0/-E convention”类似的话。
阅读(4048) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~