diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-06-12 14:00:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-07-22 00:54:56 -0400 |
commit | 838ea8e8dbfc8d907c7a55bbad507a44c1b81d57 (patch) | |
tree | 77882a5d063136e61a67a91ba95c2edf1da75e03 /drivers/base | |
parent | 185000fc556372b7fb7f26516c325f212030dbd3 (diff) |
sysdev: fix debugging statements in registration code.
The systdev_class_register() and sysdev_register() functions have
pr_debug() statements which are enabled when the user selects the
driver core debug. Both of these routines do not produce the
correct output, as they make assumptions about data which has not
been initialised.
In sysdev_class_register() the code uses the kobject_name(&cls->kset.kobj)
at the start of the function, but this is not setup until later in the
same call. Change this to use cls->name which is passed in from the caller.
The sysdev_register() function tries to get the name of the sysdev by
kobject_name(&sysdev->kobj), but that isn't setup until later in the same
function so change this message to use the name of the sysdev's class and
add another message once the name is initialised.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/sys.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index 358bb0be3c08..50690d9df248 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c | |||
@@ -130,8 +130,8 @@ static struct kset *system_kset; | |||
130 | 130 | ||
131 | int sysdev_class_register(struct sysdev_class * cls) | 131 | int sysdev_class_register(struct sysdev_class * cls) |
132 | { | 132 | { |
133 | pr_debug("Registering sysdev class '%s'\n", | 133 | pr_debug("Registering sysdev class '%s'\n", cls->name); |
134 | kobject_name(&cls->kset.kobj)); | 134 | |
135 | INIT_LIST_HEAD(&cls->drivers); | 135 | INIT_LIST_HEAD(&cls->drivers); |
136 | memset(&cls->kset.kobj, 0x00, sizeof(struct kobject)); | 136 | memset(&cls->kset.kobj, 0x00, sizeof(struct kobject)); |
137 | cls->kset.kobj.parent = &system_kset->kobj; | 137 | cls->kset.kobj.parent = &system_kset->kobj; |
@@ -241,7 +241,8 @@ int sysdev_register(struct sys_device * sysdev) | |||
241 | if (!cls) | 241 | if (!cls) |
242 | return -EINVAL; | 242 | return -EINVAL; |
243 | 243 | ||
244 | pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj)); | 244 | pr_debug("Registering sys device of class '%s'\n", |
245 | kobject_name(&cls->kset.kobj)); | ||
245 | 246 | ||
246 | /* initialize the kobject to 0, in case it had previously been used */ | 247 | /* initialize the kobject to 0, in case it had previously been used */ |
247 | memset(&sysdev->kobj, 0x00, sizeof(struct kobject)); | 248 | memset(&sysdev->kobj, 0x00, sizeof(struct kobject)); |
@@ -257,6 +258,9 @@ int sysdev_register(struct sys_device * sysdev) | |||
257 | if (!error) { | 258 | if (!error) { |
258 | struct sysdev_driver * drv; | 259 | struct sysdev_driver * drv; |
259 | 260 | ||
261 | pr_debug("Registering sys device '%s'\n", | ||
262 | kobject_name(&sysdev->kobj)); | ||
263 | |||
260 | mutex_lock(&sysdev_drivers_lock); | 264 | mutex_lock(&sysdev_drivers_lock); |
261 | /* Generic notification is implicit, because it's that | 265 | /* Generic notification is implicit, because it's that |
262 | * code that should have called us. | 266 | * code that should have called us. |
@@ -269,6 +273,7 @@ int sysdev_register(struct sys_device * sysdev) | |||
269 | } | 273 | } |
270 | mutex_unlock(&sysdev_drivers_lock); | 274 | mutex_unlock(&sysdev_drivers_lock); |
271 | } | 275 | } |
276 | |||
272 | kobject_uevent(&sysdev->kobj, KOBJ_ADD); | 277 | kobject_uevent(&sysdev->kobj, KOBJ_ADD); |
273 | return error; | 278 | return error; |
274 | } | 279 | } |