From: Jiri Slaby <jirislaby@gmail.com>
To: Linux kernel mailing list <linux-kernel@vger.kernel.org>
Cc: Greg KH <gregkh@suse.de>
Subject: kobject_add failed with -EEXIST
Date: Mon, 20 Nov 2006 18:14:56 +0100 [thread overview]
Message-ID: <4561E290.7060100@gmail.com> (raw)
Hi!
Does anybody have some clue, what's wrong with the attached module?
Kernel complains when the module is insmoded second time (DRIVER_DEBUG enabled):
cls_init FIRST TIME
device class 'cls_class': registering
DEV: registering device: ID = 'cls_device'
PM: Adding info for No Bus:cls_device
DEV: Unregistering device. ID = 'cls_device'
PM: Removing info for No Bus:cls_device
device_create_release called for cls_device
device class 'cls_class': unregistering
class 'cls_class': release.
class_create_release called for cls_class
cls_exit
cls_init SECOND TIME
device class 'cls_class': registering
DEV: registering device: ID = 'cls_device'
kobject_add failed for cls_class with -EEXIST, don't try to register things with
the same name in the same directory.
[<c0103edd>] show_trace_log_lvl+0x26/0x3c
[<c0104000>] show_trace+0x1b/0x1d
[<c010480a>] dump_stack+0x24/0x26
[<c01e39e7>] kobject_add+0x131/0x1b6
[<c01e3bd7>] kobject_register+0x24/0x4c
[<c01e3c55>] kobject_add_dir+0x56/0x76
[<c0256955>] setup_parent+0x6f/0x9e
[<c0256dff>] device_add+0x7f/0x4ee
[<c0257288>] device_register+0x1a/0x20
[<c025731c>] device_create+0x8e/0xb2
[<f89b0052>] cls_init+0x52/0x9f [cls]
[<c0140f00>] sys_init_module+0x15a/0x1ace
[<c01030f8>] syscall_call+0x7/0xb
=======================
kobject_add_dir: kobject_register error: -17
PM: Adding info for No Bus:cls_device
-8<-----------8<-----------8<-----------8<-
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/err.h>
static struct class *cls;
static struct device *dev;
static int __init cls_init(void)
{
printk(KERN_INFO "cls_init\n");
cls = class_create(THIS_MODULE, "cls_class");
if (IS_ERR(cls)) {
printk(KERN_ERR "class_create: %ld", PTR_ERR(cls));
return -ENODEV;
}
dev = device_create(cls, NULL, 0, "cls_device");
if (IS_ERR(dev)) {
printk(KERN_ERR "device_create: %ld", PTR_ERR(dev));
class_destroy(cls);
return -ENODEV;
}
return 0;
}
static void __exit cls_exit(void)
{
device_unregister(dev);
class_destroy(cls);
printk(KERN_INFO "cls_exit\n");
}
module_init(cls_init);
module_exit(cls_exit);
MODULE_LICENSE("GPL");
-8<-----------8<-----------8<-----------8<-
thanks,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
next reply other threads:[~2006-11-20 17:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-20 17:14 Jiri Slaby [this message]
2006-11-20 17:27 ` kobject_add failed with -EEXIST Greg KH
2006-11-20 17:31 ` Jiri Slaby
2006-11-20 17:52 ` Greg KH
2006-11-21 10:49 ` Jiri Slaby
[not found] ` <4af2d03a0611241620h657de9b8jfb9310e19f68f426@mail.gmail.com>
2006-11-25 0:30 ` Fwd: " Jiri Slaby
2006-11-20 17:31 ` Greg KH
2006-11-20 17:42 ` Oliver Neukum
2006-11-20 17:47 ` Jiri Slaby
2006-11-20 18:15 ` Jiri Slaby
2006-11-20 18:23 ` Akinobu Mita
2006-11-20 18:56 ` Jiri Slaby
2006-11-20 19:53 ` [PATCH] driver core: delete virtual directory on class_unregister() Akinobu Mita
2006-11-20 20:34 ` Greg KH
2006-11-21 9:58 ` Akinobu Mita
2006-11-21 15:09 ` Cornelia Huck
2006-11-25 8:58 ` kobject_add failed with -EEXIST markus reichelt
-- strict thread matches above, loose matches on Subject: below --
2006-11-17 15:40 Jiri Slaby
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4561E290.7060100@gmail.com \
--to=jirislaby@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox