diff options
author | julian <julian@FreeBSD.org> | 2004-12-13 07:45:02 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2004-12-13 07:45:02 +0000 |
commit | fa3c9e1494023c17cefb5dbc5201185c0046a8b6 (patch) | |
tree | 94b6d3d6c9c6d567ffb86b7446ba1f828cc1c062 /sys/dev | |
parent | 4e2d779c7a83fcfe199d376127355445accd0123 (diff) | |
download | FreeBSD-src-fa3c9e1494023c17cefb5dbc5201185c0046a8b6.zip FreeBSD-src-fa3c9e1494023c17cefb5dbc5201185c0046a8b6.tar.gz |
MFNetBSD
Whitespace diff reduction, formatting fixes and one actual
arithmetic error that NetBSD have fixed.
Obtained from: NetBSD
MFC after: 1 week
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/ugen.c | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index bc0c27a..05e7ade 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -28,8 +28,8 @@ __FBSDID("$FreeBSD$"); * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. * 4. Neither the name of The NetBSD Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. @@ -546,10 +546,10 @@ ugenopen(struct cdev *dev, int flag, int mode, usb_proc_ptr p) if (clalloc(&sce->q, UGEN_IBSIZE, 0) == -1) return (ENOMEM); err = usbd_open_pipe_intr(sce->iface, - edesc->bEndpointAddress, - USBD_SHORT_XFER_OK, &sce->pipeh, sce, - sce->ibuf, isize, ugenintr, - USBD_DEFAULT_INTERVAL); + edesc->bEndpointAddress, + USBD_SHORT_XFER_OK, &sce->pipeh, sce, + sce->ibuf, isize, ugenintr, + USBD_DEFAULT_INTERVAL); if (err) { free(sce->ibuf, M_USBDEV); clfree(&sce->q); @@ -633,12 +633,6 @@ ugenclose(struct cdev *dev, int flag, int mode, usb_proc_ptr p) DPRINTFN(5, ("ugenclose: flag=%d, mode=%d, unit=%d, endpt=%d\n", flag, mode, UGENUNIT(dev), endpt)); - -#if defined(__NetBSD__) || defined(__OpenBSD__) - if (sc->sc_dying) - wakeup(&sc->sc_dying); -#endif - #ifdef DIAGNOSTIC if (!sc->sc_is_open[endpt]) { printf("ugenclose: not open\n"); @@ -674,6 +668,7 @@ ugenclose(struct cdev *dev, int flag, int mode, usb_proc_ptr p) case UE_ISOCHRONOUS: for (i = 0; i < UGEN_NISOREQS; ++i) usbd_free_xfer(sce->isoreqs[i].xfer); + default: break; } @@ -710,6 +705,7 @@ ugen_do_read(struct ugen_softc *sc, int endpt, struct uio *uio, int flag) if (endpt == USB_CONTROL_ENDPOINT) return (ENODEV); +#ifdef DIAGNOSTIC if (sce->edesc == NULL) { printf("ugenread: no edesc\n"); return (EIO); @@ -718,6 +714,7 @@ ugen_do_read(struct ugen_softc *sc, int endpt, struct uio *uio, int flag) printf("ugenread: no pipe\n"); return (EIO); } +#endif switch (sce->edesc->bmAttributes & UE_XFERTYPE) { case UE_INTERRUPT: @@ -758,32 +755,32 @@ ugen_do_read(struct ugen_softc *sc, int endpt, struct uio *uio, int flag) } break; case UE_BULK: - xfer = usbd_alloc_xfer(sc->sc_udev); - if (xfer == 0) - return (ENOMEM); - while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) { + xfer = usbd_alloc_xfer(sc->sc_udev); + if (xfer == 0) + return (ENOMEM); + while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) { DPRINTFN(1, ("ugenread: start transfer %d bytes\n",n)); tn = n; - err = usbd_bulk_transfer( - xfer, sce->pipeh, - sce->state & UGEN_SHORT_OK ? - USBD_SHORT_XFER_OK : 0, - sce->timeout, buf, &tn, "ugenrb"); - if (err) { - if (err == USBD_INTERRUPTED) - error = EINTR; - else if (err == USBD_TIMEOUT) - error = ETIMEDOUT; - else - error = EIO; - break; - } - DPRINTFN(1, ("ugenread: got %d bytes\n", tn)); - error = uiomove(buf, tn, uio); - if (error || tn < n) - break; - } - usbd_free_xfer(xfer); + err = usbd_bulk_transfer( + xfer, sce->pipeh, + sce->state & UGEN_SHORT_OK ? + USBD_SHORT_XFER_OK : 0, + sce->timeout, buf, &tn, "ugenrb"); + if (err) { + if (err == USBD_INTERRUPTED) + error = EINTR; + else if (err == USBD_TIMEOUT) + error = ETIMEDOUT; + else + error = EIO; + break; + } + DPRINTFN(1, ("ugenread: got %d bytes\n", tn)); + error = uiomove(buf, tn, uio); + if (error || tn < n) + break; + } + usbd_free_xfer(xfer); break; case UE_ISOCHRONOUS: s = splusb(); @@ -863,6 +860,7 @@ ugen_do_write(struct ugen_softc *sc, int endpt, struct uio *uio, int flag) if (endpt == USB_CONTROL_ENDPOINT) return (ENODEV); +#ifdef DIAGNOSTIC if (sce->edesc == NULL) { printf("ugenwrite: no edesc\n"); return (EIO); @@ -871,6 +869,7 @@ ugen_do_write(struct ugen_softc *sc, int endpt, struct uio *uio, int flag) printf("ugenwrite: no pipe\n"); return (EIO); } +#endif switch (sce->edesc->bmAttributes & UE_XFERTYPE) { case UE_BULK: @@ -907,7 +906,7 @@ ugen_do_write(struct ugen_softc *sc, int endpt, struct uio *uio, int flag) break; DPRINTFN(1, ("ugenwrite: transfer %d bytes\n", n)); err = usbd_intr_transfer(xfer, sce->pipeh, 0, - sce->timeout, buf, &n,"ugenwi"); + sce->timeout, buf, &n, "ugenwi"); if (err) { if (err == USBD_INTERRUPTED) error = EINTR; @@ -1098,7 +1097,7 @@ ugen_isoc_rintr(usbd_xfer_handle xfer, usbd_private_handle addr, if(sce->fill < sce->cur && sce->cur <= sce->fill + count) { sce->cur += count; if(sce->cur >= sce->limit) - sce->cur = sce->ibuf + (sce->cur - sce->limit); + sce->cur = sce->ibuf + (sce->limit - sce->cur); DPRINTFN(5, ("ugen_isoc_rintr: throwing away %d bytes\n", count)); } @@ -1290,9 +1289,9 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, /* All handled in the upper FS layer. */ return (0); case USB_SET_SHORT_XFER: - /* This flag only affects read */ if (endpt == USB_CONTROL_ENDPOINT) return (EINVAL); + /* This flag only affects read */ sce = &sc->sc_endpoints[endpt][IN]; if (sce->pipeh == NULL) { @@ -1366,7 +1365,8 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, ai->uai_interface_index, &iface); if (err) return (EINVAL); - err = ugen_set_interface(sc, ai->uai_interface_index, ai->uai_alt_no); + err = ugen_set_interface(sc, ai->uai_interface_index, + ai->uai_alt_no); if (err) return (EINVAL); break; @@ -1380,7 +1380,8 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd, free(cdesc, M_TEMP); return (EINVAL); } - ai->uai_alt_no = usbd_get_no_alts(cdesc, idesc->bInterfaceNumber); + ai->uai_alt_no = usbd_get_no_alts(cdesc, + idesc->bInterfaceNumber); free(cdesc, M_TEMP); break; case USB_GET_DEVICE_DESC: @@ -1566,7 +1567,7 @@ ugenpoll(struct cdev *dev, int events, usb_proc_ptr p) /* XXX always IN */ sce = &sc->sc_endpoints[UGENENDPOINT(dev)][IN]; - +#ifdef DIAGNOSTIC if (!sce->edesc) { printf("ugenpoll: no edesc\n"); return (EIO); @@ -1575,7 +1576,7 @@ ugenpoll(struct cdev *dev, int events, usb_proc_ptr p) printf("ugenpoll: no pipe\n"); return (EIO); } - +#endif s = splusb(); switch (sce->edesc->bmAttributes & UE_XFERTYPE) { case UE_INTERRUPT: |