Commit eb579f58 authored by Inaky Perez-Gonzalez's avatar Inaky Perez-Gonzalez Committed by Greg Kroah-Hartman

usb: cleanup usb_register_bus() and hook up sysfs group

This path cleans the exit paths of usb_register_bus() [to use a goto
schema], maximum line length (keeping it under ~75).
Signed-off-by: default avatarInaky Perez-Gonzalez <inaky@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5234ce1b
...@@ -792,27 +792,23 @@ static void usb_bus_init (struct usb_bus *bus) ...@@ -792,27 +792,23 @@ static void usb_bus_init (struct usb_bus *bus)
*/ */
static int usb_register_bus(struct usb_bus *bus) static int usb_register_bus(struct usb_bus *bus)
{ {
int result = -E2BIG;
int busnum; int busnum;
mutex_lock(&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock);
busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1);
if (busnum < USB_MAXBUS) { if (busnum >= USB_MAXBUS) {
set_bit (busnum, busmap.busmap);
bus->busnum = busnum;
} else {
printk (KERN_ERR "%s: too many buses\n", usbcore_name); printk (KERN_ERR "%s: too many buses\n", usbcore_name);
mutex_unlock(&usb_bus_list_lock); goto error_find_busnum;
return -E2BIG;
} }
set_bit (busnum, busmap.busmap);
bus->busnum = busnum;
bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0), bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0),
bus->controller, "usb_host%d", busnum); bus->controller, "usb_host%d",
if (IS_ERR(bus->class_dev)) { busnum);
clear_bit(busnum, busmap.busmap); result = PTR_ERR(bus->class_dev);
mutex_unlock(&usb_bus_list_lock); if (IS_ERR(bus->class_dev))
return PTR_ERR(bus->class_dev); goto error_create_class_dev;
}
class_set_devdata(bus->class_dev, bus); class_set_devdata(bus->class_dev, bus);
/* Add it to the local list of buses */ /* Add it to the local list of buses */
...@@ -821,8 +817,15 @@ static int usb_register_bus(struct usb_bus *bus) ...@@ -821,8 +817,15 @@ static int usb_register_bus(struct usb_bus *bus)
usb_notify_add_bus(bus); usb_notify_add_bus(bus);
dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum); dev_info (bus->controller, "new USB bus registered, assigned bus "
"number %d\n", bus->busnum);
return 0; return 0;
error_create_class_dev:
clear_bit(busnum, busmap.busmap);
error_find_busnum:
mutex_unlock(&usb_bus_list_lock);
return result;
} }
/** /**
......
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