Diff for /src/sys/bus/usb/usb.c between versions 1.10 and 1.11

version 1.10, 2004/01/08 18:12:59 version 1.11, 2004/02/11 15:17:26
Line 58 Line 58
 #include <sys/kernel.h>  #include <sys/kernel.h>
 #include <sys/lock.h>  #include <sys/lock.h>
 #include <sys/malloc.h>  #include <sys/malloc.h>
#if __FreeBSD_version >= 500000#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
 #include <sys/mutex.h>  #include <sys/mutex.h>
 #endif  #endif
 #if defined(__NetBSD__) || defined(__OpenBSD__)  #if defined(__NetBSD__) || defined(__OpenBSD__)
 #include <sys/device.h>  #include <sys/device.h>
#elif defined(__FreeBSD__)#elif defined(__FreeBSD__) || defined(__DragonFly__)
 #include <sys/unistd.h>  #include <sys/unistd.h>
 #include <sys/module.h>  #include <sys/module.h>
 #include <sys/bus.h>  #include <sys/bus.h>
Line 74 Line 74
 #include <sys/proc.h>  #include <sys/proc.h>
 #include <sys/conf.h>  #include <sys/conf.h>
 #include <sys/poll.h>  #include <sys/poll.h>
#if __FreeBSD_version >= 500014#if defined(__FreeBSD__) && __FreeBSD_version >= 500014
 #include <sys/selinfo.h>  #include <sys/selinfo.h>
 #else  #else
 #include <sys/select.h>  #include <sys/select.h>
Line 90 Line 90
 #define USBUNIT(d)      (minor(d))      /* usb_discover device nodes, kthread */  #define USBUNIT(d)      (minor(d))      /* usb_discover device nodes, kthread */
 #define USB_DEV_MINOR   255             /* event queue device */  #define USB_DEV_MINOR   255             /* event queue device */
   
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
 MALLOC_DEFINE(M_USB, "USB", "USB");  MALLOC_DEFINE(M_USB, "USB", "USB");
 MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device");  MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device");
 MALLOC_DEFINE(M_USBHC, "USBHC", "USB host controller");  MALLOC_DEFINE(M_USBHC, "USBHC", "USB host controller");
Line 139  TAILQ_HEAD(, usb_task) usb_all_tasks; Line 139  TAILQ_HEAD(, usb_task) usb_all_tasks;
   
 #if defined(__NetBSD__) || defined(__OpenBSD__)  #if defined(__NetBSD__) || defined(__OpenBSD__)
 cdev_decl(usb);  cdev_decl(usb);
#elif defined(__FreeBSD__)#elif defined(__FreeBSD__) || defined(__DragonFly__)
 d_open_t  usbopen;  d_open_t  usbopen;
 d_close_t usbclose;  d_close_t usbclose;
 d_read_t usbread;  d_read_t usbread;
Line 200  USB_DECLARE_DRIVER_INIT(usb, Line 200  USB_DECLARE_DRIVER_INIT(usb,
                         DEVMETHOD(device_shutdown, bus_generic_shutdown)                          DEVMETHOD(device_shutdown, bus_generic_shutdown)
                         );                          );
   
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
 MODULE_VERSION(usb, 1);  MODULE_VERSION(usb, 1);
 #endif  #endif
   
