--- zzzz-none-000/linux-2.4.17/drivers/usb/usb.c 2001-11-21 17:59:11.000000000 +0000 +++ sangam-fb-401/linux-2.4.17/drivers/usb/usb.c 2005-03-30 14:18:05.000000000 +0000 @@ -68,6 +68,22 @@ static struct usb_driver *usb_minors[16]; +#define CONFIG_USB_HOST_LIMIT_DEVICES +#define CONFIG_USB_HOST_MAX_DEVICES 5 /* = Root hub, hub + three devices... */ + +#if defined(CONFIG_USB_HOST_LIMIT_DEVICES) +# if !defined(CONFIG_USB_HOST_MAX_DEVICES) +# error CONFIG_USB_HOST_MAX_DEVICES not #defined! +# elif CONFIG_USB_HOST_MAX_DEVICES < 1 +# define CONFIG_USB_HOST_MAX_DEVICES 1 +# endif +/* + * Assumption: 1 host controller hardware, 1 host controller driver. This + * variable needs to be moved into some hcd private structure, otherwise. + */ +static unsigned int ndev_allow = CONFIG_USB_HOST_MAX_DEVICES; +#endif + /** * usb_register - register a USB driver * @new_driver: USB operations for the driver @@ -1729,6 +1745,9 @@ if (dev->devnum > 0) { clear_bit(dev->devnum, &dev->bus->devmap.devicemap); usbdevfs_remove_device(dev); +#if defined(CONFIG_USB_HOST_LIMIT_DEVICES) + ++ndev_allow; +#endif } /* Free up the device itself */ @@ -2185,7 +2204,11 @@ dev->epmaxpacketin [0] = 8; dev->epmaxpacketout[0] = 8; +#if defined(CONFIG_USB_HOST_LIMIT_DEVICES) + err = (ndev_allow > 0) ? usb_set_address(dev) : -EREMDEV; /* Error 142 */ +#else err = usb_set_address(dev); +#endif if (err < 0) { err("USB device not accepting new address=%d (error=%d)", dev->devnum, err); @@ -2240,6 +2263,9 @@ dev->devnum = -1; return 1; } +#if defined(CONFIG_USB_HOST_LIMIT_DEVICES) + --ndev_allow; +#endif dbg("new device strings: Mfr=%d, Product=%d, SerialNumber=%d", dev->descriptor.iManufacturer, dev->descriptor.iProduct, dev->descriptor.iSerialNumber);