Lines Matching refs:ch

339 	struct moxa_str *ch;  in moxa_init()  local
388 for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) { in moxa_init()
389 ch->type = PORT_16550A; in moxa_init()
390 ch->port = i; in moxa_init()
391 ch->tqueue.routine = do_moxa_softint; in moxa_init()
392 ch->tqueue.data = ch; in moxa_init()
393 ch->tty = 0; in moxa_init()
394 ch->close_delay = 5 * HZ / 10; in moxa_init()
395 ch->closing_wait = 30 * HZ; in moxa_init()
396 ch->count = 0; in moxa_init()
397 ch->blocked_open = 0; in moxa_init()
398 ch->callout_termios = moxaCallout.init_termios; in moxa_init()
399 ch->normal_termios = moxaDriver.init_termios; in moxa_init()
400 init_waitqueue_head(&ch->open_wait); in moxa_init()
401 init_waitqueue_head(&ch->close_wait); in moxa_init()
542 struct moxa_str *ch = (struct moxa_str *) private_; in do_moxa_softint() local
545 if (ch && (tty = ch->tty)) { in do_moxa_softint()
546 if (test_and_clear_bit(MOXA_EVENT_HANGUP, &ch->event)) { in do_moxa_softint()
548 wake_up_interruptible(&ch->open_wait); in do_moxa_softint()
549 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CALLOUT_ACTIVE); in do_moxa_softint()
557 struct moxa_str *ch; in moxa_open() local
588 ch = &moxaChannels[port]; in moxa_open()
589 ch->count++; in moxa_open()
590 tty->driver_data = ch; in moxa_open()
591 ch->tty = tty; in moxa_open()
592 if (ch->count == 1 && (ch->asyncflags & ASYNC_SPLIT_TERMIOS)) { in moxa_open()
594 *tty->termios = ch->normal_termios; in moxa_open()
596 *tty->termios = ch->callout_termios; in moxa_open()
598 ch->session = current->session; in moxa_open()
599 ch->pgrp = current->pgrp; in moxa_open()
600 if (!(ch->asyncflags & ASYNC_INITIALIZED)) { in moxa_open()
601 ch->statusflags = 0; in moxa_open()
603 MoxaPortLineCtrl(ch->port, 1, 1); in moxa_open()
604 MoxaPortEnable(ch->port); in moxa_open()
605 ch->asyncflags |= ASYNC_INITIALIZED; in moxa_open()
607 retval = block_till_ready(tty, filp, ch); in moxa_open()
611 if (ch->type == PORT_16550A) { in moxa_open()
612 MoxaSetFifo(ch->port, 1); in moxa_open()
614 MoxaSetFifo(ch->port, 0); in moxa_open()
622 struct moxa_str *ch; in moxa_close() local
644 ch = (struct moxa_str *) tty->driver_data; in moxa_close()
646 if ((tty->count == 1) && (ch->count != 1)) { in moxa_close()
648 "ch->count is %d\n", ch->count); in moxa_close()
649 ch->count = 1; in moxa_close()
651 if (--ch->count < 0) { in moxa_close()
654 ch->count = 0; in moxa_close()
656 if (ch->count) { in moxa_close()
660 ch->asyncflags |= ASYNC_CLOSING; in moxa_close()
666 if (ch->asyncflags & ASYNC_NORMAL_ACTIVE) in moxa_close()
667 ch->normal_termios = *tty->termios; in moxa_close()
668 if (ch->asyncflags & ASYNC_CALLOUT_ACTIVE) in moxa_close()
669 ch->callout_termios = *tty->termios; in moxa_close()
670 if (ch->asyncflags & ASYNC_INITIALIZED) { in moxa_close()
673 moxaEmptyTimer_on[ch->port] = 0; in moxa_close()
674 del_timer(&moxaEmptyTimer[ch->port]); in moxa_close()
676 shut_down(ch); in moxa_close()
684 ch->event = 0; in moxa_close()
685 ch->tty = 0; in moxa_close()
686 if (ch->blocked_open) { in moxa_close()
687 if (ch->close_delay) { in moxa_close()
689 schedule_timeout(ch->close_delay); in moxa_close()
691 wake_up_interruptible(&ch->open_wait); in moxa_close()
693 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CALLOUT_ACTIVE | in moxa_close()
695 wake_up_interruptible(&ch->close_wait); in moxa_close()
702 struct moxa_str *ch; in moxa_write() local
706 ch = (struct moxa_str *) tty->driver_data; in moxa_write()
707 if (ch == NULL) in moxa_write()
709 port = ch->port; in moxa_write()
735 ch->statusflags |= LOWWAIT; in moxa_write()
741 struct moxa_str *ch; in moxa_write_room() local
745 ch = (struct moxa_str *) tty->driver_data; in moxa_write_room()
746 if (ch == NULL) in moxa_write_room()
748 return (MoxaPortTxFree(ch->port)); in moxa_write_room()
753 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_flush_buffer() local
755 if (ch == NULL) in moxa_flush_buffer()
757 MoxaPortFlushData(ch->port, 1); in moxa_flush_buffer()
764 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_chars_in_buffer() local
772 if (ch == NULL) in moxa_chars_in_buffer()
774 chars = MoxaPortTxQueue(ch->port); in moxa_chars_in_buffer()
780 if (!(ch->statusflags & EMPTYWAIT)) in moxa_chars_in_buffer()
796 struct moxa_str *ch; in moxa_put_char() local
800 ch = (struct moxa_str *) tty->driver_data; in moxa_put_char()
801 if (ch == NULL) in moxa_put_char()
803 port = ch->port; in moxa_put_char()
812 ch->statusflags |= LOWWAIT; in moxa_put_char()
818 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_ioctl() local
824 if ((port != MAX_PORTS) && (!ch)) in moxa_ioctl()
835 MoxaPortSendBreak(ch->port, 0); in moxa_ioctl()
843 MoxaPortSendBreak(ch->port, arg); in moxa_ioctl()
854 ch->asyncflags &= ~ASYNC_CHECK_CD; in moxa_ioctl()
856 ch->asyncflags |= ASYNC_CHECK_CD; in moxa_ioctl()
860 MoxaPortGetLineOut(ch->port, &dtr, &rts); in moxa_ioctl()
865 dtr = MoxaPortLineStatus(ch->port); in moxa_ioctl()
876 MoxaPortGetLineOut(ch->port, &dtr, &rts); in moxa_ioctl()
881 MoxaPortLineCtrl(ch->port, dtr, rts); in moxa_ioctl()
886 MoxaPortGetLineOut(ch->port, &dtr, &rts); in moxa_ioctl()
891 MoxaPortLineCtrl(ch->port, dtr, rts); in moxa_ioctl()
901 MoxaPortLineCtrl(ch->port, dtr, rts); in moxa_ioctl()
904 return (moxa_get_serial_info(ch, (struct serial_struct *) arg)); in moxa_ioctl()
907 return (moxa_set_serial_info(ch, (struct serial_struct *) arg)); in moxa_ioctl()
918 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_throttle() local
920 ch->statusflags |= THROTTLE; in moxa_throttle()
925 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_unthrottle() local
927 ch->statusflags &= ~THROTTLE; in moxa_unthrottle()
933 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_set_termios() local
935 if (ch == NULL) in moxa_set_termios()
940 wake_up_interruptible(&ch->open_wait); in moxa_set_termios()
945 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_stop() local
947 if (ch == NULL) in moxa_stop()
949 MoxaPortTxDisable(ch->port); in moxa_stop()
950 ch->statusflags |= TXSTOPPED; in moxa_stop()
956 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_start() local
958 if (ch == NULL) in moxa_start()
961 if (!(ch->statusflags & TXSTOPPED)) in moxa_start()
964 MoxaPortTxEnable(ch->port); in moxa_start()
965 ch->statusflags &= ~TXSTOPPED; in moxa_start()
970 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; in moxa_hangup() local
973 shut_down(ch); in moxa_hangup()
974 ch->event = 0; in moxa_hangup()
975 ch->count = 0; in moxa_hangup()
976 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CALLOUT_ACTIVE); in moxa_hangup()
977 ch->tty = 0; in moxa_hangup()
978 wake_up_interruptible(&ch->open_wait); in moxa_hangup()
984 struct moxa_str *ch; in moxa_poll() local
1002 ch = &moxaChannels[card * MAX_PORTS_PER_BOARD]; in moxa_poll()
1003 for (i = 0; i < ports; i++, ch++) { in moxa_poll()
1004 if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) in moxa_poll()
1006 if (!(ch->statusflags & THROTTLE) && in moxa_poll()
1007 (MoxaPortRxQueue(ch->port) > 0)) in moxa_poll()
1008 receive_data(ch); in moxa_poll()
1009 if ((tp = ch->tty) == 0) in moxa_poll()
1011 if (ch->statusflags & LOWWAIT) { in moxa_poll()
1012 if (MoxaPortTxQueue(ch->port) <= WAKEUP_CHARS) { in moxa_poll()
1014 ch->statusflags &= ~LOWWAIT; in moxa_poll()
1019 if (!I_IGNBRK(tp) && (MoxaPortResetBrkCnt(ch->port) > 0)) { in moxa_poll()
1023 if (MoxaPortDCDChange(ch->port)) { in moxa_poll()
1024 if (ch->asyncflags & ASYNC_CHECK_CD) { in moxa_poll()
1025 if (MoxaPortDCDON(ch->port)) in moxa_poll()
1026 wake_up_interruptible(&ch->open_wait); in moxa_poll()
1028 set_bit(MOXA_EVENT_HANGUP, &ch->event); in moxa_poll()
1030 if (schedule_task(&ch->tqueue) == 0) in moxa_poll()
1049 struct moxa_str *ch; in set_tty_param() local
1052 ch = (struct moxa_str *) tty->driver_data; in set_tty_param()
1055 ch->asyncflags &= ~ASYNC_CHECK_CD; in set_tty_param()
1057 ch->asyncflags |= ASYNC_CHECK_CD; in set_tty_param()
1067 MoxaPortFlowCtrl(ch->port, rts, cts, txflow, rxflow, xany); in set_tty_param()
1068 MoxaPortSetTermio(ch->port, ts); in set_tty_param()
1072 struct moxa_str *ch) in block_till_ready() argument
1083 if (tty_hung_up_p(filp) || (ch->asyncflags & ASYNC_CLOSING)) { in block_till_ready()
1084 if (ch->asyncflags & ASYNC_CLOSING) in block_till_ready()
1085 interruptible_sleep_on(&ch->close_wait); in block_till_ready()
1087 if (ch->asyncflags & ASYNC_HUP_NOTIFY) in block_till_ready()
1100 if (ch->asyncflags & ASYNC_NORMAL_ACTIVE) in block_till_ready()
1102 if ((ch->asyncflags & ASYNC_CALLOUT_ACTIVE) && in block_till_ready()
1103 (ch->asyncflags & ASYNC_SESSION_LOCKOUT) && in block_till_ready()
1104 (ch->session != current->session)) in block_till_ready()
1106 if ((ch->asyncflags & ASYNC_CALLOUT_ACTIVE) && in block_till_ready()
1107 (ch->asyncflags & ASYNC_PGRP_LOCKOUT) && in block_till_ready()
1108 (ch->pgrp != current->pgrp)) in block_till_ready()
1110 ch->asyncflags |= ASYNC_CALLOUT_ACTIVE; in block_till_ready()
1118 if (ch->asyncflags & ASYNC_CALLOUT_ACTIVE) in block_till_ready()
1120 ch->asyncflags |= ASYNC_NORMAL_ACTIVE; in block_till_ready()
1127 add_wait_queue(&ch->open_wait, &wait); in block_till_ready()
1130 ch->line, ch->count); in block_till_ready()
1135 ch->count--; in block_till_ready()
1137 ch->blocked_open++; in block_till_ready()
1141 !(ch->asyncflags & ASYNC_INITIALIZED)) { in block_till_ready()
1143 if (ch->asyncflags & ASYNC_HUP_NOTIFY) in block_till_ready()
1152 if (!(ch->asyncflags & ASYNC_CALLOUT_ACTIVE) && in block_till_ready()
1153 !(ch->asyncflags & ASYNC_CLOSING) && (do_clocal || in block_till_ready()
1154 MoxaPortDCDON(ch->port))) in block_till_ready()
1164 remove_wait_queue(&ch->open_wait, &wait); in block_till_ready()
1166 ch->count++; in block_till_ready()
1167 ch->blocked_open--; in block_till_ready()
1170 ch->line, ch->count); in block_till_ready()
1174 ch->asyncflags |= ASYNC_NORMAL_ACTIVE; in block_till_ready()
1180 struct moxa_str *ch = tty->driver_data; in setup_empty_event() local
1185 ch->statusflags |= EMPTYWAIT; in setup_empty_event()
1186 moxaEmptyTimer_on[ch->port] = 0; in setup_empty_event()
1187 del_timer(&moxaEmptyTimer[ch->port]); in setup_empty_event()
1188 moxaEmptyTimer[ch->port].expires = jiffies + HZ; in setup_empty_event()
1189 moxaEmptyTimer_on[ch->port] = 1; in setup_empty_event()
1190 add_timer(&moxaEmptyTimer[ch->port]); in setup_empty_event()
1196 struct moxa_str *ch; in check_xmit_empty() local
1198 ch = (struct moxa_str *) data; in check_xmit_empty()
1199 moxaEmptyTimer_on[ch->port] = 0; in check_xmit_empty()
1200 del_timer(&moxaEmptyTimer[ch->port]); in check_xmit_empty()
1201 if (ch->tty && (ch->statusflags & EMPTYWAIT)) { in check_xmit_empty()
1202 if (MoxaPortTxQueue(ch->port) == 0) { in check_xmit_empty()
1203 ch->statusflags &= ~EMPTYWAIT; in check_xmit_empty()
1204 tty_wakeup(ch->tty); in check_xmit_empty()
1207 moxaEmptyTimer[ch->port].expires = jiffies + HZ; in check_xmit_empty()
1208 moxaEmptyTimer_on[ch->port] = 1; in check_xmit_empty()
1209 add_timer(&moxaEmptyTimer[ch->port]); in check_xmit_empty()
1211 ch->statusflags &= ~EMPTYWAIT; in check_xmit_empty()
1214 static void shut_down(struct moxa_str *ch) in shut_down() argument
1218 if (!(ch->asyncflags & ASYNC_INITIALIZED)) in shut_down()
1221 tp = ch->tty; in shut_down()
1223 MoxaPortDisable(ch->port); in shut_down()
1229 MoxaPortLineCtrl(ch->port, 0, 0); in shut_down()
1231 ch->asyncflags &= ~ASYNC_INITIALIZED; in shut_down()
1234 static void receive_data(struct moxa_str *ch) in receive_data() argument
1243 tp = ch->tty; in receive_data()
1250 MoxaPortFlushData(ch->port, 0); in receive_data()
1261 count = MoxaPortReadData(ch->port, charptr, space); in receive_data()
1270 tty_schedule_flip(ch->tty); in receive_data()