1 /* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */
4 * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama@jp.FreeBSD.org>.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
33 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
34 * All rights reserved.
36 * This code is derived from software contributed to The NetBSD Foundation
37 * by Lennart Augustsson (lennart@augustsson.net) at
38 * Carlstedt Research & Technology.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. All advertising materials mentioning features or use of this software
49 * must display the following acknowledgement:
50 * This product includes software developed by the NetBSD
51 * Foundation, Inc. and its contributors.
52 * 4. Neither the name of The NetBSD Foundation nor the names of its
53 * contributors may be used to endorse or promote products derived
54 * from this software without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
57 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
58 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
60 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
61 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
62 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
63 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
64 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
66 * POSSIBILITY OF SUCH DAMAGE.
69 #include <sys/param.h>
70 #include <sys/systm.h>
71 #include <sys/kernel.h>
72 #include <sys/malloc.h>
73 #include <sys/module.h>
75 #include <sys/ioccom.h>
76 #include <sys/fcntl.h>
78 #include <sys/serial.h>
80 #include <sys/clist.h>
82 #if __FreeBSD_version >= 500014
83 #include <sys/selinfo.h>
85 #include <sys/select.h>
89 #include <sys/sysctl.h>
91 #include <dev/usb/usb.h>
92 #include <dev/usb/usbcdc.h>
94 #include <dev/usb/usbdi.h>
95 #include <dev/usb/usbdi_util.h>
97 #include <dev/usb/usb_quirks.h>
99 #include <dev/usb/ucomvar.h>
102 static int ucomdebug = 0;
103 SYSCTL_NODE(_hw_usb, OID_AUTO, ucom, CTLFLAG_RW, 0, "USB ucom");
104 SYSCTL_INT(_hw_usb_ucom, OID_AUTO, debug, CTLFLAG_RW,
105 &ucomdebug, 0, "ucom debug level");
106 #define DPRINTF(x) do { \
111 #define DPRINTFN(n, x) do { \
112 if (ucomdebug > (n)) \
117 #define DPRINTFN(n, x)
120 static void ucom_cleanup(struct ucom_softc *);
121 static int ucomparam(struct tty *, struct termios *);
122 static void ucomstart(struct tty *);
123 static void ucomstop(struct tty *, int);
124 static void ucom_shutdown(struct ucom_softc *);
125 static void ucom_dtr(struct ucom_softc *, int);
126 static void ucom_rts(struct ucom_softc *, int);
127 static void ucombreak(struct tty *, int);
128 static usbd_status ucomstartread(struct ucom_softc *);
129 static void ucomreadcb(usbd_xfer_handle, usbd_private_handle, usbd_status);
130 static void ucomwritecb(usbd_xfer_handle, usbd_private_handle, usbd_status);
131 static void ucomstopread(struct ucom_softc *);
133 static t_open_t ucomopen;
134 static t_close_t ucomclose;
135 static t_modem_t ucommodem;
136 static t_ioctl_t ucomioctl;
138 devclass_t ucom_devclass;
140 static moduledata_t ucom_mod = {
146 DECLARE_MODULE(ucom, ucom_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
147 MODULE_DEPEND(ucom, usb, 1, 1, 1);
148 MODULE_VERSION(ucom, UCOM_MODVER);
151 ucom_attach(struct ucom_softc *sc)
156 unit = device_get_unit(sc->sc_dev);
158 sc->sc_tty = tp = ttyalloc();
160 tp->t_oproc = ucomstart;
161 tp->t_param = ucomparam;
162 tp->t_stop = ucomstop;
163 tp->t_break = ucombreak;
164 tp->t_open = ucomopen;
165 tp->t_close = ucomclose;
166 tp->t_modem = ucommodem;
167 tp->t_ioctl = ucomioctl;
169 DPRINTF(("ucom_attach: tty_attach tp = %p\n", tp));
171 ttycreate(tp, TS_CALLOUT, "U%d", unit);
172 DPRINTF(("ucom_attach: ttycreate: ttyU%d\n", unit));
178 ucom_detach(struct ucom_softc *sc)
182 DPRINTF(("ucom_detach: sc = %p, tp = %p\n", sc, sc->sc_tty));
186 if (sc->sc_tty->t_state & TS_ISOPEN)
187 ucomclose(sc->sc_tty);
189 if (sc->sc_bulkin_pipe != NULL)
190 usbd_abort_pipe(sc->sc_bulkin_pipe);
191 if (sc->sc_bulkout_pipe != NULL)
192 usbd_abort_pipe(sc->sc_bulkout_pipe);
203 ucom_shutdown(struct ucom_softc *sc)
205 struct tty *tp = sc->sc_tty;
207 DPRINTF(("ucom_shutdown\n"));
209 * Hang up if necessary. Wait a bit, so the other side has time to
210 * notice even if we immediately open the port again.
212 if (ISSET(tp->t_cflag, HUPCL)) {
213 (void)ucommodem(tp, 0, SER_DTR);
214 (void)tsleep(sc, TTIPRI, "ucomsd", hz);
219 ucomopen(struct tty *tp, struct cdev *dev)
221 struct ucom_softc *sc;
230 DPRINTF(("%s: ucomopen: tp = %p\n", device_get_nameunit(sc->sc_dev), tp));
233 sc->sc_lsr = sc->sc_msr = sc->sc_mcr = 0;
235 (void)ucommodem(tp, SER_DTR | SER_RTS, 0);
237 /* Device specific open */
238 if (sc->sc_callback->ucom_open != NULL) {
239 error = sc->sc_callback->ucom_open(sc->sc_parent,
247 DPRINTF(("ucomopen: open pipes in = %d out = %d\n",
248 sc->sc_bulkin_no, sc->sc_bulkout_no));
250 /* Open the bulk pipes */
252 err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkin_no, 0,
253 &sc->sc_bulkin_pipe);
255 printf("%s: open bulk in error (addr %d): %s\n",
256 device_get_nameunit(sc->sc_dev), sc->sc_bulkin_no,
262 err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_no,
263 USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe);
265 printf("%s: open bulk out error (addr %d): %s\n",
266 device_get_nameunit(sc->sc_dev), sc->sc_bulkout_no,
272 /* Allocate a request and an input buffer and start reading. */
273 sc->sc_ixfer = usbd_alloc_xfer(sc->sc_udev);
274 if (sc->sc_ixfer == NULL) {
279 sc->sc_ibuf = usbd_alloc_buffer(sc->sc_ixfer,
281 if (sc->sc_ibuf == NULL) {
286 sc->sc_oxfer = usbd_alloc_xfer(sc->sc_udev);
287 if (sc->sc_oxfer == NULL) {
292 sc->sc_obuf = usbd_alloc_buffer(sc->sc_oxfer,
295 if (sc->sc_obuf == NULL) {
300 sc->sc_state |= UCS_RXSTOP;
313 ucomclose(struct tty *tp)
315 struct ucom_softc *sc;
319 DPRINTF(("%s: ucomclose \n", device_get_nameunit(sc->sc_dev)));
323 if (sc->sc_callback->ucom_close != NULL)
324 sc->sc_callback->ucom_close(sc->sc_parent, sc->sc_portno);
328 ucomioctl(struct tty *tp, u_long cmd, void *data, int flag, usb_proc_ptr p)
330 struct ucom_softc *sc;
337 DPRINTF(("ucomioctl: cmd = 0x%08lx\n", cmd));
340 if (sc->sc_callback->ucom_ioctl != NULL)
341 error = sc->sc_callback->ucom_ioctl(sc->sc_parent,
348 ucommodem(struct tty *tp, int sigon, int sigoff)
350 struct ucom_softc *sc;
357 if (sigon == 0 && sigoff == 0) {
359 if (ISSET(mcr, SER_DTR))
361 if (ISSET(mcr, SER_RTS))
365 if (ISSET(msr, SER_CTS))
367 if (ISSET(msr, SER_DCD))
369 if (ISSET(msr, SER_DSR))
371 if (ISSET(msr, SER_RI))
377 if (ISSET(sigon, SER_DTR))
379 if (ISSET(sigoff, SER_DTR))
381 if (ISSET(sigon, SER_RTS))
383 if (ISSET(sigoff, SER_RTS))
387 onoff = ISSET(sc->sc_mcr, SER_DTR) ? 1 : 0;
390 onoff = ISSET(sc->sc_mcr, SER_RTS) ? 1 : 0;
397 ucombreak(struct tty *tp, int onoff)
399 struct ucom_softc *sc;
402 DPRINTF(("ucombreak: onoff = %d\n", onoff));
403 if (sc->sc_callback->ucom_set == NULL)
405 sc->sc_callback->ucom_set(sc->sc_parent, sc->sc_portno,
406 UCOM_SET_BREAK, onoff);
410 ucom_dtr(struct ucom_softc *sc, int onoff)
412 DPRINTF(("ucom_dtr: onoff = %d\n", onoff));
414 if (sc->sc_callback->ucom_set == NULL)
416 sc->sc_callback->ucom_set(sc->sc_parent, sc->sc_portno,
417 UCOM_SET_DTR, onoff);
421 ucom_rts(struct ucom_softc *sc, int onoff)
423 DPRINTF(("ucom_rts: onoff = %d\n", onoff));
425 if (sc->sc_callback->ucom_set == NULL)
427 sc->sc_callback->ucom_set(sc->sc_parent, sc->sc_portno,
428 UCOM_SET_RTS, onoff);
432 ucom_status_change(struct ucom_softc *sc)
434 struct tty *tp = sc->sc_tty;
438 if (sc->sc_callback->ucom_get_status == NULL) {
444 old_msr = sc->sc_msr;
445 sc->sc_callback->ucom_get_status(sc->sc_parent, sc->sc_portno,
446 &sc->sc_lsr, &sc->sc_msr);
447 if (ISSET((sc->sc_msr ^ old_msr), SER_DCD)) {
448 if (sc->sc_poll == 0)
450 onoff = ISSET(sc->sc_msr, SER_DCD) ? 1 : 0;
451 DPRINTF(("ucom_status_change: DCD changed to %d\n", onoff));
452 ttyld_modem(tp, onoff);
457 ucomparam(struct tty *tp, struct termios *t)
459 struct ucom_softc *sc;
468 DPRINTF(("ucomparam: sc = %p\n", sc));
470 /* Check requested parameters. */
471 if (t->c_ospeed < 0) {
472 DPRINTF(("ucomparam: negative ospeed\n"));
475 if (t->c_ispeed && t->c_ispeed != t->c_ospeed) {
476 DPRINTF(("ucomparam: mismatch ispeed and ospeed\n"));
481 * If there were no changes, don't do anything. This avoids dropping
482 * input and improves performance when all we did was frob things like
485 if (tp->t_ospeed == t->c_ospeed &&
486 tp->t_cflag == t->c_cflag)
489 /* And copy to tty. */
491 tp->t_ospeed = t->c_ospeed;
492 tp->t_cflag = t->c_cflag;
494 if (sc->sc_callback->ucom_param == NULL)
499 error = sc->sc_callback->ucom_param(sc->sc_parent, sc->sc_portno, t);
501 DPRINTF(("ucomparam: callback: error = %d\n", error));
507 if (t->c_cflag & CRTS_IFLOW) {
508 sc->sc_state |= UCS_RTS_IFLOW;
509 } else if (sc->sc_state & UCS_RTS_IFLOW) {
510 sc->sc_state &= ~UCS_RTS_IFLOW;
511 (void)ucommodem(tp, SER_RTS, 0);
516 uerr = ucomstartread(sc);
517 if (uerr != USBD_NORMAL_COMPLETION)
524 ucomstart(struct tty *tp)
526 struct ucom_softc *sc;
534 DPRINTF(("ucomstart: sc = %p\n", sc));
541 if (tp->t_state & TS_TBLOCK) {
542 if (ISSET(sc->sc_mcr, SER_RTS) &&
543 ISSET(sc->sc_state, UCS_RTS_IFLOW)) {
544 DPRINTF(("ucomstart: clear RTS\n"));
545 (void)ucommodem(tp, 0, SER_RTS);
548 if (!ISSET(sc->sc_mcr, SER_RTS) &&
549 tp->t_rawq.c_cc <= tp->t_ilowat &&
550 ISSET(sc->sc_state, UCS_RTS_IFLOW)) {
551 DPRINTF(("ucomstart: set RTS\n"));
552 (void)ucommodem(tp, SER_RTS, 0);
556 if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP)) {
558 DPRINTF(("ucomstart: stopped\n"));
562 if (tp->t_outq.c_cc <= tp->t_olowat) {
563 if (ISSET(tp->t_state, TS_SO_OLOWAT)) {
564 CLR(tp->t_state, TS_SO_OLOWAT);
565 wakeup(TSA_OLOWAT(tp));
567 selwakeuppri(&tp->t_wsel, TTIPRI);
568 if (tp->t_outq.c_cc == 0) {
569 if (ISSET(tp->t_state, TS_BUSY | TS_SO_OCOMPLETE) ==
570 TS_SO_OCOMPLETE && tp->t_outq.c_cc == 0) {
571 CLR(tp->t_state, TS_SO_OCOMPLETE);
572 wakeup(TSA_OCOMPLETE(tp));
578 /* Grab the first contiguous region of buffer space. */
579 data = tp->t_outq.c_cf;
580 cbp = (struct cblock *) ((intptr_t) tp->t_outq.c_cf & ~CROUND);
581 cnt = min((char *) (cbp+1) - tp->t_outq.c_cf, tp->t_outq.c_cc);
584 DPRINTF(("ucomstart: cnt == 0\n"));
588 SET(tp->t_state, TS_BUSY);
590 if (cnt > sc->sc_obufsize) {
591 DPRINTF(("ucomstart: big buffer %d chars\n", cnt));
592 cnt = sc->sc_obufsize;
594 if (sc->sc_callback->ucom_write != NULL)
595 sc->sc_callback->ucom_write(sc->sc_parent, sc->sc_portno,
596 sc->sc_obuf, data, &cnt);
598 memcpy(sc->sc_obuf, data, cnt);
600 DPRINTF(("ucomstart: %d chars\n", cnt));
601 usbd_setup_xfer(sc->sc_oxfer, sc->sc_bulkout_pipe,
602 (usbd_private_handle)sc, sc->sc_obuf, cnt,
603 USBD_NO_COPY, USBD_NO_TIMEOUT, ucomwritecb);
604 /* What can we do on error? */
605 err = usbd_transfer(sc->sc_oxfer);
606 if (err != USBD_IN_PROGRESS)
607 printf("ucomstart: err=%s\n", usbd_errstr(err));
616 ucomstop(struct tty *tp, int flag)
618 struct ucom_softc *sc;
623 DPRINTF(("ucomstop: %d\n", flag));
625 if ((flag & FREAD) && (sc->sc_state & UCS_RXSTOP) == 0) {
626 DPRINTF(("ucomstop: read\n"));
632 DPRINTF(("ucomstop: write\n"));
634 if (ISSET(tp->t_state, TS_BUSY)) {
636 if (!ISSET(tp->t_state, TS_TTSTOP))
637 SET(tp->t_state, TS_FLUSH);
644 DPRINTF(("ucomstop: done\n"));
648 ucomwritecb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status)
650 struct ucom_softc *sc = (struct ucom_softc *)p;
651 struct tty *tp = sc->sc_tty;
655 DPRINTF(("ucomwritecb: status = %d\n", status));
657 if (status == USBD_CANCELLED || sc->sc_dying)
660 if (status != USBD_NORMAL_COMPLETION) {
661 printf("%s: ucomwritecb: %s\n",
662 device_get_nameunit(sc->sc_dev), usbd_errstr(status));
663 if (status == USBD_STALLED)
664 usbd_clear_endpoint_stall_async(sc->sc_bulkin_pipe);
665 /* XXX we should restart after some delay. */
669 usbd_get_xfer_status(xfer, NULL, NULL, &cc, NULL);
670 DPRINTF(("ucomwritecb: cc = %d\n", cc));
671 if (cc <= sc->sc_opkthdrlen) {
672 printf("%s: sent size too small, cc = %d\n",
673 device_get_nameunit(sc->sc_dev), cc);
677 /* convert from USB bytes to tty bytes */
678 cc -= sc->sc_opkthdrlen;
681 CLR(tp->t_state, TS_BUSY);
682 if (ISSET(tp->t_state, TS_FLUSH))
683 CLR(tp->t_state, TS_FLUSH);
685 ndflush(&tp->t_outq, cc);
693 CLR(tp->t_state, TS_BUSY);
699 ucomstartread(struct ucom_softc *sc)
703 DPRINTF(("ucomstartread: start\n"));
705 if (sc->sc_bulkin_pipe == NULL || (sc->sc_state & UCS_RXSTOP) == 0)
706 return (USBD_NORMAL_COMPLETION);
707 sc->sc_state &= ~UCS_RXSTOP;
709 usbd_setup_xfer(sc->sc_ixfer, sc->sc_bulkin_pipe,
710 (usbd_private_handle)sc,
711 sc->sc_ibuf, sc->sc_ibufsize,
712 USBD_SHORT_XFER_OK | USBD_NO_COPY,
713 USBD_NO_TIMEOUT, ucomreadcb);
715 err = usbd_transfer(sc->sc_ixfer);
716 if (err && err != USBD_IN_PROGRESS) {
717 sc->sc_state |= UCS_RXSTOP;
718 DPRINTF(("ucomstartread: err = %s\n", usbd_errstr(err)));
722 return (USBD_NORMAL_COMPLETION);
726 ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status)
728 struct ucom_softc *sc = (struct ucom_softc *)p;
729 struct tty *tp = sc->sc_tty;
736 DPRINTF(("ucomreadcb: status = %d\n", status));
738 if (status != USBD_NORMAL_COMPLETION) {
739 if (!(sc->sc_state & UCS_RXSTOP))
740 printf("%s: ucomreadcb: %s\n",
741 device_get_nameunit(sc->sc_dev), usbd_errstr(status));
742 sc->sc_state |= UCS_RXSTOP;
743 if (status == USBD_STALLED)
744 usbd_clear_endpoint_stall_async(sc->sc_bulkin_pipe);
745 /* XXX we should restart after some delay. */
748 sc->sc_state |= UCS_RXSTOP;
750 usbd_get_xfer_status(xfer, NULL, (void **)&cp, &cc, NULL);
751 DPRINTF(("ucomreadcb: got %d chars, tp = %p\n", cc, tp));
755 if (sc->sc_callback->ucom_read != NULL)
756 sc->sc_callback->ucom_read(sc->sc_parent, sc->sc_portno,
759 if (cc > sc->sc_ibufsize) {
760 printf("%s: invalid receive data size, %d chars\n",
761 device_get_nameunit(sc->sc_dev), cc);
768 if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
769 if (tp->t_rawq.c_cc + cc > tp->t_ihiwat
770 && (sc->sc_state & UCS_RTS_IFLOW
771 || tp->t_iflag & IXOFF)
772 && !(tp->t_state & TS_TBLOCK))
774 lostcc = b_to_q((char *)cp, cc, &tp->t_rawq);
777 if (tp->t_state & TS_TTSTOP
778 && (tp->t_iflag & IXANY
779 || tp->t_cc[VSTART] == tp->t_cc[VSTOP])) {
780 tp->t_state &= ~TS_TTSTOP;
781 tp->t_lflag &= ~FLUSHO;
785 printf("%s: lost %d chars\n", device_get_nameunit(sc->sc_dev),
788 /* Give characters to tty layer. */
790 DPRINTFN(7, ("ucomreadcb: char = 0x%02x\n", *cp));
791 if (ttyld_rint(tp, *cp) == -1) {
792 /* XXX what should we do? */
793 printf("%s: lost %d chars\n",
794 device_get_nameunit(sc->sc_dev), cc);
804 err = ucomstartread(sc);
806 printf("%s: read start failed\n", device_get_nameunit(sc->sc_dev));
807 /* XXX what should we dow now? */
810 if ((sc->sc_state & UCS_RTS_IFLOW) && !ISSET(sc->sc_mcr, SER_RTS)
811 && !(tp->t_state & TS_TBLOCK))
812 ucommodem(tp, SER_RTS, 0);
816 ucom_cleanup(struct ucom_softc *sc)
818 DPRINTF(("ucom_cleanup: closing pipes\n"));
821 if (sc->sc_bulkin_pipe != NULL) {
822 sc->sc_state |= UCS_RXSTOP;
823 usbd_abort_pipe(sc->sc_bulkin_pipe);
824 usbd_close_pipe(sc->sc_bulkin_pipe);
825 sc->sc_bulkin_pipe = NULL;
827 if (sc->sc_bulkout_pipe != NULL) {
828 usbd_abort_pipe(sc->sc_bulkout_pipe);
829 usbd_close_pipe(sc->sc_bulkout_pipe);
830 sc->sc_bulkout_pipe = NULL;
832 if (sc->sc_ixfer != NULL) {
833 usbd_free_xfer(sc->sc_ixfer);
836 if (sc->sc_oxfer != NULL) {
837 usbd_free_xfer(sc->sc_oxfer);
843 ucomstopread(struct ucom_softc *sc)
847 DPRINTF(("ucomstopread: enter\n"));
849 if (!(sc->sc_state & UCS_RXSTOP)) {
850 sc->sc_state |= UCS_RXSTOP;
851 if (sc->sc_bulkin_pipe == NULL) {
852 DPRINTF(("ucomstopread: bulkin pipe NULL\n"));
855 err = usbd_abort_pipe(sc->sc_bulkin_pipe);
857 DPRINTF(("ucomstopread: err = %s\n",
862 DPRINTF(("ucomstopread: leave\n"));