/* Assigns a bus number, and links the controller into usbcore data structures so that it can be seen by scanning the bus list.  */
static int usb_register_bus(struct usb_bus *bus)
/* Assigns a bus number, and links the controller into usbcore data structures so that it can be seen by scanning the bus list.  */
static int usb_register_bus(struct usb_bus *bus)
{
	int result = -E2BIG;
	int busnum;
	mutex_lock(&usb_bus_list_lock);
	busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1);
	if (busnum >= USB_MAXBUS) {
		printk (KERN_ERR "%s: too many buses\n", usbcore_name);
		goto error_find_busnum;
	}
	set_bit (busnum, busmap.busmap);
	bus->busnum = busnum;
	list_add (&bus->bus_list, &usb_bus_list);
	mutex_unlock(&usb_bus_list_lock);
	usb_notify_add_bus(bus);
	dev_info (bus->controller, "new USB bus registered, assigned bus "
		  "number %d\n", bus->busnum);
	return 0;
error_find_busnum:
	mutex_unlock(&usb_bus_list_lock);
	return result;
}