Diff for /src/sys/dev/usbmisc/uscanner/uscanner.c between versions 1.5 and 1.6

version 1.5, 2003/12/29 06:42:21 version 1.6, 2003/12/30 01:01:48
Line 1 Line 1
 /*   /* 
 * $NetBSD: uscanner.c,v 1.26 2001/12/31 12:15:22 augustss Exp $ * $NetBSD: uscanner.c,v 1.30 2002/07/11 21:14:36 augustss Exp $
 * $FreeBSD: src/sys/dev/usb/uscanner.c,v 1.2.2.16 2003/12/22 20:00:55 sanpei Exp $ * $FreeBSD: src/sys/dev/usb/uscanner.c,v 1.48 2003/12/22 19:58:27 sanpei Exp $
  * $DragonFly$   * $DragonFly$
  */   */
   
   /* Also already merged from NetBSD:
    *      $NetBSD: uscanner.c,v 1.33 2002/09/23 05:51:24 simonb Exp $
    */
   
 /*  /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.   * Copyright (c) 2000 The NetBSD Foundation, Inc.
  * All rights reserved.   * All rights reserved.
Line 58 Line 62
 #endif  #endif
 #include <sys/tty.h>  #include <sys/tty.h>
 #include <sys/file.h>  #include <sys/file.h>
   #if __FreeBSD_version >= 500014
   #include <sys/selinfo.h>
   #else
 #include <sys/select.h>  #include <sys/select.h>
   #endif
 #include <sys/proc.h>  #include <sys/proc.h>
 #include <sys/vnode.h>  #include <sys/vnode.h>
 #include <sys/poll.h>  #include <sys/poll.h>
Line 194  static const struct uscan_info uscanner_ Line 202  static const struct uscan_info uscanner_
  {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1220U }, 0 },   {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1220U }, 0 },
  {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1236U }, 0 },   {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1236U }, 0 },
  {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2000U }, 0 },   {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2000U }, 0 },
    {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2100U }, 0 },
  {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2200U }, 0 },   {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA2200U }, 0 },
  {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA3400 }, 0 },   {{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA3400 }, 0 },
   
Line 218  struct uscanner_softc { Line 227  struct uscanner_softc {
         USBBASEDEVICE           sc_dev;         /* base device */          USBBASEDEVICE           sc_dev;         /* base device */
         usbd_device_handle      sc_udev;          usbd_device_handle      sc_udev;
         usbd_interface_handle   sc_iface;          usbd_interface_handle   sc_iface;
   #if defined(__FreeBSD__)
           dev_t                   dev;
   #endif
   
         u_int                   sc_dev_flags;          u_int                   sc_dev_flags;
   
Line 249  d_open_t  uscanneropen; Line 261  d_open_t  uscanneropen;
 d_close_t uscannerclose;  d_close_t uscannerclose;
 d_read_t  uscannerread;  d_read_t  uscannerread;
 d_write_t uscannerwrite;  d_write_t uscannerwrite;
 d_ioctl_t uscannerioctl;  
 d_poll_t  uscannerpoll;  d_poll_t  uscannerpoll;
   
 #define USCANNER_CDEV_MAJOR     156  #define USCANNER_CDEV_MAJOR     156
Line 265  Static struct cdevsw uscanner_cdevsw = { Line 276  Static struct cdevsw uscanner_cdevsw = {
         /* close */     uscannerclose,          /* close */     uscannerclose,
         /* read */      uscannerread,          /* read */      uscannerread,
         /* write */     uscannerwrite,          /* write */     uscannerwrite,
        /* ioctl */     uscannerioctl,        /* ioctl */     noioctl,
         /* poll */      uscannerpoll,          /* poll */      uscannerpoll,
         /* mmap */      nommap,          /* mmap */      nommap,
         /* strategy */  nostrategy,          /* strategy */  nostrategy,
Line 360  USB_ATTACH(uscanner) Line 371  USB_ATTACH(uscanner)
   
 #ifdef __FreeBSD__  #ifdef __FreeBSD__
         /* the main device, ctrl endpoint */          /* the main device, ctrl endpoint */
        make_dev(&uscanner_cdevsw, USBDEVUNIT(sc->sc_dev),        sc->dev = make_dev(&uscanner_cdevsw, USBDEVUNIT(sc->sc_dev),
                 UID_ROOT, GID_OPERATOR, 0644, "%s", USBDEVNAME(sc->sc_dev));                  UID_ROOT, GID_OPERATOR, 0644, "%s", USBDEVNAME(sc->sc_dev));
 #endif  #endif
   
           usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
                              USBDEV(sc->sc_dev));
   
         USB_ATTACH_SUCCESS_RETURN;          USB_ATTACH_SUCCESS_RETURN;
 }  }
   
