diff --git a/sys/dev/usb/controller/at91dci.c b/sys/dev/usb/controller/at91dci.c index fec3b2761281..cfb74a3e558a 100644 --- a/sys/dev/usb/controller/at91dci.c +++ b/sys/dev/usb/controller/at91dci.c @@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR at91dcidebug diff --git a/sys/dev/usb/controller/at91dci_atmelarm.c b/sys/dev/usb/controller/at91dci_atmelarm.c index 71d2937cdde5..164f9bd38363 100644 --- a/sys/dev/usb/controller/at91dci_atmelarm.c +++ b/sys/dev/usb/controller/at91dci_atmelarm.c @@ -28,7 +28,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include diff --git a/sys/dev/usb/controller/atmegadci.c b/sys/dev/usb/controller/atmegadci.c index edaef19c38b7..a05238534886 100644 --- a/sys/dev/usb/controller/atmegadci.c +++ b/sys/dev/usb/controller/atmegadci.c @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR atmegadci_debug diff --git a/sys/dev/usb/controller/atmegadci_atmelarm.c b/sys/dev/usb/controller/atmegadci_atmelarm.c index 7cf2eb42ddd4..1fc929fba596 100644 --- a/sys/dev/usb/controller/atmegadci_atmelarm.c +++ b/sys/dev/usb/controller/atmegadci_atmelarm.c @@ -26,7 +26,6 @@ __FBSDID("$FreeBSD$"); * SUCH DAMAGE. */ -#include #include #include diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c index 7c873d9f778a..42f41ff37e46 100644 --- a/sys/dev/usb/controller/ehci.c +++ b/sys/dev/usb/controller/ehci.c @@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR ehcidebug @@ -3168,7 +3167,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer, USETW(sc->sc_hub_desc.stat.wStatus, 0); break; case C(UR_SET_ADDRESS, UT_WRITE_DEVICE): - if (value >= USB_MAX_DEVICES) { + if (value >= EHCI_MAX_DEVICES) { std->err = USB_ERR_IOERROR; goto done; } diff --git a/sys/dev/usb/controller/ehci.h b/sys/dev/usb/controller/ehci.h index 5b5480947f4a..ddb2d9c6b006 100644 --- a/sys/dev/usb/controller/ehci.h +++ b/sys/dev/usb/controller/ehci.h @@ -38,7 +38,7 @@ #ifndef _EHCI_H_ #define _EHCI_H_ -#define EHCI_MAX_DEVICES USB_MAX_DEVICES +#define EHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) /* PCI config registers */ #define PCI_CBMEM 0x10 /* configuration base MEM */ diff --git a/sys/dev/usb/controller/ehci_ixp4xx.c b/sys/dev/usb/controller/ehci_ixp4xx.c index 1e0e2531d2f7..5ce8e68581a8 100644 --- a/sys/dev/usb/controller/ehci_ixp4xx.c +++ b/sys/dev/usb/controller/ehci_ixp4xx.c @@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$"); #include "opt_bus.h" #include -#include #include #include diff --git a/sys/dev/usb/controller/ehci_mbus.c b/sys/dev/usb/controller/ehci_mbus.c index 66cf8cc58b8a..31431a15fa9b 100644 --- a/sys/dev/usb/controller/ehci_mbus.c +++ b/sys/dev/usb/controller/ehci_mbus.c @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include "opt_bus.h" #include -#include #include #include diff --git a/sys/dev/usb/controller/ehci_pci.c b/sys/dev/usb/controller/ehci_pci.c index 2f097fc22873..f739c3a7cc11 100644 --- a/sys/dev/usb/controller/ehci_pci.c +++ b/sys/dev/usb/controller/ehci_pci.c @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); */ #include -#include #include #include diff --git a/sys/dev/usb/controller/musb_otg.c b/sys/dev/usb/controller/musb_otg.c index cda1a67ca5ef..be0af9330e37 100644 --- a/sys/dev/usb/controller/musb_otg.c +++ b/sys/dev/usb/controller/musb_otg.c @@ -39,7 +39,6 @@ #include #include #include -#include #define USB_DEBUG_VAR musbotgdebug diff --git a/sys/dev/usb/controller/musb_otg_atmelarm.c b/sys/dev/usb/controller/musb_otg_atmelarm.c index 3ee5cfbafadf..38fa304993c2 100644 --- a/sys/dev/usb/controller/musb_otg_atmelarm.c +++ b/sys/dev/usb/controller/musb_otg_atmelarm.c @@ -25,7 +25,6 @@ */ #include -#include #include #include diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c index ad2b1ccf50a5..d453de891eca 100644 --- a/sys/dev/usb/controller/ohci.c +++ b/sys/dev/usb/controller/ohci.c @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR ohcidebug @@ -2256,7 +2255,7 @@ ohci_root_ctrl_done(struct usb2_xfer *xfer, USETW(sc->sc_hub_desc.stat.wStatus, 0); break; case C(UR_SET_ADDRESS, UT_WRITE_DEVICE): - if (value >= USB_MAX_DEVICES) { + if (value >= OHCI_MAX_DEVICES) { std->err = USB_ERR_IOERROR; goto done; } diff --git a/sys/dev/usb/controller/ohci.h b/sys/dev/usb/controller/ohci.h index 84a6afd4365d..47d3be332fc5 100644 --- a/sys/dev/usb/controller/ohci.h +++ b/sys/dev/usb/controller/ohci.h @@ -39,7 +39,7 @@ #ifndef _OHCI_H_ #define _OHCI_H_ -#define OHCI_MAX_DEVICES USB_MAX_DEVICES +#define OHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) /* PCI config registers */ #define PCI_CBMEM 0x10 /* configuration base memory */ diff --git a/sys/dev/usb/controller/ohci_atmelarm.c b/sys/dev/usb/controller/ohci_atmelarm.c index 562cf3d18665..34826e023241 100644 --- a/sys/dev/usb/controller/ohci_atmelarm.c +++ b/sys/dev/usb/controller/ohci_atmelarm.c @@ -26,7 +26,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include diff --git a/sys/dev/usb/controller/ohci_pci.c b/sys/dev/usb/controller/ohci_pci.c index c9f586de2b10..fec8acdbf578 100644 --- a/sys/dev/usb/controller/ohci_pci.c +++ b/sys/dev/usb/controller/ohci_pci.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include diff --git a/sys/dev/usb/controller/uhci.c b/sys/dev/usb/controller/uhci.c index 82a96230fc95..de4026d7425c 100644 --- a/sys/dev/usb/controller/uhci.c +++ b/sys/dev/usb/controller/uhci.c @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR uhcidebug @@ -2626,7 +2625,7 @@ uhci_root_ctrl_done(struct usb2_xfer *xfer, USETW(sc->sc_hub_desc.stat.wStatus, 0); break; case C(UR_SET_ADDRESS, UT_WRITE_DEVICE): - if (value >= USB_MAX_DEVICES) { + if (value >= UHCI_MAX_DEVICES) { std->err = USB_ERR_IOERROR; goto done; } diff --git a/sys/dev/usb/controller/uhci.h b/sys/dev/usb/controller/uhci.h index 9365a4c94200..c652dd866438 100644 --- a/sys/dev/usb/controller/uhci.h +++ b/sys/dev/usb/controller/uhci.h @@ -39,7 +39,7 @@ #ifndef _UHCI_H_ #define _UHCI_H_ -#define UHCI_MAX_DEVICES USB_MAX_DEVICES +#define UHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) /* PCI config registers */ #define PCI_USBREV 0x60 /* USB protocol revision */ diff --git a/sys/dev/usb/controller/uhci_pci.c b/sys/dev/usb/controller/uhci_pci.c index a61693bc16b6..379841bb3dcf 100644 --- a/sys/dev/usb/controller/uhci_pci.c +++ b/sys/dev/usb/controller/uhci_pci.c @@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$"); */ #include -#include #include #include diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index f835ec1fb5f4..70099efc6b3b 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -25,7 +25,6 @@ */ #include -#include #include #include diff --git a/sys/dev/usb/controller/uss820dci.c b/sys/dev/usb/controller/uss820dci.c index 5fc8e980644b..8e1e2bc0d08b 100644 --- a/sys/dev/usb/controller/uss820dci.c +++ b/sys/dev/usb/controller/uss820dci.c @@ -36,7 +36,6 @@ #include #include #include -#include #define USB_DEBUG_VAR uss820dcidebug diff --git a/sys/dev/usb/controller/uss820dci_atmelarm.c b/sys/dev/usb/controller/uss820dci_atmelarm.c index 5691d4b0013b..4cd08621fccf 100644 --- a/sys/dev/usb/controller/uss820dci_atmelarm.c +++ b/sys/dev/usb/controller/uss820dci_atmelarm.c @@ -28,7 +28,6 @@ __FBSDID("$FreeBSD$"); */ #include -#include #include #include diff --git a/sys/dev/usb/net/if_cdce.c b/sys/dev/usb/net/if_cdce.c index a54ddc0abc94..8e7aae44e127 100644 --- a/sys/dev/usb/net/if_cdce.c +++ b/sys/dev/usb/net/if_cdce.c @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR cdce_debug diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c index 4b79aae5d73e..19d3d506a98d 100644 --- a/sys/dev/usb/serial/u3g.c +++ b/sys/dev/usb/serial/u3g.c @@ -34,7 +34,6 @@ #include #include #include -#include #define USB_DEBUG_VAR u3g_debug diff --git a/sys/dev/usb/serial/ubser.c b/sys/dev/usb/serial/ubser.c index 266af1d5bca9..08d5e14e8840 100644 --- a/sys/dev/usb/serial/ubser.c +++ b/sys/dev/usb/serial/ubser.c @@ -80,7 +80,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR ubser_debug diff --git a/sys/dev/usb/serial/ugensa.c b/sys/dev/usb/serial/ugensa.c index c85e57d5e46f..6174f1762892 100644 --- a/sys/dev/usb/serial/ugensa.c +++ b/sys/dev/usb/serial/ugensa.c @@ -47,7 +47,6 @@ #include #include #include -#include #define USB_DEBUG_VAR usb2_debug diff --git a/sys/dev/usb/serial/umct.c b/sys/dev/usb/serial/umct.c index dba38d2bfaeb..9e49440d9312 100644 --- a/sys/dev/usb/serial/umct.c +++ b/sys/dev/usb/serial/umct.c @@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR usb2_debug diff --git a/sys/dev/usb/serial/umodem.c b/sys/dev/usb/serial/umodem.c index 9c53c884a3c1..dedea151da9d 100644 --- a/sys/dev/usb/serial/umodem.c +++ b/sys/dev/usb/serial/umodem.c @@ -86,7 +86,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #define USB_DEBUG_VAR umodem_debug diff --git a/sys/dev/usb/storage/ustorage_fs.c b/sys/dev/usb/storage/ustorage_fs.c index e6b71fb5d463..bcb63a5b9f07 100644 --- a/sys/dev/usb/storage/ustorage_fs.c +++ b/sys/dev/usb/storage/ustorage_fs.c @@ -39,7 +39,6 @@ #include #include #include -#include #define USB_DEBUG_VAR ustorage_fs_debug diff --git a/sys/dev/usb/template/usb_template.c b/sys/dev/usb/template/usb_template.c index 31c853afc88a..dd1a536c02f5 100644 --- a/sys/dev/usb/template/usb_template.c +++ b/sys/dev/usb/template/usb_template.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #define USB_DEBUG_VAR usb2_debug diff --git a/sys/dev/usb/usb_busdma.c b/sys/dev/usb/usb_busdma.c index 809c3bfea0a3..86b6921145ee 100644 --- a/sys/dev/usb/usb_busdma.c +++ b/sys/dev/usb/usb_busdma.c @@ -27,7 +27,6 @@ #include #include #include -#include #define USB_DEBUG_VAR usb2_debug diff --git a/sys/dev/usb/usb_compat_linux.c b/sys/dev/usb/usb_compat_linux.c index 6d6c857c1a27..b422df1010d3 100644 --- a/sys/dev/usb/usb_compat_linux.c +++ b/sys/dev/usb/usb_compat_linux.c @@ -25,7 +25,6 @@ * SUCH DAMAGE. */ -#include #include #include #include diff --git a/sys/dev/usb/usb_core.h b/sys/dev/usb/usb_core.h index 6067815ef080..f76064208150 100644 --- a/sys/dev/usb/usb_core.h +++ b/sys/dev/usb/usb_core.h @@ -157,10 +157,40 @@ struct usb2_xfer_root; /* typedefs */ -typedef uint8_t usb2_error_t; - typedef void (usb2_callback_t)(struct usb2_xfer *); +#ifndef USB_HAVE_USB_ERROR_T +typedef uint8_t usb2_error_t; /* see "USB_ERR_XXX" */ +#endif + +#ifndef USB_HAVE_TIMEOUT_T +typedef uint32_t usb2_timeout_t; /* milliseconds */ +#endif + +#ifndef USB_HAVE_LENGTH_T +typedef uint32_t usb2_length_t; /* bytes */ +#endif + +#ifndef USB_HAVE_FRAMES_T +typedef uint32_t usb2_frames_t; /* units */ +#endif + +#ifndef USB_HAVE_INTERVAL_T +typedef uint32_t usb2_interval_t; /* milliseconds */ +#endif + +#ifndef USB_HAVE_SIZE_T +typedef uint32_t usb2_size_t; /* bytes */ +#endif + +#ifndef USB_HAVE_REFS_T +typedef uint32_t usb2_refs_t; /* units */ +#endif + +#ifndef USB_HAVE_TICKS_T +typedef uint32_t usb2_ticks_t; /* system defined */ +#endif + /* structures */ /* diff --git a/sys/dev/usb/usb_debug.c b/sys/dev/usb/usb_debug.c index b7eeea7681be..da317fe4b791 100644 --- a/sys/dev/usb/usb_debug.c +++ b/sys/dev/usb/usb_debug.c @@ -25,7 +25,6 @@ */ #include -#include #include #include diff --git a/sys/dev/usb/usb_defs.h b/sys/dev/usb/usb_defs.h index 64caf3931806..4f72ea53c01a 100644 --- a/sys/dev/usb/usb_defs.h +++ b/sys/dev/usb/usb_defs.h @@ -27,22 +27,16 @@ #ifndef _USB2_DEFS_H_ #define _USB2_DEFS_H_ -/* Definition of some USB constants */ +/* Definition of some hardcoded USB constants. */ + +#define USB_MAX_IPACKET 8 /* initial USB packet size */ -#define USB_BUS_MAX 256 /* units */ -#define USB_DEV_MAX 128 /* units */ -#define USB_IFACE_MAX 32 /* units */ #define USB_EP_MAX (2*16) /* hardcoded */ -#define USB_FIFO_MAX (4 * USB_EP_MAX) #define USB_ROOT_HUB_ADDR 1 /* index */ #define USB_MIN_DEVICES 2 /* unused + root HUB */ -#define USB_MAX_DEVICES USB_DEV_MAX /* including virtual root HUB and - * address zero */ -#define USB_MAX_ENDPOINTS USB_EP_MAX /* 2 directions on 16 endpoints */ - #define USB_UNCONFIG_INDEX 0xFF /* internal use only */ #define USB_IFACE_INDEX_ANY 0xFF /* internal use only */ @@ -57,20 +51,10 @@ #define USB_FS_BYTES_PER_HS_UFRAME 188 /* bytes */ #define USB_HS_MICRO_FRAMES_MAX 8 /* units */ +#define USB_ISOC_TIME_MAX 128 /* ms */ + /* sanity checks */ -#if (USB_FIFO_MAX < USB_EP_MAX) -#error "There cannot be less FIFOs than USB endpoints." -#endif -#if (USB_FIFO_MAX & 1) -#error "Number of FIFOs must be odd." -#endif -#if (USB_EP_MAX < (2*16)) -#error "Number of hardware USB endpoints cannot be less than 32." -#endif -#if (USB_MAX_DEVICES < USB_MIN_DEVICES) -#error "Minimum number of devices is greater than maximum number of devices." -#endif #if (USB_ROOT_HUB_ADDR >= USB_MIN_DEVICES) #error "The root hub address must be less than USB_MIN_DEVICES." #endif diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index d3d98ff544c3..6dbc6ae44677 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -29,7 +29,6 @@ #include #include -#include #include #include diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index 8bd7326bc3c3..c667eacf4917 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include diff --git a/sys/dev/usb/usb_dynamic.c b/sys/dev/usb/usb_dynamic.c index 6983f64de635..8c0a64454874 100644 --- a/sys/dev/usb/usb_dynamic.c +++ b/sys/dev/usb/usb_dynamic.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index c7cf05611542..d7995894e270 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include diff --git a/sys/dev/usb/usb_handle_request.c b/sys/dev/usb/usb_handle_request.c index 3d2425a323ea..0df5d8763914 100644 --- a/sys/dev/usb/usb_handle_request.c +++ b/sys/dev/usb/usb_handle_request.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include diff --git a/sys/dev/usb/usb_hid.c b/sys/dev/usb/usb_hid.c index f79414a24fcf..21c32d6ee1d2 100644 --- a/sys/dev/usb/usb_hid.c +++ b/sys/dev/usb/usb_hid.c @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #define USB_DEBUG_VAR usb2_debug diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index 67190ed16541..596edebd8389 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -30,7 +30,6 @@ * USB spec: http://www.usb.org/developers/docs/usbspec.zip */ -#include #include #include #include diff --git a/sys/dev/usb/usb_msctest.c b/sys/dev/usb/usb_msctest.c index 35b71ece649d..d41d8c968a6d 100644 --- a/sys/dev/usb/usb_msctest.c +++ b/sys/dev/usb/usb_msctest.c @@ -32,7 +32,6 @@ * mass storage quirks for not supported SCSI commands! */ -#include #include #include #include diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c index 47f7ec7c21e8..0c66942b9f09 100644 --- a/sys/dev/usb/usb_request.c +++ b/sys/dev/usb/usb_request.c @@ -26,7 +26,6 @@ * SUCH DAMAGE. */ -#include #include #include #include diff --git a/sys/dev/usb/usb_sw_transfer.c b/sys/dev/usb/usb_sw_transfer.c index 984c233025cd..439ed9c88734 100644 --- a/sys/dev/usb/usb_sw_transfer.c +++ b/sys/dev/usb/usb_sw_transfer.c @@ -27,7 +27,6 @@ #include #include #include -#include #define USB_DEBUG_VAR usb2_debug diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 71bbb0873552..097931e39f75 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -27,7 +27,6 @@ #include #include #include -#include #define USB_DEBUG_VAR usb2_debug diff --git a/sys/dev/usb/usb_util.c b/sys/dev/usb/usb_util.c index 541cd55fc9a4..b22e35bdec2f 100644 --- a/sys/dev/usb/usb_util.c +++ b/sys/dev/usb/usb_util.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -#include #include #include #include