diff options
| -rw-r--r-- | sys/dev/usb/uhub.c | 11 | ||||
| -rw-r--r-- | sys/dev/usb/usb_port.h | 19 |
2 files changed, 13 insertions, 17 deletions
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c index 5125f1d0a361..6b859b9d54c7 100644 --- a/sys/dev/usb/uhub.c +++ b/sys/dev/usb/uhub.c @@ -48,11 +48,11 @@ #include <sys/malloc.h> #if defined(__NetBSD__) || defined(__OpenBSD__) #include <sys/device.h> +#include <sys/proc.h> #elif defined(__FreeBSD__) #include <sys/module.h> #include <sys/bus.h> #endif -#include <sys/proc.h> #include "bus_if.h" @@ -87,20 +87,22 @@ void uhub_intr __P((usbd_request_handle, usbd_private_handle, usbd_status)); static bus_child_detached_t uhub_child_detached; #endif -USB_DECLARE_DRIVER_INIT(uhub, DEVMETHOD(bus_child_detached, uhub_child_detached)); - /* We need two attachment points: * hub to usb and hub to hub * Every other driver only connects to hubs */ #if defined(__NetBSD__) || defined(__OpenBSD__) +USB_DECLARE_DRIVER(uhub); + /* Create the driver instance for the hub connected to hub case */ struct cfattach uhub_uhub_ca = { sizeof(struct uhub_softc), uhub_match, uhub_attach, uhub_detach, uhub_activate }; #elif defined(__FreeBSD__) +USB_DECLARE_DRIVER_INIT(uhub, DEVMETHOD(bus_child_detached, uhub_child_detached)); + /* Create the driver instance for the hub connected to usb case. */ devclass_t uhubroot_devclass; @@ -539,7 +541,8 @@ uhub_child_detached(self, child) /* should never happen; children are only created after init */ panic("hub not fully initialised, but child deleted?"); - for (port = 0; port < dev->hub->hubdesc.bNbrPorts; port++) { + nports = dev->hub->hubdesc.bNbrPorts; + for (port = 0; port < nports; port++) { up = &dev->hub->ports[port]; if (up->device && up->device->subdevs) { for (i = 0; up->device->subdevs[i]; i++) { diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h index 7c8d8c4e18ea..55b4db2e65e1 100644 --- a/sys/dev/usb/usb_port.h +++ b/sys/dev/usb/usb_port.h @@ -68,7 +68,7 @@ typedef struct device *device_ptr_t; #define logprintf printf -#define USB_DECLARE_DRIVER_NAME_INIT(_1, dname, _2) \ +#define USB_DECLARE_DRIVER(dname) \ int __CONCAT(dname,_match) __P((struct device *, struct cfdata *, void *)); \ void __CONCAT(dname,_attach) __P((struct device *, struct device *, void *)); \ int __CONCAT(dname,_detach) __P((struct device *, int)); \ @@ -166,7 +166,7 @@ typedef struct device device_ptr_t; #define usb_timeout(f, d, t, h) timeout((f), (d), (t)) #define usb_untimeout(f, d, h) untimeout((f), (d)) -#define USB_DECLARE_DRIVER_NAME_INIT(_1, dname, _2) \ +#define USB_DECLARE_DRIVER(dname) \ int __CONCAT(dname,_match) __P((struct device *, void *, void *)); \ void __CONCAT(dname,_attach) __P((struct device *, struct device *, void *)); \ int __CONCAT(dname,_detach) __P((struct device *, int)); \ @@ -265,7 +265,7 @@ __CONCAT(dname,_detach)(self, flags) \ #define usb_timeout(f, d, t, h) ((h) = timeout((f), (d), (t))) #define usb_untimeout(f, d, h) untimeout((f), (d), (h)) -#define USB_DECLARE_DRIVER_NAME_INIT(name, dname, init...) \ +#define USB_DECLARE_DRIVER_INIT(dname, init...) \ static device_probe_t __CONCAT(dname,_match); \ static device_attach_t __CONCAT(dname,_attach); \ static device_detach_t __CONCAT(dname,_detach); \ @@ -281,10 +281,12 @@ static device_method_t __CONCAT(dname,_methods)[] = { \ }; \ \ static driver_t __CONCAT(dname,_driver) = { \ - name, \ + #dname, \ __CONCAT(dname,_methods), \ sizeof(struct __CONCAT(dname,_softc)) \ } +#define METHODS_NONE {0,0} +#define USB_DECLARE_DRIVER(dname) USB_DECLARE_DRIVER_INIT(dname, METHODS_NONE) #define USB_MATCH(dname) \ static int \ @@ -354,15 +356,6 @@ __CONCAT(dname,_detach)(device_t self) #endif /* __FreeBSD__ */ -#define NONE {0,0} - -#define USB_DECLARE_DRIVER_NAME(name, dname) \ - USB_DECLARE_DRIVER_NAME_INIT(#name, dname, NONE ) -#define USB_DECLARE_DRIVER_INIT(dname, init...) \ - USB_DECLARE_DRIVER_NAME_INIT(#dname, dname, init) -#define USB_DECLARE_DRIVER(dname) \ - USB_DECLARE_DRIVER_NAME_INIT(#dname, dname, NONE ) - #if defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__FreeBSD__) #endif |
