usb_serial.c (192502) | usb_serial.c (192820) |
---|---|
1/* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */ 2 3/*- 4 * Copyright (c) 2001-2003, 2005, 2008 5 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/* $NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $ */ 2 3/*- 4 * Copyright (c) 2001-2003, 2005, 2008 5 * Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 192502 2009-05-21 01:48:42Z thompsa $"); | 31__FBSDID("$FreeBSD: head/sys/dev/usb/serial/usb_serial.c 192820 2009-05-26 17:06:36Z thompsa $"); |
32 33/*- 34 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. 35 * All rights reserved. 36 * 37 * This code is derived from software contributed to The NetBSD Foundation 38 * by Lennart Augustsson (lennart@augustsson.net) at 39 * Carlstedt Research & Technology. --- 544 unchanged lines hidden (view full) --- 584{ 585 struct usb2_com_cfg_task *task = 586 (struct usb2_com_cfg_task *)_task; 587 struct usb2_com_softc *sc = task->sc; 588 589 DPRINTF("\n"); 590 591 if (sc->sc_flag & UCOM_FLAG_LL_READY) { | 32 33/*- 34 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. 35 * All rights reserved. 36 * 37 * This code is derived from software contributed to The NetBSD Foundation 38 * by Lennart Augustsson (lennart@augustsson.net) at 39 * Carlstedt Research & Technology. --- 544 unchanged lines hidden (view full) --- 584{ 585 struct usb2_com_cfg_task *task = 586 (struct usb2_com_cfg_task *)_task; 587 struct usb2_com_softc *sc = task->sc; 588 589 DPRINTF("\n"); 590 591 if (sc->sc_flag & UCOM_FLAG_LL_READY) { |
592 593 sc->sc_flag &= ~(UCOM_FLAG_LL_READY | 594 UCOM_FLAG_GP_DATA); 595 596 if (sc->sc_callback->usb2_com_cfg_close) { | 592 sc->sc_flag &= ~UCOM_FLAG_LL_READY; 593 if (sc->sc_callback->usb2_com_cfg_close) |
597 (sc->sc_callback->usb2_com_cfg_close) (sc); | 594 (sc->sc_callback->usb2_com_cfg_close) (sc); |
598 } | |
599 } else { 600 /* already closed */ 601 } 602} 603 604static void 605usb2_com_close(struct tty *tp) 606{ --- 8 unchanged lines hidden (view full) --- 615 return; 616 } 617 usb2_com_shutdown(sc); 618 619 usb2_com_queue_command(sc, usb2_com_cfg_close, NULL, 620 &sc->sc_close_task[0].hdr, 621 &sc->sc_close_task[1].hdr); 622 | 595 } else { 596 /* already closed */ 597 } 598} 599 600static void 601usb2_com_close(struct tty *tp) 602{ --- 8 unchanged lines hidden (view full) --- 611 return; 612 } 613 usb2_com_shutdown(sc); 614 615 usb2_com_queue_command(sc, usb2_com_cfg_close, NULL, 616 &sc->sc_close_task[0].hdr, 617 &sc->sc_close_task[1].hdr); 618 |
623 sc->sc_flag &= ~(UCOM_FLAG_HL_READY | 624 UCOM_FLAG_WR_START | 625 UCOM_FLAG_RTS_IFLOW); | 619 sc->sc_flag &= ~(UCOM_FLAG_HL_READY | UCOM_FLAG_RTS_IFLOW); |
626 627 if (sc->sc_callback->usb2_com_stop_read) { 628 (sc->sc_callback->usb2_com_stop_read) (sc); 629 } | 620 621 if (sc->sc_callback->usb2_com_stop_read) { 622 (sc->sc_callback->usb2_com_stop_read) (sc); 623 } |
630 if (sc->sc_callback->usb2_com_stop_write) { 631 (sc->sc_callback->usb2_com_stop_write) (sc); 632 } | |
633} 634 635static int 636usb2_com_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) 637{ 638 struct usb2_com_softc *sc = tty_softc(tp); 639 int error; 640 --- 359 unchanged lines hidden (view full) --- 1000 mtx_assert(sc->sc_mtx, MA_OWNED); 1001 1002 DPRINTF("sc = %p\n", sc); 1003 1004 if (!(sc->sc_flag & UCOM_FLAG_HL_READY)) { 1005 /* The higher layer is not ready */ 1006 return; 1007 } | 624} 625 626static int 627usb2_com_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) 628{ 629 struct usb2_com_softc *sc = tty_softc(tp); 630 int error; 631 --- 359 unchanged lines hidden (view full) --- 991 mtx_assert(sc->sc_mtx, MA_OWNED); 992 993 DPRINTF("sc = %p\n", sc); 994 995 if (!(sc->sc_flag & UCOM_FLAG_HL_READY)) { 996 /* The higher layer is not ready */ 997 return; 998 } |
1008 sc->sc_flag |= UCOM_FLAG_WR_START; 1009 | |
1010 usb2_com_start_transfers(sc); 1011} 1012 1013/*------------------------------------------------------------------------* 1014 * usb2_com_get_data 1015 * 1016 * Return values: 1017 * 0: No data is available. --- 5 unchanged lines hidden (view full) --- 1023{ 1024 struct usb2_page_search res; 1025 struct tty *tp = sc->sc_tty; 1026 uint32_t cnt; 1027 uint32_t offset_orig; 1028 1029 mtx_assert(sc->sc_mtx, MA_OWNED); 1030 | 999 usb2_com_start_transfers(sc); 1000} 1001 1002/*------------------------------------------------------------------------* 1003 * usb2_com_get_data 1004 * 1005 * Return values: 1006 * 0: No data is available. --- 5 unchanged lines hidden (view full) --- 1012{ 1013 struct usb2_page_search res; 1014 struct tty *tp = sc->sc_tty; 1015 uint32_t cnt; 1016 uint32_t offset_orig; 1017 1018 mtx_assert(sc->sc_mtx, MA_OWNED); 1019 |
1031 if ((!(sc->sc_flag & UCOM_FLAG_HL_READY)) || 1032 (!(sc->sc_flag & UCOM_FLAG_GP_DATA)) || 1033 (!(sc->sc_flag & UCOM_FLAG_WR_START))) { | 1020 if (tty_gone(tp) || 1021 !(sc->sc_flag & UCOM_FLAG_GP_DATA)) { |
1034 actlen[0] = 0; 1035 return (0); /* multiport device polling */ 1036 } 1037 offset_orig = offset; 1038 1039 while (len != 0) { 1040 1041 usb2_get_page(pc, offset, &res); --- 29 unchanged lines hidden (view full) --- 1071{ 1072 struct usb2_page_search res; 1073 struct tty *tp = sc->sc_tty; 1074 char *buf; 1075 uint32_t cnt; 1076 1077 mtx_assert(sc->sc_mtx, MA_OWNED); 1078 | 1022 actlen[0] = 0; 1023 return (0); /* multiport device polling */ 1024 } 1025 offset_orig = offset; 1026 1027 while (len != 0) { 1028 1029 usb2_get_page(pc, offset, &res); --- 29 unchanged lines hidden (view full) --- 1059{ 1060 struct usb2_page_search res; 1061 struct tty *tp = sc->sc_tty; 1062 char *buf; 1063 uint32_t cnt; 1064 1065 mtx_assert(sc->sc_mtx, MA_OWNED); 1066 |
1079 if ((!(sc->sc_flag & UCOM_FLAG_HL_READY)) || 1080 (!(sc->sc_flag & UCOM_FLAG_GP_DATA))) { | 1067 if (tty_gone(tp)) |
1081 return; /* multiport device polling */ | 1068 return; /* multiport device polling */ |
1082 } | 1069 |
1083 if (len == 0) 1084 return; /* no data */ 1085 1086 /* set a flag to prevent recursation ? */ 1087 1088 while (len > 0) { 1089 1090 usb2_get_page(pc, offset, &res); --- 45 unchanged lines hidden --- | 1070 if (len == 0) 1071 return; /* no data */ 1072 1073 /* set a flag to prevent recursation ? */ 1074 1075 while (len > 0) { 1076 1077 usb2_get_page(pc, offset, &res); --- 45 unchanged lines hidden --- |