Line 214  USB_ATTACH(usb) Line 214  USB_ATTACH(usb)
 {  {
 #if defined(__NetBSD__) || defined(__OpenBSD__)  #if defined(__NetBSD__) || defined(__OpenBSD__)
         struct usb_softc *sc = (struct usb_softc *)self;          struct usb_softc *sc = (struct usb_softc *)self;
#elif defined(__FreeBSD__)#elif defined(__FreeBSD__) || defined(__DragonFly__)
         struct usb_softc *sc = device_get_softc(self);          struct usb_softc *sc = device_get_softc(self);
         void *aux = device_get_ivars(self);          void *aux = device_get_ivars(self);
         static int global_init_done = 0;          static int global_init_done = 0;
Line 234  USB_ATTACH(usb) Line 234  USB_ATTACH(usb)
         sc->sc_bus->usbctl = sc;          sc->sc_bus->usbctl = sc;
         sc->sc_port.power = USB_MAX_POWER;          sc->sc_port.power = USB_MAX_POWER;
   
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
         printf("%s", USBDEVNAME(sc->sc_dev));          printf("%s", USBDEVNAME(sc->sc_dev));
 #endif  #endif
         usbrev = sc->sc_bus->usbrev;          usbrev = sc->sc_bus->usbrev;
Line 293  USB_ATTACH(usb) Line 293  USB_ATTACH(usb)
                  * until the USB event thread is running, which means that                   * until the USB event thread is running, which means that
                  * the keyboard will not work until after cold boot.                   * the keyboard will not work until after cold boot.
                  */                   */
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
                 if (cold)                  if (cold)
 #else  #else
                 if (cold && (sc->sc_dev.dv_cfdata->cf_flags & 1))                  if (cold && (sc->sc_dev.dv_cfdata->cf_flags & 1))
Line 313  USB_ATTACH(usb) Line 313  USB_ATTACH(usb)
         usb_kthread_create(usb_create_event_thread, sc);          usb_kthread_create(usb_create_event_thread, sc);
 #endif  #endif
   
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
         usb_create_event_thread(sc);          usb_create_event_thread(sc);
         /* The per controller devices (used for usb_discover) */          /* The per controller devices (used for usb_discover) */
         /* XXX This is redundant now, but old usbd's will want it */          /* XXX This is redundant now, but old usbd's will want it */
Line 580  usbioctl(dev_t devt, u_long cmd, caddr_t Line 580  usbioctl(dev_t devt, u_long cmd, caddr_t
                 return (EIO);                  return (EIO);
   
         switch (cmd) {          switch (cmd) {
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
         /* This part should be deleted */          /* This part should be deleted */
         case USB_DISCOVER:          case USB_DISCOVER:
                 break;                  break;
Line 685  usbpoll(dev_t dev, int events, usb_proc_ Line 685  usbpoll(dev_t dev, int events, usb_proc_
   
                 return (revents);                  return (revents);
         } else {          } else {
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
                 return (0);     /* select/poll never wakes up - back compat */                  return (0);     /* select/poll never wakes up - back compat */
 #else  #else
                 return (ENXIO);                  return (ENXIO);
Line 699  usb_discover(void *v) Line 699  usb_discover(void *v)
 {  {
         struct usb_softc *sc = v;          struct usb_softc *sc = v;
   
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
         /* splxxx should be changed to mutexes for preemption safety some day */          /* splxxx should be changed to mutexes for preemption safety some day */
         int s;          int s;
 #endif  #endif
Line 715  usb_discover(void *v) Line 715  usb_discover(void *v)
          * but this is guaranteed since this function is only called           * but this is guaranteed since this function is only called
          * from the event thread for the controller.           * from the event thread for the controller.
          */           */
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
         s = splusb();          s = splusb();
 #endif  #endif
         while (sc->sc_bus->needs_explore && !sc->sc_dying) {          while (sc->sc_bus->needs_explore && !sc->sc_dying) {
                 sc->sc_bus->needs_explore = 0;                  sc->sc_bus->needs_explore = 0;
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
                 splx(s);                  splx(s);
 #endif  #endif
                 sc->sc_bus->root_hub->hub->explore(sc->sc_bus->root_hub);                  sc->sc_bus->root_hub->hub->explore(sc->sc_bus->root_hub);
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
                 s = splusb();                  s = splusb();
 #endif  #endif
         }          }
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
         splx(s);          splx(s);
 #endif  #endif
 }  }
Line 916  usb_detach(device_ptr_t self, int flags) Line 916  usb_detach(device_ptr_t self, int flags)
   
         return (0);          return (0);
 }  }
#elif defined(__FreeBSD__)#elif defined(__FreeBSD__) || defined(__DragonFly__)
 int  int
 usb_detach(device_t self)  usb_detach(device_t self)
 {  {
Line 927  usb_detach(device_t self) Line 927  usb_detach(device_t self)
 #endif  #endif
   
   
#if defined(__FreeBSD__)#if defined(__FreeBSD__) || defined(__DragonFly__)
 DRIVER_MODULE(usb, ohci, usb_driver, usb_devclass, 0, 0);  DRIVER_MODULE(usb, ohci, usb_driver, usb_devclass, 0, 0);
 DRIVER_MODULE(usb, uhci, usb_driver, usb_devclass, 0, 0);  DRIVER_MODULE(usb, uhci, usb_driver, usb_devclass, 0, 0);
 DRIVER_MODULE(usb, ehci, usb_driver, usb_devclass, 0, 0);  DRIVER_MODULE(usb, ehci, usb_driver, usb_devclass, 0, 0);

Removed from v.1.10  
changed lines
  Added in v.1.11