modprobe实现自动挂载时出现挂载失败,并且有两个设备号
下面是终端报错:
WARNING: CPU: 0 PID: 79 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x54/0x74()
sysfs: cannot create duplicate filename '/class/newchrled'
Modules linked in: newchrled(O+)
CPU: 0 PID: 79 Comm: modprobe Tainted: G O 4.1.15 #1
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[<80015ed4>] (unwind_backtrace) from [<80012794>] (show_stack+0x10/0x14)
[<80012794>] (show_stack) from [<8068c9fc>] (dump_stack+0x80/0xc8)
[<8068c9fc>] (dump_stack) from [<8003824c>] (warn_slowpath_common+0x74/0xb0)
[<8003824c>] (warn_slowpath_common) from [<800382b8>] (warn_slowpath_fmt+0x30/0x40)
[<800382b8>] (warn_slowpath_fmt) from [<8014b774>] (sysfs_warn_dup+0x54/0x74)
[<8014b774>] (sysfs_warn_dup) from [<8014b860>] (sysfs_create_dir_ns+0x84/0x9c)
[<8014b860>] (sysfs_create_dir_ns) from [<8029e380>] (kobject_add_internal+0xa0/0x2d8)
[<8029e380>] (kobject_add_internal) from [<8029e670>] (kset_register+0x50/0x7c)
[<8029e670>] (kset_register) from [<8034e604>] (__class_register+0xa8/0x1bc)
[<8034e604>] (__class_register) from [<8034e758>] (__class_create+0x40/0x78)
[<8034e758>] (__class_create) from [<7f0061ec>] (led_init+0x1ec/0x248 [newchrled])
[<7f0061ec>] (led_init [newchrled]) from [<80009704>] (do_one_initcall+0x80/0x1d8)
[<80009704>] (do_one_initcall) from [<8068a8e8>] (do_init_module+0x58/0x1a8)
[<8068a8e8>] (do_init_module) from [<80095e48>] (load_module+0x165c/0x1d48)
[<80095e48>] (load_module) from [<80096600>] (SyS_init_module+0xcc/0x124)
[<80096600>] (SyS_init_module) from [<8000f500>] (ret_fast_syscall+0x0/0x3c)
---[ end trace a611e8ac7172b37f ]---
------------[ cut here ]------------
WARNING: CPU: 0 PID: 79 at lib/kobject.c:240 kobject_add_internal+0x25c/0x2d8()
kobject_add_internal failed for newchrled with -EEXIST, don't try to register things with the same name in the same directory.
Modules linked in: newchrled(O+)
CPU: 0 PID: 79 Comm: modprobe Tainted: G W O 4.1.15 #1
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[<80015ed4>] (unwind_backtrace) from [<80012794>] (show_stack+0x10/0x14)
[<80012794>] (show_stack) from [<8068c9fc>] (dump_stack+0x80/0xc8)
[<8068c9fc>] (dump_stack) from [<8003824c>] (warn_slowpath_common+0x74/0xb0)
[<8003824c>] (warn_slowpath_common) from [<800382b8>] (warn_slowpath_fmt+0x30/0x40)
[<800382b8>] (warn_slowpath_fmt) from [<8029e53c>] (kobject_add_internal+0x25c/0x2d8)
[<8029e53c>] (kobject_add_internal) from [<8029e670>] (kset_register+0x50/0x7c)
[<8029e670>] (kset_register) from [<8034e604>] (__class_register+0xa8/0x1bc)
[<8034e604>] (__class_register) from [<8034e758>] (__class_create+0x40/0x78)
[<8034e758>] (__class_create) from [<7f0061ec>] (led_init+0x1ec/0x248 [newchrled])
[<7f0061ec>] (led_init [newchrled]) from [<80009704>] (do_one_initcall+0x80/0x1d8)
[<80009704>] (do_one_initcall) from [<8068a8e8>] (do_init_module+0x58/0x1a8)
[<8068a8e8>] (do_init_module) from [<80095e48>] (load_module+0x165c/0x1d48)
[<80095e48>] (load_module) from [<80096600>] (SyS_init_module+0xcc/0x124)
[<80096600>] (SyS_init_module) from [<8000f500>] (ret_fast_syscall+0x0/0x3c)
---[ end trace a611e8ac7172b380 ]---
解决办法:
从驱动入口函数可已看出,我漏加了返回值,补上解决!