Line 376  uscanneropen(dev_t dev, int flag, int mo Line 390  uscanneropen(dev_t dev, int flag, int mo
   
         USB_GET_SC_OPEN(uscanner, unit, sc);          USB_GET_SC_OPEN(uscanner, unit, sc);
   
        DPRINTFN(5, ("uscanneropen: flag=%d, mode=%d, unit=%d\n",         DPRINTFN(5, ("uscanneropen: flag=%d, mode=%d, unit=%d\n",
                      flag, mode, unit));                       flag, mode, unit));
   
         if (sc->sc_dying)          if (sc->sc_dying)
Line 602  uscanner_activate(device_ptr_t self, enu Line 616  uscanner_activate(device_ptr_t self, enu
         switch (act) {          switch (act) {
         case DVACT_ACTIVATE:          case DVACT_ACTIVATE:
                 return (EOPNOTSUPP);                  return (EOPNOTSUPP);
                 break;  
   
         case DVACT_DEACTIVATE:          case DVACT_DEACTIVATE:
                 sc->sc_dying = 1;                  sc->sc_dying = 1;
Line 618  USB_DETACH(uscanner) Line 631  USB_DETACH(uscanner)
         int s;          int s;
 #if defined(__NetBSD__) || defined(__OpenBSD__)  #if defined(__NetBSD__) || defined(__OpenBSD__)
         int maj, mn;          int maj, mn;
 #elif defined(__FreeBSD__)  
         dev_t dev;  
         struct vnode *vp;  
 #endif  #endif
   
 #if defined(__NetBSD__) || defined(__OpenBSD__)  #if defined(__NetBSD__) || defined(__OpenBSD__)
Line 656  USB_DETACH(uscanner) Line 666  USB_DETACH(uscanner)
         vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR);          vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR);
 #elif defined(__FreeBSD__)  #elif defined(__FreeBSD__)
         /* destroy the device for the control endpoint */          /* destroy the device for the control endpoint */
        dev = makedev(USCANNER_CDEV_MAJOR, USBDEVUNIT(sc->sc_dev));        destroy_dev(sc->dev);
        vp = SLIST_FIRST(&dev->si_hlist); 
        if (vp) 
                VOP_REVOKE(vp, REVOKEALL); 
        destroy_dev(dev); 
 #endif  #endif
   
           usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
                              USBDEV(sc->sc_dev));
   
         return (0);          return (0);
 }  }
   
Line 677  uscannerpoll(dev_t dev, int events, usb_ Line 686  uscannerpoll(dev_t dev, int events, usb_
         if (sc->sc_dying)          if (sc->sc_dying)
                 return (EIO);                  return (EIO);
   
        /*         /*
          * We have no easy way of determining if a read will           * We have no easy way of determining if a read will
          * yield any data or a write will happen.           * yield any data or a write will happen.
          * Pretend they will.           * Pretend they will.
          */           */
        revents |= events &         revents |= events &
                    (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM);                     (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM);
   
         return (revents);          return (revents);
 }  }
   
 int  
 uscannerioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, usb_proc_ptr p)  
 {  
         return (EINVAL);  
 }  
   
 #if defined(__FreeBSD__)  #if defined(__FreeBSD__)
 DRIVER_MODULE(uscanner, uhub, uscanner_driver, uscanner_devclass, usbd_driver_load, 0);  DRIVER_MODULE(uscanner, uhub, uscanner_driver, uscanner_devclass, usbd_driver_load, 0);
 #endif  #endif

Removed from v.1.5  
changed lines
  Added in v.1.6