+ -
当前位置:首页 → 问答吧 → 字符设备cdev_del冒出的调用流程

字符设备cdev_del冒出的调用流程

时间:2011-01-17

来源:互联网

在我写linux驱动时候,是关于字符设备的,在卸载函数里,有这么一个调用:
printk(KERN_ALERT "the adl_dev is to del");
  cdev_del(&adl_dev.pcdev);  //remove the character device
  printk(KERN_ALERT "the adl_dev is del");
卸载的时候,会调用此函数:然后在dmesg命令后,找到如下相关的东西!
这个是怎么回事呢?是我那有错?还是只是一个具体流程!为什么我的其他函数,就没有这个呢?
1934.879632] the adl_dev is to del
[ 1934.879663] ------------[ cut here ]------------
[ 1934.879673] WARNING: at lib/kobject.c:595 kobject_put+0x48/0x4d()
[ 1934.879676] Hardware name:  
[ 1934.879679] kobject: '(null)' (e0046bdc): is not initialized, yet kobject_put() is being called.
[ 1934.879682] Modules linked in: adlink(-) intel_agp agpgart sg [last unloaded: adlink]
[ 1934.879691] Pid: 2769, comm: rmmod Not tainted 2.6.34.1 #1
[ 1934.879694] Call Trace:
[ 1934.879701]  [<c10230f2>] warn_slowpath_common+0x67/0x90
[ 1934.879706]  [<c11f8d0e>] ? kobject_put+0x48/0x4d
[ 1934.879710]  [<c11f8d0e>] ? kobject_put+0x48/0x4d
[ 1934.879715]  [<c1023158>] warn_slowpath_fmt+0x26/0x28
[ 1934.879719]  [<c11f8d0e>] kobject_put+0x48/0x4d
[ 1934.879725]  [<c108a2ac>] cdev_del+0x1d/0x20
[ 1934.879731]  [<e004616a>] adl_remove+0x10/0x36 [adlink]
[ 1934.879738]  [<c120f679>] pci_device_remove+0x19/0x3a
[ 1934.879745]  [<c1274c74>] __device_release_driver+0x3e/0x7d
[ 1934.879750]  [<c1274d47>] driver_detach+0x94/0xaf
[ 1934.879755]  [<c127419d>] bus_remove_driver+0x5a/0x91
[ 1934.879760]  [<c127516c>] driver_unregister+0x3d/0x67
[ 1934.879765]  [<c10cc418>] ? sysfs_remove_file+0xd/0xf
[ 1934.879770]  [<c120f762>] pci_unregister_driver+0x2a/0x8a
[ 1934.879775]  [<e0046158>] adl_exit_module+0x1c/0x1e [adlink]
[ 1934.879781]  [<c104769b>] sys_delete_module+0x180/0x1d0
[ 1934.879787]  [<c1077552>] ? do_munmap+0x1ed/0x2b3
[ 1934.879792]  [<c1002b93>] sysenter_do_call+0x12/0x22
[ 1934.879796] ---[ end trace d58467bd0e50a9cd ]---
[ 1934.879798] the adl_dev is to del

作者: wucongdonglai   发布时间: 2011-01-17

传入的数据结构中有没有初始化的 kobject 实例 ,应该是 adl_dev.pcdev.kobj ,仔细检查一下代码吧。

Kernel 没事是不会打印调用流程玩的。

作者: deepwhite   发布时间: 2011-01-17