Skip to content

Commit

Permalink
sysdev: fix debugging statements in registration code.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ben Dooks authored and Greg Kroah-Hartman committed Jul 22, 2008
1 parent 185000f commit 838ea8e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/base/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ static struct kset *system_kset;

int sysdev_class_register(struct sysdev_class * cls)
{
pr_debug("Registering sysdev class '%s'\n",
kobject_name(&cls->kset.kobj));
pr_debug("Registering sysdev class '%s'\n", cls->name);

INIT_LIST_HEAD(&cls->drivers);
memset(&cls->kset.kobj, 0x00, sizeof(struct kobject));
cls->kset.kobj.parent = &system_kset->kobj;
Expand Down Expand Up @@ -241,7 +241,8 @@ int sysdev_register(struct sys_device * sysdev)
if (!cls)
return -EINVAL;

pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));
pr_debug("Registering sys device of class '%s'\n",
kobject_name(&cls->kset.kobj));

/* initialize the kobject to 0, in case it had previously been used */
memset(&sysdev->kobj, 0x00, sizeof(struct kobject));
Expand All @@ -257,6 +258,9 @@ int sysdev_register(struct sys_device * sysdev)
if (!error) {
struct sysdev_driver * drv;

pr_debug("Registering sys device '%s'\n",
kobject_name(&sysdev->kobj));

mutex_lock(&sysdev_drivers_lock);
/* Generic notification is implicit, because it's that
* code that should have called us.
Expand All @@ -269,6 +273,7 @@ int sysdev_register(struct sys_device * sysdev)
}
mutex_unlock(&sysdev_drivers_lock);
}

kobject_uevent(&sysdev->kobj, KOBJ_ADD);
return error;
}
Expand Down

0 comments on commit 838ea8e

Please sign in to comment.