Commit bd37147c authored by Leann Ogasawara's avatar Leann Ogasawara Committed by Greg Kroah-Hartman

[PATCH] Fix class_register() always returns 0

I noticed that the class_register() function in drivers/base/class.c
always returns 0 and thus will never fail.  Patch below inserts simple
error checking to return any errors if they occur.  Feedback welcome.
Thanks,
parent 4740d085
...@@ -102,13 +102,21 @@ void class_put(struct class * cls) ...@@ -102,13 +102,21 @@ void class_put(struct class * cls)
int class_register(struct class * cls) int class_register(struct class * cls)
{ {
int error;
pr_debug("device class '%s': registering\n",cls->name); pr_debug("device class '%s': registering\n",cls->name);
INIT_LIST_HEAD(&cls->children); INIT_LIST_HEAD(&cls->children);
INIT_LIST_HEAD(&cls->interfaces); INIT_LIST_HEAD(&cls->interfaces);
kobject_set_name(&cls->subsys.kset.kobj,cls->name); error = kobject_set_name(&cls->subsys.kset.kobj,cls->name);
if (error)
return error;
subsys_set_kset(cls,class_subsys); subsys_set_kset(cls,class_subsys);
subsystem_register(&cls->subsys);
error = subsystem_register(&cls->subsys);
if (error)
return error;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment