Commit b6157a96 authored by Luiz Capitulino's avatar Luiz Capitulino Committed by Greg Kroah-Hartman

[PATCH] USB: usb/core/file.c::usb_major_init() cleanup.

 This patch does a cleanup for usb/core/file.c::usb_major_init(), which
 is:

*) in error condition, returns the error code from register_chrdev(),
   insted returning -EBUSY;

*) adds missing audit for class_register();

*) only calls devfs_mk_dir() if the prior calls have success.
Signed-off-by: default avatarLuiz Capitulino <lcapitulino@prefeitura.sp.gov.br>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent bfc614c5
...@@ -79,14 +79,25 @@ static struct class usb_class = { ...@@ -79,14 +79,25 @@ static struct class usb_class = {
int usb_major_init(void) int usb_major_init(void)
{ {
if (register_chrdev(USB_MAJOR, "usb", &usb_fops)) { int error;
error = register_chrdev(USB_MAJOR, "usb", &usb_fops);
if (error) {
err("unable to get major %d for usb devices", USB_MAJOR); err("unable to get major %d for usb devices", USB_MAJOR);
return -EBUSY; goto out;
}
error = class_register(&usb_class);
if (error) {
err("class_register failed for usb devices");
unregister_chrdev(USB_MAJOR, "usb");
goto out;
} }
devfs_mk_dir("usb"); devfs_mk_dir("usb");
class_register(&usb_class);
return 0; out:
return error;
} }
void usb_major_cleanup(void) void usb_major_cleanup(void)
......
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