Searched refs:tty (Results 1 - 200 of 485) sorted by relevance

123

/linux-4.1.27/drivers/tty/
H A Dtty_mutex.c1 #include <linux/tty.h>
7 /* Legacy tty mutex glue */
10 * Getting the big tty mutex.
13 void __lockfunc tty_lock(struct tty_struct *tty) tty_lock() argument
15 if (tty->magic != TTY_MAGIC) { tty_lock()
16 pr_err("L Bad %p\n", tty); tty_lock()
20 tty_kref_get(tty); tty_lock()
21 mutex_lock(&tty->legacy_mutex); tty_lock()
25 void __lockfunc tty_unlock(struct tty_struct *tty) tty_unlock() argument
27 if (tty->magic != TTY_MAGIC) { tty_unlock()
28 pr_err("U Bad %p\n", tty); tty_unlock()
32 mutex_unlock(&tty->legacy_mutex); tty_unlock()
33 tty_kref_put(tty); tty_unlock()
37 void __lockfunc tty_lock_slave(struct tty_struct *tty) tty_lock_slave() argument
39 if (tty && tty != tty->link) tty_lock_slave()
40 tty_lock(tty); tty_lock_slave()
43 void __lockfunc tty_unlock_slave(struct tty_struct *tty) tty_unlock_slave() argument
45 if (tty && tty != tty->link) tty_unlock_slave()
46 tty_unlock(tty); tty_unlock_slave()
49 void tty_set_lock_subclass(struct tty_struct *tty) tty_set_lock_subclass() argument
51 lockdep_set_subclass(&tty->legacy_mutex, TTY_LOCK_SLAVE); tty_set_lock_subclass()
H A Dtty_ldisc.c6 #include <linux/tty.h>
25 #define tty_ldisc_debug(tty, f, args...) ({ \
27 printk(KERN_DEBUG "%s: %s: " f, __func__, tty_name(tty, __b), ##args); \
30 #define tty_ldisc_debug(tty, f, args...)
33 /* lockdep nested classes for tty->ldisc_sem */
154 static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc) tty_ldisc_get() argument
168 request_module("tty-ldisc-%d", disc); tty_ldisc_get()
181 ld->tty = tty; tty_ldisc_get()
249 * tty_ldisc_ref_wait - wait for the tty ldisc
250 * @tty: tty device
262 * guarantees tty->ldisc != NULL when the lock is acquired).
265 struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *tty) tty_ldisc_ref_wait() argument
267 ldsem_down_read(&tty->ldisc_sem, MAX_SCHEDULE_TIMEOUT); tty_ldisc_ref_wait()
268 WARN_ON(!tty->ldisc); tty_ldisc_ref_wait()
269 return tty->ldisc; tty_ldisc_ref_wait()
274 * tty_ldisc_ref - get the tty ldisc
275 * @tty: tty device
282 struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty) tty_ldisc_ref() argument
286 if (ldsem_down_read_trylock(&tty->ldisc_sem)) { tty_ldisc_ref()
287 ld = tty->ldisc; tty_ldisc_ref()
289 ldsem_up_read(&tty->ldisc_sem); tty_ldisc_ref()
296 * tty_ldisc_deref - free a tty ldisc reference
305 ldsem_up_read(&ld->tty->ldisc_sem); tty_ldisc_deref()
311 __tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout) __tty_ldisc_lock() argument
313 return ldsem_down_write(&tty->ldisc_sem, timeout); __tty_ldisc_lock()
317 __tty_ldisc_lock_nested(struct tty_struct *tty, unsigned long timeout) __tty_ldisc_lock_nested() argument
319 return ldsem_down_write_nested(&tty->ldisc_sem, __tty_ldisc_lock_nested()
323 static inline void __tty_ldisc_unlock(struct tty_struct *tty) __tty_ldisc_unlock() argument
325 return ldsem_up_write(&tty->ldisc_sem); __tty_ldisc_unlock()
329 tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout) tty_ldisc_lock() argument
333 ret = __tty_ldisc_lock(tty, timeout); tty_ldisc_lock()
336 set_bit(TTY_LDISC_HALTED, &tty->flags); tty_ldisc_lock()
340 static void tty_ldisc_unlock(struct tty_struct *tty) tty_ldisc_unlock() argument
342 clear_bit(TTY_LDISC_HALTED, &tty->flags); tty_ldisc_unlock()
343 __tty_ldisc_unlock(tty); tty_ldisc_unlock()
347 tty_ldisc_lock_pair_timeout(struct tty_struct *tty, struct tty_struct *tty2, tty_ldisc_lock_pair_timeout() argument
352 if (tty < tty2) { tty_ldisc_lock_pair_timeout()
353 ret = __tty_ldisc_lock(tty, timeout); tty_ldisc_lock_pair_timeout()
357 __tty_ldisc_unlock(tty); tty_ldisc_lock_pair_timeout()
361 WARN_ON_ONCE(tty == tty2); tty_ldisc_lock_pair_timeout()
362 if (tty2 && tty != tty2) { tty_ldisc_lock_pair_timeout()
365 ret = __tty_ldisc_lock_nested(tty, timeout); tty_ldisc_lock_pair_timeout()
370 ret = __tty_ldisc_lock(tty, timeout); tty_ldisc_lock_pair_timeout()
376 set_bit(TTY_LDISC_HALTED, &tty->flags); tty_ldisc_lock_pair_timeout()
383 tty_ldisc_lock_pair(struct tty_struct *tty, struct tty_struct *tty2) tty_ldisc_lock_pair() argument
385 tty_ldisc_lock_pair_timeout(tty, tty2, MAX_SCHEDULE_TIMEOUT); tty_ldisc_lock_pair()
388 static void __lockfunc tty_ldisc_unlock_pair(struct tty_struct *tty, tty_ldisc_unlock_pair() argument
391 __tty_ldisc_unlock(tty); tty_ldisc_unlock_pair()
398 * @tty: tty
400 * Flush the line discipline queue (if any) and the tty flip buffers
401 * for this tty.
404 void tty_ldisc_flush(struct tty_struct *tty) tty_ldisc_flush() argument
406 struct tty_ldisc *ld = tty_ldisc_ref(tty); tty_ldisc_flush()
408 tty_buffer_flush(tty, ld); tty_ldisc_flush()
416 * @tty: tty structure
426 static void tty_set_termios_ldisc(struct tty_struct *tty, int num) tty_set_termios_ldisc() argument
428 down_write(&tty->termios_rwsem); tty_set_termios_ldisc()
429 tty->termios.c_line = num; tty_set_termios_ldisc()
430 up_write(&tty->termios_rwsem); tty_set_termios_ldisc()
435 * @tty: tty we are opening the ldisc on
444 static int tty_ldisc_open(struct tty_struct *tty, struct tty_ldisc *ld) tty_ldisc_open() argument
446 WARN_ON(test_and_set_bit(TTY_LDISC_OPEN, &tty->flags)); tty_ldisc_open()
450 ret = ld->ops->open(tty); tty_ldisc_open()
452 clear_bit(TTY_LDISC_OPEN, &tty->flags); tty_ldisc_open()
460 * @tty: tty we are opening the ldisc on
467 static void tty_ldisc_close(struct tty_struct *tty, struct tty_ldisc *ld) tty_ldisc_close() argument
469 WARN_ON(!test_bit(TTY_LDISC_OPEN, &tty->flags)); tty_ldisc_close()
470 clear_bit(TTY_LDISC_OPEN, &tty->flags); tty_ldisc_close()
472 ld->ops->close(tty); tty_ldisc_close()
476 * tty_ldisc_restore - helper for tty ldisc change
477 * @tty: tty to recover
484 static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) tty_ldisc_restore() argument
491 old = tty_ldisc_get(tty, old->ops->num); tty_ldisc_restore()
493 tty->ldisc = old; tty_ldisc_restore()
494 tty_set_termios_ldisc(tty, old->ops->num); tty_ldisc_restore()
495 if (tty_ldisc_open(tty, old) < 0) { tty_ldisc_restore()
498 new_ldisc = tty_ldisc_get(tty, N_TTY); tty_ldisc_restore()
501 tty->ldisc = new_ldisc; tty_ldisc_restore()
502 tty_set_termios_ldisc(tty, N_TTY); tty_ldisc_restore()
503 r = tty_ldisc_open(tty, new_ldisc); tty_ldisc_restore()
507 tty_name(tty, buf), r); tty_ldisc_restore()
513 * @tty: the terminal to set
516 * Set the discipline of a tty line. Must be called from a process
519 * the close of one side of a tty/pty pair, and eventually hangup.
522 int tty_set_ldisc(struct tty_struct *tty, int ldisc) tty_set_ldisc() argument
527 new_ldisc = tty_ldisc_get(tty, ldisc); tty_set_ldisc()
531 tty_lock(tty); tty_set_ldisc()
532 retval = tty_ldisc_lock(tty, 5 * HZ); tty_set_ldisc()
535 tty_unlock(tty); tty_set_ldisc()
543 if (tty->ldisc->ops->num == ldisc) { tty_set_ldisc()
544 tty_ldisc_unlock(tty); tty_set_ldisc()
546 tty_unlock(tty); tty_set_ldisc()
550 old_ldisc = tty->ldisc; tty_set_ldisc()
552 if (test_bit(TTY_HUPPED, &tty->flags)) { tty_set_ldisc()
555 tty_ldisc_unlock(tty); tty_set_ldisc()
557 tty_unlock(tty); tty_set_ldisc()
562 tty_ldisc_close(tty, old_ldisc); tty_set_ldisc()
565 tty->ldisc = new_ldisc; tty_set_ldisc()
566 tty_set_termios_ldisc(tty, ldisc); tty_set_ldisc()
568 retval = tty_ldisc_open(tty, new_ldisc); tty_set_ldisc()
572 tty_ldisc_restore(tty, old_ldisc); tty_set_ldisc()
575 if (tty->ldisc->ops->num != old_ldisc->ops->num && tty->ops->set_ldisc) { tty_set_ldisc()
576 down_read(&tty->termios_rwsem); tty_set_ldisc()
577 tty->ops->set_ldisc(tty); tty_set_ldisc()
578 up_read(&tty->termios_rwsem); tty_set_ldisc()
592 tty_ldisc_unlock(tty); tty_set_ldisc()
596 schedule_work(&tty->port->buf.work); tty_set_ldisc()
598 tty_unlock(tty); tty_set_ldisc()
604 * @tty: tty to reset
609 static void tty_reset_termios(struct tty_struct *tty) tty_reset_termios() argument
611 down_write(&tty->termios_rwsem); tty_reset_termios()
612 tty->termios = tty->driver->init_termios; tty_reset_termios()
613 tty->termios.c_ispeed = tty_termios_input_baud_rate(&tty->termios); tty_reset_termios()
614 tty->termios.c_ospeed = tty_termios_baud_rate(&tty->termios); tty_reset_termios()
615 up_write(&tty->termios_rwsem); tty_reset_termios()
620 * tty_ldisc_reinit - reinitialise the tty ldisc
621 * @tty: tty to reinit
624 * Switch the tty to a line discipline and leave the ldisc
628 static int tty_ldisc_reinit(struct tty_struct *tty, int ldisc) tty_ldisc_reinit() argument
630 struct tty_ldisc *ld = tty_ldisc_get(tty, ldisc); tty_ldisc_reinit()
635 tty_ldisc_close(tty, tty->ldisc); tty_ldisc_reinit()
636 tty_ldisc_put(tty->ldisc); tty_ldisc_reinit()
640 tty->ldisc = ld; tty_ldisc_reinit()
641 tty_set_termios_ldisc(tty, ldisc); tty_ldisc_reinit()
648 * @tty: tty being hung up
650 * Some tty devices reset their termios when they receive a hangup
658 * tty itself so we must be careful about locking rules.
661 void tty_ldisc_hangup(struct tty_struct *tty) tty_ldisc_hangup() argument
664 int reset = tty->driver->flags & TTY_DRIVER_RESET_TERMIOS; tty_ldisc_hangup()
667 tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc); tty_ldisc_hangup()
669 ld = tty_ldisc_ref(tty); tty_ldisc_hangup()
672 ld->ops->flush_buffer(tty); tty_ldisc_hangup()
673 tty_driver_flush_buffer(tty); tty_ldisc_hangup()
674 if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) && tty_ldisc_hangup()
676 ld->ops->write_wakeup(tty); tty_ldisc_hangup()
678 ld->ops->hangup(tty); tty_ldisc_hangup()
682 wake_up_interruptible_poll(&tty->write_wait, POLLOUT); tty_ldisc_hangup()
683 wake_up_interruptible_poll(&tty->read_wait, POLLIN); tty_ldisc_hangup()
691 tty_ldisc_lock(tty, MAX_SCHEDULE_TIMEOUT); tty_ldisc_hangup()
693 if (tty->ldisc) { tty_ldisc_hangup()
701 if (!tty_ldisc_reinit(tty, tty->termios.c_line)) tty_ldisc_hangup()
702 err = tty_ldisc_open(tty, tty->ldisc); tty_ldisc_hangup()
709 BUG_ON(tty_ldisc_reinit(tty, N_TTY)); tty_ldisc_hangup()
710 WARN_ON(tty_ldisc_open(tty, tty->ldisc)); tty_ldisc_hangup()
713 tty_ldisc_unlock(tty); tty_ldisc_hangup()
715 tty_reset_termios(tty); tty_ldisc_hangup()
717 tty_ldisc_debug(tty, "re-opened ldisc: %p\n", tty->ldisc); tty_ldisc_hangup()
722 * @tty: tty being shut down
723 * @o_tty: pair tty for pty/tty pairs
725 * Called during the initial open of a tty/pty pair in order to set up the
726 * line disciplines and bind them to the tty. This has no locking issues
730 int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty) tty_ldisc_setup() argument
732 struct tty_ldisc *ld = tty->ldisc; tty_ldisc_setup()
735 retval = tty_ldisc_open(tty, ld); tty_ldisc_setup()
742 tty_ldisc_close(tty, ld); tty_ldisc_setup()
749 static void tty_ldisc_kill(struct tty_struct *tty) tty_ldisc_kill() argument
754 tty_ldisc_close(tty, tty->ldisc); tty_ldisc_kill()
755 tty_ldisc_put(tty->ldisc); tty_ldisc_kill()
757 tty->ldisc = NULL; tty_ldisc_kill()
760 tty_set_termios_ldisc(tty, N_TTY); tty_ldisc_kill()
765 * @tty: tty being shut down (or one end of pty pair)
767 * Called during the final close of a tty or a pty pair in order to shut
772 void tty_ldisc_release(struct tty_struct *tty) tty_ldisc_release() argument
774 struct tty_struct *o_tty = tty->link; tty_ldisc_release()
781 tty_ldisc_debug(tty, "closing ldisc: %p\n", tty->ldisc); tty_ldisc_release()
783 tty_ldisc_lock_pair(tty, o_tty); tty_ldisc_release()
784 tty_ldisc_kill(tty); tty_ldisc_release()
787 tty_ldisc_unlock_pair(tty, o_tty); tty_ldisc_release()
792 tty_ldisc_debug(tty, "ldisc closed\n"); tty_ldisc_release()
796 * tty_ldisc_init - ldisc setup for new tty
797 * @tty: tty being allocated
799 * Set up the line discipline objects for a newly allocated tty. Note that
800 * the tty structure is not completely set up when this call is made.
803 void tty_ldisc_init(struct tty_struct *tty) tty_ldisc_init() argument
805 struct tty_ldisc *ld = tty_ldisc_get(tty, N_TTY); tty_ldisc_init()
808 tty->ldisc = ld; tty_ldisc_init()
812 * tty_ldisc_init - ldisc cleanup for new tty
813 * @tty: tty that was allocated recently
815 * The tty structure must not becompletely set up (tty_ldisc_setup) when
818 void tty_ldisc_deinit(struct tty_struct *tty) tty_ldisc_deinit() argument
820 tty_ldisc_put(tty->ldisc); tty_ldisc_deinit()
821 tty->ldisc = NULL; tty_ldisc_deinit()
H A Dn_tty.c40 #include <linux/tty.h>
156 static inline int tty_put_user(struct tty_struct *tty, unsigned char x, tty_put_user() argument
159 struct n_tty_data *ldata = tty->disc_data; tty_put_user()
161 tty_audit_add_data(tty, &x, 1, ldata->icanon); tty_put_user()
165 static inline int tty_copy_to_user(struct tty_struct *tty, tty_copy_to_user() argument
170 struct n_tty_data *ldata = tty->disc_data; tty_copy_to_user()
172 tty_audit_add_data(tty, from, n, ldata->icanon); tty_copy_to_user()
178 * @tty: terminal
188 static void n_tty_kick_worker(struct tty_struct *tty) n_tty_kick_worker() argument
190 struct n_tty_data *ldata = tty->disc_data; n_tty_kick_worker()
196 WARN_RATELIMIT(tty->port->itty == NULL, n_tty_kick_worker()
202 WARN_RATELIMIT(test_bit(TTY_LDISC_HALTED, &tty->flags), n_tty_kick_worker()
204 queue_work(system_unbound_wq, &tty->port->buf.work); n_tty_kick_worker()
208 static ssize_t chars_in_buffer(struct tty_struct *tty) chars_in_buffer() argument
210 struct n_tty_data *ldata = tty->disc_data; chars_in_buffer()
222 * @tty: tty device
229 static void n_tty_write_wakeup(struct tty_struct *tty) n_tty_write_wakeup() argument
231 if (tty->fasync && test_and_clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) n_tty_write_wakeup()
232 kill_fasync(&tty->fasync, SIGIO, POLL_OUT); n_tty_write_wakeup()
235 static void n_tty_check_throttle(struct tty_struct *tty) n_tty_check_throttle() argument
237 struct n_tty_data *ldata = tty->disc_data; n_tty_check_throttle()
249 tty_set_flow_change(tty, TTY_THROTTLE_SAFE); n_tty_check_throttle()
252 throttled = tty_throttle_safe(tty); n_tty_check_throttle()
256 __tty_set_flow_change(tty, 0); n_tty_check_throttle()
259 static void n_tty_check_unthrottle(struct tty_struct *tty) n_tty_check_unthrottle() argument
261 if (tty->driver->type == TTY_DRIVER_TYPE_PTY) { n_tty_check_unthrottle()
262 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) n_tty_check_unthrottle()
264 if (!tty->count) n_tty_check_unthrottle()
266 n_tty_kick_worker(tty); n_tty_check_unthrottle()
267 tty_wakeup(tty->link); n_tty_check_unthrottle()
281 tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); n_tty_check_unthrottle()
282 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) n_tty_check_unthrottle()
284 if (!tty->count) n_tty_check_unthrottle()
286 n_tty_kick_worker(tty); n_tty_check_unthrottle()
287 unthrottled = tty_unthrottle_safe(tty); n_tty_check_unthrottle()
291 __tty_set_flow_change(tty, 0); n_tty_check_unthrottle()
295 * put_tty_queue - add character to tty
299 * Add a character to the tty read_buf queue.
313 * @tty: terminal to reset
335 static void n_tty_packet_mode_flush(struct tty_struct *tty) n_tty_packet_mode_flush() argument
339 if (tty->link->packet) { n_tty_packet_mode_flush()
340 spin_lock_irqsave(&tty->ctrl_lock, flags); n_tty_packet_mode_flush()
341 tty->ctrl_status |= TIOCPKT_FLUSHREAD; n_tty_packet_mode_flush()
342 spin_unlock_irqrestore(&tty->ctrl_lock, flags); n_tty_packet_mode_flush()
343 wake_up_interruptible(&tty->link->read_wait); n_tty_packet_mode_flush()
349 * @tty: terminal device
351 * Flush the input buffer. Called when the tty layer wants the
361 static void n_tty_flush_buffer(struct tty_struct *tty) n_tty_flush_buffer() argument
363 down_write(&tty->termios_rwsem); n_tty_flush_buffer()
364 reset_buffer_flags(tty->disc_data); n_tty_flush_buffer()
365 n_tty_kick_worker(tty); n_tty_flush_buffer()
367 if (tty->link) n_tty_flush_buffer()
368 n_tty_packet_mode_flush(tty); n_tty_flush_buffer()
369 up_write(&tty->termios_rwsem); n_tty_flush_buffer()
374 * @tty: tty device
382 static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) n_tty_chars_in_buffer() argument
388 down_write(&tty->termios_rwsem); n_tty_chars_in_buffer()
389 n = chars_in_buffer(tty); n_tty_chars_in_buffer()
390 up_write(&tty->termios_rwsem); n_tty_chars_in_buffer()
416 static inline int is_continuation(unsigned char c, struct tty_struct *tty) is_continuation() argument
418 return I_IUTF8(tty) && is_utf8_continuation(c); is_continuation()
424 * @tty: terminal device
425 * @space: space available in tty driver write buffer
430 * tty driver's write buffer.
443 static int do_output_char(unsigned char c, struct tty_struct *tty, int space) do_output_char() argument
445 struct n_tty_data *ldata = tty->disc_data; do_output_char()
453 if (O_ONLRET(tty)) do_output_char()
455 if (O_ONLCR(tty)) { do_output_char()
459 tty->ops->write(tty, "\r\n", 2); do_output_char()
465 if (O_ONOCR(tty) && ldata->column == 0) do_output_char()
467 if (O_OCRNL(tty)) { do_output_char()
469 if (O_ONLRET(tty)) do_output_char()
477 if (O_TABDLY(tty) == XTABS) { do_output_char()
481 tty->ops->write(tty, " ", spaces); do_output_char()
492 if (O_OLCUC(tty)) do_output_char()
494 if (!is_continuation(c, tty)) do_output_char()
500 tty_put_char(tty, c); do_output_char()
507 * @tty: terminal device
515 * tty layer write lock)
518 static int process_output(unsigned char c, struct tty_struct *tty) process_output() argument
520 struct n_tty_data *ldata = tty->disc_data; process_output()
525 space = tty_write_room(tty); process_output()
526 retval = do_output_char(c, tty, space); process_output()
537 * @tty: terminal device
551 * tty layer write lock)
554 static ssize_t process_output_block(struct tty_struct *tty, process_output_block() argument
557 struct n_tty_data *ldata = tty->disc_data; process_output_block()
564 space = tty_write_room(tty); process_output_block()
577 if (O_ONLRET(tty)) process_output_block()
579 if (O_ONLCR(tty)) process_output_block()
584 if (O_ONOCR(tty) && ldata->column == 0) process_output_block()
586 if (O_OCRNL(tty)) process_output_block()
598 if (O_OLCUC(tty)) process_output_block()
600 if (!is_continuation(c, tty)) process_output_block()
607 i = tty->ops->write(tty, buf, i); process_output_block()
615 * @tty: terminal device
618 * characters to the tty.
638 static size_t __process_echoes(struct tty_struct *tty) __process_echoes() argument
640 struct n_tty_data *ldata = tty->disc_data; __process_echoes()
645 old_space = space = tty_write_room(tty); __process_echoes()
687 tty_put_char(tty, '\b'); __process_echoes()
711 tty_put_char(tty, ECHO_OP_START); __process_echoes()
731 tty_put_char(tty, '^'); __process_echoes()
732 tty_put_char(tty, op ^ 0100); __process_echoes()
741 if (O_OPOST(tty)) { __process_echoes()
742 int retval = do_output_char(c, tty, space); __process_echoes()
749 tty_put_char(tty, c); __process_echoes()
773 static void commit_echoes(struct tty_struct *tty) commit_echoes() argument
775 struct n_tty_data *ldata = tty->disc_data; commit_echoes()
792 echoed = __process_echoes(tty); commit_echoes()
795 if (echoed && tty->ops->flush_chars) commit_echoes()
796 tty->ops->flush_chars(tty); commit_echoes()
799 static void process_echoes(struct tty_struct *tty) process_echoes() argument
801 struct n_tty_data *ldata = tty->disc_data; process_echoes()
809 echoed = __process_echoes(tty); process_echoes()
812 if (echoed && tty->ops->flush_chars) process_echoes()
813 tty->ops->flush_chars(tty); process_echoes()
817 static void flush_echoes(struct tty_struct *tty) flush_echoes() argument
819 struct n_tty_data *ldata = tty->disc_data; flush_echoes()
821 if ((!L_ECHO(tty) && !L_ECHONL(tty)) || flush_echoes()
827 __process_echoes(tty); flush_echoes()
905 * @tty: terminal device
908 * L_ECHO(tty) is true. Called from the driver receive_buf path.
926 * @tty: terminal device
929 * L_ECHO(tty) is true. Called from the driver receive_buf path.
935 static void echo_char(unsigned char c, struct tty_struct *tty) echo_char() argument
937 struct n_tty_data *ldata = tty->disc_data; echo_char()
943 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') echo_char()
965 * @tty: terminal device
975 static void eraser(unsigned char c, struct tty_struct *tty) eraser() argument
977 struct n_tty_data *ldata = tty->disc_data; eraser()
984 /* process_output('\a', tty); */ /* what do you think? */ eraser()
987 if (c == ERASE_CHAR(tty)) eraser()
989 else if (c == WERASE_CHAR(tty)) eraser()
992 if (!L_ECHO(tty)) { eraser()
996 if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) { eraser()
999 echo_char(KILL_CHAR(tty), tty); eraser() local
1001 if (L_ECHOK(tty)) eraser()
1016 } while (is_continuation(c, tty) && head != ldata->canon_head); eraser()
1019 if (is_continuation(c, tty)) eraser()
1031 if (L_ECHO(tty)) { eraser()
1032 if (L_ECHOPRT(tty)) { eraser()
1038 echo_char(c, tty); eraser()
1044 } else if (kill_type == ERASE && !L_ECHOE(tty)) { eraser()
1045 echo_char(ERASE_CHAR(tty), tty); eraser() local
1065 if (L_ECHOCTL(tty)) eraser()
1067 } else if (!is_continuation(c, tty)) { eraser()
1073 if (iscntrl(c) && L_ECHOCTL(tty)) { eraser()
1078 if (!iscntrl(c) || L_ECHOCTL(tty)) { eraser()
1088 if (ldata->read_head == ldata->canon_head && L_ECHO(tty)) eraser()
1095 * @tty: terminal
1107 static void __isig(int sig, struct tty_struct *tty) __isig() argument
1109 struct pid *tty_pgrp = tty_get_pgrp(tty); __isig()
1116 static void isig(int sig, struct tty_struct *tty) isig() argument
1118 struct n_tty_data *ldata = tty->disc_data; isig()
1120 if (L_NOFLSH(tty)) { isig()
1122 __isig(sig, tty); isig()
1125 up_read(&tty->termios_rwsem); isig()
1126 down_write(&tty->termios_rwsem); isig()
1128 __isig(sig, tty); isig()
1137 tty_driver_flush_buffer(tty); isig()
1140 reset_buffer_flags(tty->disc_data); isig()
1143 if (tty->link) isig()
1144 n_tty_packet_mode_flush(tty); isig()
1146 up_write(&tty->termios_rwsem); isig()
1147 down_read(&tty->termios_rwsem); isig()
1153 * @tty: terminal
1164 static void n_tty_receive_break(struct tty_struct *tty) n_tty_receive_break() argument
1166 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_break()
1168 if (I_IGNBRK(tty)) n_tty_receive_break()
1170 if (I_BRKINT(tty)) { n_tty_receive_break()
1171 isig(SIGINT, tty); n_tty_receive_break()
1174 if (I_PARMRK(tty)) { n_tty_receive_break()
1179 if (waitqueue_active(&tty->read_wait)) n_tty_receive_break()
1180 wake_up_interruptible_poll(&tty->read_wait, POLLIN); n_tty_receive_break()
1185 * @tty: terminal
1187 * Data arrived faster than we could process it. While the tty
1196 static void n_tty_receive_overrun(struct tty_struct *tty) n_tty_receive_overrun() argument
1198 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_overrun()
1205 tty_name(tty, buf), n_tty_receive_overrun()
1214 * @tty: terminal device
1223 static void n_tty_receive_parity_error(struct tty_struct *tty, unsigned char c) n_tty_receive_parity_error() argument
1225 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_parity_error()
1227 if (I_INPCK(tty)) { n_tty_receive_parity_error()
1228 if (I_IGNPAR(tty)) n_tty_receive_parity_error()
1230 if (I_PARMRK(tty)) { n_tty_receive_parity_error()
1238 if (waitqueue_active(&tty->read_wait)) n_tty_receive_parity_error()
1239 wake_up_interruptible_poll(&tty->read_wait, POLLIN); n_tty_receive_parity_error()
1243 n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c) n_tty_receive_signal_char() argument
1245 isig(signal, tty); n_tty_receive_signal_char()
1246 if (I_IXON(tty)) n_tty_receive_signal_char()
1247 start_tty(tty); n_tty_receive_signal_char()
1248 if (L_ECHO(tty)) { n_tty_receive_signal_char()
1249 echo_char(c, tty); n_tty_receive_signal_char()
1250 commit_echoes(tty); n_tty_receive_signal_char()
1252 process_echoes(tty); n_tty_receive_signal_char()
1258 * @tty: terminal device
1273 n_tty_receive_char_special(struct tty_struct *tty, unsigned char c) n_tty_receive_char_special() argument
1275 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_char_special()
1277 if (I_IXON(tty)) { n_tty_receive_char_special()
1278 if (c == START_CHAR(tty)) { n_tty_receive_char_special()
1279 start_tty(tty); n_tty_receive_char_special()
1280 process_echoes(tty); n_tty_receive_char_special()
1283 if (c == STOP_CHAR(tty)) { n_tty_receive_char_special()
1284 stop_tty(tty); n_tty_receive_char_special()
1289 if (L_ISIG(tty)) { n_tty_receive_char_special()
1290 if (c == INTR_CHAR(tty)) { n_tty_receive_char_special()
1291 n_tty_receive_signal_char(tty, SIGINT, c); n_tty_receive_char_special()
1293 } else if (c == QUIT_CHAR(tty)) { n_tty_receive_char_special()
1294 n_tty_receive_signal_char(tty, SIGQUIT, c); n_tty_receive_char_special()
1296 } else if (c == SUSP_CHAR(tty)) { n_tty_receive_char_special()
1297 n_tty_receive_signal_char(tty, SIGTSTP, c); n_tty_receive_char_special()
1302 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { n_tty_receive_char_special()
1303 start_tty(tty); n_tty_receive_char_special()
1304 process_echoes(tty); n_tty_receive_char_special()
1308 if (I_IGNCR(tty)) n_tty_receive_char_special()
1310 if (I_ICRNL(tty)) n_tty_receive_char_special()
1312 } else if (c == '\n' && I_INLCR(tty)) n_tty_receive_char_special()
1316 if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || n_tty_receive_char_special()
1317 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { n_tty_receive_char_special()
1318 eraser(c, tty); n_tty_receive_char_special()
1319 commit_echoes(tty); n_tty_receive_char_special()
1322 if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { n_tty_receive_char_special()
1324 if (L_ECHO(tty)) { n_tty_receive_char_special()
1326 if (L_ECHOCTL(tty)) { n_tty_receive_char_special()
1329 commit_echoes(tty); n_tty_receive_char_special()
1334 if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && L_IEXTEN(tty)) { n_tty_receive_char_special()
1338 echo_char(c, tty); n_tty_receive_char_special()
1341 echo_char(read_buf(ldata, tail), tty); n_tty_receive_char_special() local
1344 commit_echoes(tty); n_tty_receive_char_special()
1348 if (L_ECHO(tty) || L_ECHONL(tty)) { n_tty_receive_char_special()
1350 commit_echoes(tty); n_tty_receive_char_special()
1354 if (c == EOF_CHAR(tty)) { n_tty_receive_char_special()
1358 if ((c == EOL_CHAR(tty)) || n_tty_receive_char_special()
1359 (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { n_tty_receive_char_special()
1363 if (L_ECHO(tty)) { n_tty_receive_char_special()
1367 echo_char(c, tty); n_tty_receive_char_special()
1368 commit_echoes(tty); n_tty_receive_char_special()
1374 if (c == (unsigned char) '\377' && I_PARMRK(tty)) n_tty_receive_char_special()
1381 kill_fasync(&tty->fasync, SIGIO, POLL_IN); n_tty_receive_char_special()
1382 wake_up_interruptible_poll(&tty->read_wait, POLLIN); n_tty_receive_char_special()
1387 if (L_ECHO(tty)) { n_tty_receive_char_special()
1395 echo_char(c, tty); n_tty_receive_char_special()
1397 commit_echoes(tty); n_tty_receive_char_special()
1401 if (c == (unsigned char) '\377' && I_PARMRK(tty)) n_tty_receive_char_special()
1409 n_tty_receive_char_inline(struct tty_struct *tty, unsigned char c) n_tty_receive_char_inline() argument
1411 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_char_inline()
1413 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { n_tty_receive_char_inline()
1414 start_tty(tty); n_tty_receive_char_inline()
1415 process_echoes(tty); n_tty_receive_char_inline()
1417 if (L_ECHO(tty)) { n_tty_receive_char_inline()
1422 echo_char(c, tty); n_tty_receive_char_inline()
1423 commit_echoes(tty); n_tty_receive_char_inline()
1426 if (c == (unsigned char) '\377' && I_PARMRK(tty)) n_tty_receive_char_inline()
1431 static void n_tty_receive_char(struct tty_struct *tty, unsigned char c) n_tty_receive_char() argument
1433 n_tty_receive_char_inline(tty, c); n_tty_receive_char()
1437 n_tty_receive_char_fast(struct tty_struct *tty, unsigned char c) n_tty_receive_char_fast() argument
1439 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_char_fast()
1441 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && I_IXANY(tty)) { n_tty_receive_char_fast()
1442 start_tty(tty); n_tty_receive_char_fast()
1443 process_echoes(tty); n_tty_receive_char_fast()
1445 if (L_ECHO(tty)) { n_tty_receive_char_fast()
1450 echo_char(c, tty); n_tty_receive_char_fast()
1451 commit_echoes(tty); n_tty_receive_char_fast()
1456 static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c) n_tty_receive_char_closing() argument
1458 if (I_ISTRIP(tty)) n_tty_receive_char_closing()
1460 if (I_IUCLC(tty) && L_IEXTEN(tty)) n_tty_receive_char_closing()
1463 if (I_IXON(tty)) { n_tty_receive_char_closing()
1464 if (c == STOP_CHAR(tty)) n_tty_receive_char_closing()
1465 stop_tty(tty); n_tty_receive_char_closing()
1466 else if (c == START_CHAR(tty) || n_tty_receive_char_closing()
1467 (tty->stopped && !tty->flow_stopped && I_IXANY(tty) && n_tty_receive_char_closing()
1468 c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) && n_tty_receive_char_closing()
1469 c != SUSP_CHAR(tty))) { n_tty_receive_char_closing()
1470 start_tty(tty); n_tty_receive_char_closing()
1471 process_echoes(tty); n_tty_receive_char_closing()
1477 n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag) n_tty_receive_char_flagged() argument
1483 n_tty_receive_break(tty); n_tty_receive_char_flagged()
1487 n_tty_receive_parity_error(tty, c); n_tty_receive_char_flagged()
1490 n_tty_receive_overrun(tty); n_tty_receive_char_flagged()
1494 tty_name(tty, buf), flag); n_tty_receive_char_flagged()
1500 n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag) n_tty_receive_char_lnext() argument
1502 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_char_lnext()
1506 if (I_ISTRIP(tty)) n_tty_receive_char_lnext()
1508 if (I_IUCLC(tty) && L_IEXTEN(tty)) n_tty_receive_char_lnext()
1510 n_tty_receive_char(tty, c); n_tty_receive_char_lnext()
1512 n_tty_receive_char_flagged(tty, c, flag); n_tty_receive_char_lnext()
1516 n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp, n_tty_receive_buf_real_raw() argument
1519 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_buf_real_raw()
1536 n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp, n_tty_receive_buf_raw() argument
1539 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_buf_raw()
1548 n_tty_receive_char_flagged(tty, *cp++, flag); n_tty_receive_buf_raw()
1553 n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp, n_tty_receive_buf_closing() argument
1562 n_tty_receive_char_closing(tty, *cp++); n_tty_receive_buf_closing()
1564 n_tty_receive_char_flagged(tty, *cp++, flag); n_tty_receive_buf_closing()
1569 n_tty_receive_buf_standard(struct tty_struct *tty, const unsigned char *cp, n_tty_receive_buf_standard() argument
1572 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_buf_standard()
1581 if (I_ISTRIP(tty)) n_tty_receive_buf_standard()
1583 if (I_IUCLC(tty) && L_IEXTEN(tty)) n_tty_receive_buf_standard()
1585 if (L_EXTPROC(tty)) { n_tty_receive_buf_standard()
1590 n_tty_receive_char_inline(tty, c); n_tty_receive_buf_standard()
1591 else if (n_tty_receive_char_special(tty, c) && count) { n_tty_receive_buf_standard()
1594 n_tty_receive_char_lnext(tty, *cp++, flag); n_tty_receive_buf_standard()
1598 n_tty_receive_char_flagged(tty, *cp++, flag); n_tty_receive_buf_standard()
1603 n_tty_receive_buf_fast(struct tty_struct *tty, const unsigned char *cp, n_tty_receive_buf_fast() argument
1606 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_buf_fast()
1616 n_tty_receive_char_fast(tty, c); n_tty_receive_buf_fast()
1617 else if (n_tty_receive_char_special(tty, c) && count) { n_tty_receive_buf_fast()
1620 n_tty_receive_char_lnext(tty, *cp++, flag); n_tty_receive_buf_fast()
1624 n_tty_receive_char_flagged(tty, *cp++, flag); n_tty_receive_buf_fast()
1628 static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, __receive_buf() argument
1631 struct n_tty_data *ldata = tty->disc_data; __receive_buf()
1632 bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty)); __receive_buf()
1635 n_tty_receive_buf_real_raw(tty, cp, fp, count); __receive_buf()
1636 else if (ldata->raw || (L_EXTPROC(tty) && !preops)) __receive_buf()
1637 n_tty_receive_buf_raw(tty, cp, fp, count); __receive_buf()
1638 else if (tty->closing && !L_EXTPROC(tty)) __receive_buf()
1639 n_tty_receive_buf_closing(tty, cp, fp, count); __receive_buf()
1646 n_tty_receive_char_lnext(tty, *cp++, flag); __receive_buf()
1650 if (!preops && !I_PARMRK(tty)) __receive_buf()
1651 n_tty_receive_buf_fast(tty, cp, fp, count); __receive_buf()
1653 n_tty_receive_buf_standard(tty, cp, fp, count); __receive_buf()
1655 flush_echoes(tty); __receive_buf()
1656 if (tty->ops->flush_chars) __receive_buf()
1657 tty->ops->flush_chars(tty); __receive_buf()
1660 if (ldata->icanon && !L_EXTPROC(tty)) __receive_buf()
1666 if ((read_cnt(ldata) >= ldata->minimum_to_wake) || L_EXTPROC(tty)) { __receive_buf()
1667 kill_fasync(&tty->fasync, SIGIO, POLL_IN); __receive_buf()
1668 wake_up_interruptible_poll(&tty->read_wait, POLLIN); __receive_buf()
1674 * @tty: device to receive input
1689 * not stored. Overflow processing ensures the tty can always
1706 n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, n_tty_receive_buf_common() argument
1709 struct n_tty_data *ldata = tty->disc_data; n_tty_receive_buf_common()
1712 down_read(&tty->termios_rwsem); n_tty_receive_buf_common()
1731 if (I_PARMRK(tty)) n_tty_receive_buf_common()
1749 __receive_buf(tty, cp, fp, n); n_tty_receive_buf_common()
1758 tty->receive_room = room; n_tty_receive_buf_common()
1761 if (tty->driver->type == TTY_DRIVER_TYPE_PTY) { n_tty_receive_buf_common()
1763 tty_set_flow_change(tty, TTY_UNTHROTTLE_SAFE); n_tty_receive_buf_common()
1764 tty_unthrottle_safe(tty); n_tty_receive_buf_common()
1765 __tty_set_flow_change(tty, 0); n_tty_receive_buf_common()
1768 n_tty_check_throttle(tty); n_tty_receive_buf_common()
1770 up_read(&tty->termios_rwsem); n_tty_receive_buf_common()
1775 static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, n_tty_receive_buf() argument
1778 n_tty_receive_buf_common(tty, cp, fp, count, 0); n_tty_receive_buf()
1781 static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, n_tty_receive_buf2() argument
1784 return n_tty_receive_buf_common(tty, cp, fp, count, 1); n_tty_receive_buf2()
1795 * @tty: terminal
1798 * Called by the tty layer when the user changes termios flags so
1800 * and is protected from re-entry by the tty layer. The user is
1804 * Locking: Caller holds tty->termios_rwsem
1807 static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) n_tty_set_termios() argument
1809 struct n_tty_data *ldata = tty->disc_data; n_tty_set_termios()
1811 if (!old || (old->c_lflag ^ tty->termios.c_lflag) & ICANON) { n_tty_set_termios()
1814 if (!L_ICANON(tty) || !read_cnt(ldata)) { n_tty_set_termios()
1828 ldata->icanon = (L_ICANON(tty) != 0); n_tty_set_termios()
1830 if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) || n_tty_set_termios()
1831 I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) || n_tty_set_termios()
1832 I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) || n_tty_set_termios()
1833 I_PARMRK(tty)) { n_tty_set_termios()
1836 if (I_IGNCR(tty) || I_ICRNL(tty)) n_tty_set_termios()
1838 if (I_INLCR(tty)) n_tty_set_termios()
1841 if (L_ICANON(tty)) { n_tty_set_termios()
1842 set_bit(ERASE_CHAR(tty), ldata->char_map); n_tty_set_termios()
1843 set_bit(KILL_CHAR(tty), ldata->char_map); n_tty_set_termios()
1844 set_bit(EOF_CHAR(tty), ldata->char_map); n_tty_set_termios()
1846 set_bit(EOL_CHAR(tty), ldata->char_map); n_tty_set_termios()
1847 if (L_IEXTEN(tty)) { n_tty_set_termios()
1848 set_bit(WERASE_CHAR(tty), ldata->char_map); n_tty_set_termios()
1849 set_bit(LNEXT_CHAR(tty), ldata->char_map); n_tty_set_termios()
1850 set_bit(EOL2_CHAR(tty), ldata->char_map); n_tty_set_termios()
1851 if (L_ECHO(tty)) n_tty_set_termios()
1852 set_bit(REPRINT_CHAR(tty), n_tty_set_termios()
1856 if (I_IXON(tty)) { n_tty_set_termios()
1857 set_bit(START_CHAR(tty), ldata->char_map); n_tty_set_termios()
1858 set_bit(STOP_CHAR(tty), ldata->char_map); n_tty_set_termios()
1860 if (L_ISIG(tty)) { n_tty_set_termios()
1861 set_bit(INTR_CHAR(tty), ldata->char_map); n_tty_set_termios()
1862 set_bit(QUIT_CHAR(tty), ldata->char_map); n_tty_set_termios()
1863 set_bit(SUSP_CHAR(tty), ldata->char_map); n_tty_set_termios()
1870 if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) && n_tty_set_termios()
1871 (I_IGNPAR(tty) || !I_INPCK(tty)) && n_tty_set_termios()
1872 (tty->driver->flags & TTY_DRIVER_REAL_RAW)) n_tty_set_termios()
1878 * Fix tty hang when I_IXON(tty) is cleared, but the tty n_tty_set_termios()
1879 * been stopped by STOP_CHAR(tty) before it. n_tty_set_termios()
1881 if (!I_IXON(tty) && old && (old->c_iflag & IXON) && !tty->flow_stopped) { n_tty_set_termios()
1882 start_tty(tty); n_tty_set_termios()
1883 process_echoes(tty); n_tty_set_termios()
1886 /* The termios change make the tty ready for I/O */ n_tty_set_termios()
1887 wake_up_interruptible(&tty->write_wait); n_tty_set_termios()
1888 wake_up_interruptible(&tty->read_wait); n_tty_set_termios()
1892 * n_tty_close - close the ldisc for this tty
1893 * @tty: device
1901 static void n_tty_close(struct tty_struct *tty) n_tty_close() argument
1903 struct n_tty_data *ldata = tty->disc_data; n_tty_close()
1905 if (tty->link) n_tty_close()
1906 n_tty_packet_mode_flush(tty); n_tty_close()
1909 tty->disc_data = NULL; n_tty_close()
1914 * @tty: terminal to open
1922 static int n_tty_open(struct tty_struct *tty) n_tty_open() argument
1935 tty->disc_data = ldata; n_tty_open()
1936 reset_buffer_flags(tty->disc_data); n_tty_open()
1943 tty->closing = 0; n_tty_open()
1945 clear_bit(TTY_LDISC_HALTED, &tty->flags); n_tty_open()
1946 n_tty_set_termios(tty, NULL); n_tty_open()
1947 tty_unthrottle(tty); n_tty_open()
1954 static inline int input_available_p(struct tty_struct *tty, int poll) input_available_p() argument
1956 struct n_tty_data *ldata = tty->disc_data; input_available_p()
1957 int amt = poll && !TIME_CHAR(tty) && MIN_CHAR(tty) ? MIN_CHAR(tty) : 1; input_available_p()
1959 if (ldata->icanon && !L_EXTPROC(tty)) input_available_p()
1967 * @tty: terminal device
1972 * ICANON is off; it copies characters straight from the tty queue to
1985 static int copy_from_read_buf(struct tty_struct *tty, copy_from_read_buf() argument
1990 struct n_tty_data *ldata = tty->disc_data; copy_from_read_buf()
2003 is_eof = n == 1 && read_buf(ldata, tail) == EOF_CHAR(tty); copy_from_read_buf()
2004 tty_audit_add_data(tty, read_buf_addr(ldata, tail), n, copy_from_read_buf()
2008 if (L_EXTPROC(tty) && ldata->icanon && is_eof && copy_from_read_buf()
2019 * @tty: terminal device
2040 static int canon_copy_from_read_buf(struct tty_struct *tty, canon_copy_from_read_buf() argument
2044 struct n_tty_data *ldata = tty->disc_data; canon_copy_from_read_buf()
2088 ret = tty_copy_to_user(tty, *b, read_buf_addr(ldata, tail), size); canon_copy_from_read_buf()
2091 ret = tty_copy_to_user(tty, *b + size, ldata->read_buf, n - size); canon_copy_from_read_buf()
2093 ret = tty_copy_to_user(tty, *b, read_buf_addr(ldata, tail), n); canon_copy_from_read_buf()
2109 tty_audit_push(tty); canon_copy_from_read_buf()
2119 * @tty: tty
2122 * Perform job control management checks on this file/tty descriptor
2127 * current->signal->tty check is safe
2128 * ctrl_lock to safely reference tty->pgrp
2131 static int job_control(struct tty_struct *tty, struct file *file) job_control() argument
2139 current->signal->tty != tty) job_control()
2142 spin_lock_irq(&tty->ctrl_lock); job_control()
2143 if (!tty->pgrp) job_control()
2144 printk(KERN_ERR "n_tty_read: no tty->pgrp!\n"); job_control()
2145 else if (task_pgrp(current) != tty->pgrp) { job_control()
2146 spin_unlock_irq(&tty->ctrl_lock); job_control()
2153 spin_unlock_irq(&tty->ctrl_lock); job_control()
2159 * n_tty_read - read function for tty
2160 * @tty: tty device
2177 static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, n_tty_read() argument
2180 struct n_tty_data *ldata = tty->disc_data; n_tty_read()
2190 c = job_control(tty, file); n_tty_read()
2205 down_read(&tty->termios_rwsem); n_tty_read()
2210 minimum = MIN_CHAR(tty); n_tty_read()
2212 time = (HZ / 10) * TIME_CHAR(tty); n_tty_read()
2215 else if (!waitqueue_active(&tty->read_wait) || n_tty_read()
2219 timeout = (HZ / 10) * TIME_CHAR(tty); n_tty_read()
2224 packet = tty->packet; n_tty_read()
2227 add_wait_queue(&tty->read_wait, &wait); n_tty_read()
2230 if (packet && tty->link->ctrl_status) { n_tty_read()
2234 spin_lock_irq(&tty->link->ctrl_lock); n_tty_read()
2235 cs = tty->link->ctrl_status; n_tty_read()
2236 tty->link->ctrl_status = 0; n_tty_read()
2237 spin_unlock_irq(&tty->link->ctrl_lock); n_tty_read()
2238 if (tty_put_user(tty, cs, b++)) { n_tty_read()
2251 if (!input_available_p(tty, 0)) { n_tty_read()
2252 up_read(&tty->termios_rwsem); n_tty_read()
2253 tty_buffer_flush_work(tty->port); n_tty_read()
2254 down_read(&tty->termios_rwsem); n_tty_read()
2255 if (!input_available_p(tty, 0)) { n_tty_read()
2256 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { n_tty_read()
2272 up_read(&tty->termios_rwsem); n_tty_read()
2277 down_read(&tty->termios_rwsem); n_tty_read()
2282 if (ldata->icanon && !L_EXTPROC(tty)) { n_tty_read()
2283 retval = canon_copy_from_read_buf(tty, &b, &nr); n_tty_read()
2294 if (tty_put_user(tty, TIOCPKT_DATA, b++)) { n_tty_read()
2302 uncopied = copy_from_read_buf(tty, &b, &nr); n_tty_read()
2303 uncopied += copy_from_read_buf(tty, &b, &nr); n_tty_read()
2310 n_tty_check_unthrottle(tty); n_tty_read()
2318 n_tty_kick_worker(tty); n_tty_read()
2319 up_read(&tty->termios_rwsem); n_tty_read()
2321 remove_wait_queue(&tty->read_wait, &wait); n_tty_read()
2322 if (!waitqueue_active(&tty->read_wait)) n_tty_read()
2334 * n_tty_write - write function for tty
2335 * @tty: tty device
2355 static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, n_tty_write() argument
2364 if (L_TOSTOP(tty) && file->f_op->write != redirected_tty_write) { n_tty_write()
2365 retval = tty_check_change(tty); n_tty_write()
2370 down_read(&tty->termios_rwsem); n_tty_write()
2373 process_echoes(tty); n_tty_write()
2375 add_wait_queue(&tty->write_wait, &wait); n_tty_write()
2381 if (tty_hung_up_p(file) || (tty->link && !tty->link->count)) { n_tty_write()
2385 if (O_OPOST(tty)) { n_tty_write()
2387 ssize_t num = process_output_block(tty, b, nr); n_tty_write()
2399 if (process_output(c, tty) < 0) n_tty_write()
2403 if (tty->ops->flush_chars) n_tty_write()
2404 tty->ops->flush_chars(tty); n_tty_write()
2406 struct n_tty_data *ldata = tty->disc_data; n_tty_write()
2410 c = tty->ops->write(tty, b, nr); n_tty_write()
2428 up_read(&tty->termios_rwsem); n_tty_write()
2432 down_read(&tty->termios_rwsem); n_tty_write()
2435 remove_wait_queue(&tty->write_wait, &wait); n_tty_write()
2436 if (b - buf != nr && tty->fasync) n_tty_write()
2437 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); n_tty_write()
2438 up_read(&tty->termios_rwsem); n_tty_write()
2444 * @tty: terminal device
2456 static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file, n_tty_poll() argument
2459 struct n_tty_data *ldata = tty->disc_data; n_tty_poll()
2462 poll_wait(file, &tty->read_wait, wait); n_tty_poll()
2463 poll_wait(file, &tty->write_wait, wait); n_tty_poll()
2464 if (input_available_p(tty, 1)) n_tty_poll()
2467 tty_buffer_flush_work(tty->port); n_tty_poll()
2468 if (input_available_p(tty, 1)) n_tty_poll()
2471 if (tty->packet && tty->link->ctrl_status) n_tty_poll()
2473 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) n_tty_poll()
2478 if (MIN_CHAR(tty) && !TIME_CHAR(tty)) n_tty_poll()
2479 ldata->minimum_to_wake = MIN_CHAR(tty); n_tty_poll()
2483 if (tty->ops->write && !tty_is_writelocked(tty) && n_tty_poll()
2484 tty_chars_in_buffer(tty) < WAKEUP_CHARS && n_tty_poll()
2485 tty_write_room(tty) > 0) n_tty_poll()
2509 static int n_tty_ioctl(struct tty_struct *tty, struct file *file, n_tty_ioctl() argument
2512 struct n_tty_data *ldata = tty->disc_data; n_tty_ioctl()
2517 return put_user(tty_chars_in_buffer(tty), (int __user *) arg); n_tty_ioctl()
2519 down_write(&tty->termios_rwsem); n_tty_ioctl()
2520 if (L_ICANON(tty)) n_tty_ioctl()
2524 up_write(&tty->termios_rwsem); n_tty_ioctl()
2527 return n_tty_ioctl_helper(tty, file, cmd, arg); n_tty_ioctl()
2531 static void n_tty_fasync(struct tty_struct *tty, int on) n_tty_fasync() argument
2533 struct n_tty_data *ldata = tty->disc_data; n_tty_fasync()
2535 if (!waitqueue_active(&tty->read_wait)) { n_tty_fasync()
2538 else if (!tty->fasync) n_tty_fasync()
H A Dpty.c13 #include <linux/tty.h>
36 static void pty_close(struct tty_struct *tty, struct file *filp) pty_close() argument
38 BUG_ON(!tty); pty_close()
39 if (tty->driver->subtype == PTY_TYPE_MASTER) pty_close()
40 WARN_ON(tty->count > 1); pty_close()
42 if (test_bit(TTY_IO_ERROR, &tty->flags)) pty_close()
44 if (tty->count > 2) pty_close()
47 set_bit(TTY_IO_ERROR, &tty->flags); pty_close()
48 wake_up_interruptible(&tty->read_wait); pty_close()
49 wake_up_interruptible(&tty->write_wait); pty_close()
50 spin_lock_irq(&tty->ctrl_lock); pty_close()
51 tty->packet = 0; pty_close()
52 spin_unlock_irq(&tty->ctrl_lock); pty_close()
54 if (!tty->link) pty_close()
56 set_bit(TTY_OTHER_CLOSED, &tty->link->flags); pty_close()
57 wake_up_interruptible(&tty->link->read_wait); pty_close()
58 wake_up_interruptible(&tty->link->write_wait); pty_close()
59 if (tty->driver->subtype == PTY_TYPE_MASTER) { pty_close()
60 set_bit(TTY_OTHER_CLOSED, &tty->flags); pty_close()
62 if (tty->driver == ptm_driver) { pty_close()
64 if (tty->link->driver_data) pty_close()
65 devpts_pty_kill(tty->link->driver_data); pty_close()
69 tty_vhangup(tty->link); pty_close()
83 static void pty_unthrottle(struct tty_struct *tty) pty_unthrottle() argument
85 tty_wakeup(tty->link); pty_unthrottle()
86 set_bit(TTY_THROTTLED, &tty->flags); pty_unthrottle()
91 * @tty: the tty we write from
98 * the other side of the pty/tty pair.
101 static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) pty_write() argument
103 struct tty_struct *to = tty->link; pty_write()
105 if (tty->stopped) pty_write()
120 * @tty: tty we are writing from
126 static int pty_write_room(struct tty_struct *tty) pty_write_room() argument
128 if (tty->stopped) pty_write_room()
130 return tty_buffer_space_avail(tty->link->port); pty_write_room()
135 * @tty: our tty
141 static int pty_chars_in_buffer(struct tty_struct *tty) pty_chars_in_buffer() argument
147 static int pty_set_lock(struct tty_struct *tty, int __user *arg) pty_set_lock() argument
153 set_bit(TTY_PTY_LOCK, &tty->flags); pty_set_lock()
155 clear_bit(TTY_PTY_LOCK, &tty->flags); pty_set_lock()
159 static int pty_get_lock(struct tty_struct *tty, int __user *arg) pty_get_lock() argument
161 int locked = test_bit(TTY_PTY_LOCK, &tty->flags); pty_get_lock()
166 static int pty_set_pktmode(struct tty_struct *tty, int __user *arg) pty_set_pktmode() argument
173 spin_lock_irq(&tty->ctrl_lock); pty_set_pktmode()
175 if (!tty->packet) { pty_set_pktmode()
176 tty->link->ctrl_status = 0; pty_set_pktmode()
178 tty->packet = 1; pty_set_pktmode()
181 tty->packet = 0; pty_set_pktmode()
182 spin_unlock_irq(&tty->ctrl_lock); pty_set_pktmode()
188 static int pty_get_pktmode(struct tty_struct *tty, int __user *arg) pty_get_pktmode() argument
190 int pktmode = tty->packet; pty_get_pktmode()
195 static int pty_signal(struct tty_struct *tty, int sig) pty_signal() argument
202 if (tty->link) { pty_signal()
203 pgrp = tty_get_pgrp(tty->link); pty_signal()
211 static void pty_flush_buffer(struct tty_struct *tty) pty_flush_buffer() argument
213 struct tty_struct *to = tty->link; pty_flush_buffer()
225 spin_lock_irq(&tty->ctrl_lock); pty_flush_buffer()
226 tty->ctrl_status |= TIOCPKT_FLUSHWRITE; pty_flush_buffer()
228 spin_unlock_irq(&tty->ctrl_lock); pty_flush_buffer()
232 static int pty_open(struct tty_struct *tty, struct file *filp) pty_open() argument
234 if (!tty || !tty->link) pty_open()
237 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) pty_open()
239 if (test_bit(TTY_PTY_LOCK, &tty->link->flags)) pty_open()
241 if (tty->driver->subtype == PTY_TYPE_SLAVE && tty->link->count != 1) pty_open()
244 clear_bit(TTY_IO_ERROR, &tty->flags); pty_open()
245 clear_bit(TTY_OTHER_CLOSED, &tty->link->flags); pty_open()
246 set_bit(TTY_THROTTLED, &tty->flags); pty_open()
250 set_bit(TTY_IO_ERROR, &tty->flags); pty_open()
254 static void pty_set_termios(struct tty_struct *tty, pty_set_termios() argument
258 if (tty->link && tty->link->packet) { pty_set_termios()
260 (tty->termios.c_lflag & EXTPROC); pty_set_termios()
264 int new_flow = (I_IXON(tty) && pty_set_termios()
265 STOP_CHAR(tty) == '\023' && pty_set_termios()
266 START_CHAR(tty) == '\021'); pty_set_termios()
268 spin_lock_irq(&tty->ctrl_lock); pty_set_termios()
270 tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); pty_set_termios()
272 tty->ctrl_status |= TIOCPKT_DOSTOP; pty_set_termios()
274 tty->ctrl_status |= TIOCPKT_NOSTOP; pty_set_termios()
277 tty->ctrl_status |= TIOCPKT_IOCTL; pty_set_termios()
278 spin_unlock_irq(&tty->ctrl_lock); pty_set_termios()
279 wake_up_interruptible(&tty->link->read_wait); pty_set_termios()
283 tty->termios.c_cflag &= ~(CSIZE | PARENB); pty_set_termios()
284 tty->termios.c_cflag |= (CS8 | CREAD); pty_set_termios()
289 * @tty: tty being resized
296 static int pty_resize(struct tty_struct *tty, struct winsize *ws) pty_resize() argument
299 struct tty_struct *pty = tty->link; pty_resize()
301 /* For a PTY we need to lock the tty side */ pty_resize()
302 mutex_lock(&tty->winsize_mutex); pty_resize()
303 if (!memcmp(ws, &tty->winsize, sizeof(*ws))) pty_resize()
307 pgrp = tty_get_pgrp(tty); pty_resize()
318 tty->winsize = *ws; pty_resize()
321 mutex_unlock(&tty->winsize_mutex); pty_resize()
328 * @tty: tty being flow-controlled
335 static void pty_start(struct tty_struct *tty) pty_start() argument
339 if (tty->link && tty->link->packet) { pty_start()
340 spin_lock_irqsave(&tty->ctrl_lock, flags); pty_start()
341 tty->ctrl_status &= ~TIOCPKT_STOP; pty_start()
342 tty->ctrl_status |= TIOCPKT_START; pty_start()
343 spin_unlock_irqrestore(&tty->ctrl_lock, flags); pty_start()
344 wake_up_interruptible_poll(&tty->link->read_wait, POLLIN); pty_start()
348 static void pty_stop(struct tty_struct *tty) pty_stop() argument
352 if (tty->link && tty->link->packet) { pty_stop()
353 spin_lock_irqsave(&tty->ctrl_lock, flags); pty_stop()
354 tty->ctrl_status &= ~TIOCPKT_START; pty_stop()
355 tty->ctrl_status |= TIOCPKT_STOP; pty_stop()
356 spin_unlock_irqrestore(&tty->ctrl_lock, flags); pty_stop()
357 wake_up_interruptible_poll(&tty->link->read_wait, POLLIN); pty_stop()
364 * @tty: the tty being instantiated
367 * Perform the initial set up for the tty/pty pair. Called from the
368 * tty layer when the port is first opened.
372 static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty, pty_common_install() argument
377 int idx = tty->index; pty_common_install()
400 /* We always use new tty termios data so we can do this pty_common_install()
402 retval = tty_init_termios(tty); pty_common_install()
411 driver->ttys[idx] = tty; pty_common_install()
413 memset(&tty->termios_locked, 0, sizeof(tty->termios_locked)); pty_common_install()
414 tty->termios = driver->init_termios; pty_common_install()
415 memset(&o_tty->termios_locked, 0, sizeof(tty->termios_locked)); pty_common_install()
424 tty->link = o_tty; pty_common_install()
425 o_tty->link = tty; pty_common_install()
431 tty->port = ports[1]; pty_common_install()
437 tty->count++; pty_common_install()
442 tty_free_termios(tty); pty_common_install()
454 static void pty_cleanup(struct tty_struct *tty) pty_cleanup() argument
456 tty_port_put(tty->port); pty_cleanup()
462 static int pty_install(struct tty_driver *driver, struct tty_struct *tty) pty_install() argument
464 return pty_common_install(driver, tty, true); pty_install()
467 static void pty_remove(struct tty_driver *driver, struct tty_struct *tty) pty_remove() argument
469 struct tty_struct *pair = tty->link; pty_remove()
470 driver->ttys[tty->index] = NULL; pty_remove()
475 static int pty_bsd_ioctl(struct tty_struct *tty, pty_bsd_ioctl() argument
480 return pty_set_lock(tty, (int __user *) arg); pty_bsd_ioctl()
482 return pty_get_lock(tty, (int __user *)arg); pty_bsd_ioctl()
484 return pty_set_pktmode(tty, (int __user *)arg); pty_bsd_ioctl()
486 return pty_get_pktmode(tty, (int __user *)arg); pty_bsd_ioctl()
488 return pty_signal(tty, (int) arg); pty_bsd_ioctl()
598 static int pty_unix98_ioctl(struct tty_struct *tty, pty_unix98_ioctl() argument
603 return pty_set_lock(tty, (int __user *)arg); pty_unix98_ioctl()
605 return pty_get_lock(tty, (int __user *)arg); pty_unix98_ioctl()
607 return pty_set_pktmode(tty, (int __user *)arg); pty_unix98_ioctl()
609 return pty_get_pktmode(tty, (int __user *)arg); pty_unix98_ioctl()
611 return put_user(tty->index, (unsigned int __user *)arg); pty_unix98_ioctl()
613 return pty_signal(tty, (int) arg); pty_unix98_ioctl()
622 * @idx: tty index
638 * @idx: tty index
641 * This provides our locking for the tty pointer.
647 struct tty_struct *tty; pts_unix98_lookup() local
650 tty = devpts_get_priv(pts_inode); pts_unix98_lookup()
653 if (!tty) pts_unix98_lookup()
655 return tty; pts_unix98_lookup()
658 /* We have no need to install and remove our tty objects as devpts does all
661 static int pty_unix98_install(struct tty_driver *driver, struct tty_struct *tty) pty_unix98_install() argument
663 return pty_common_install(driver, tty, false); pty_unix98_install()
666 static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) pty_unix98_remove() argument
671 static void pty_unix98_shutdown(struct tty_struct *tty) pty_unix98_shutdown() argument
675 if (tty->driver->subtype == PTY_TYPE_MASTER) pty_unix98_shutdown()
676 ptmx_inode = tty->driver_data; pty_unix98_shutdown()
678 ptmx_inode = tty->link->driver_data; pty_unix98_shutdown()
679 devpts_kill_index(ptmx_inode, tty->index); pty_unix98_shutdown()
721 * @filp: file pointer to tty
725 * Locking: tty_mutex protects the init_dev work. tty->count should
732 struct tty_struct *tty; ptmx_open() local
758 tty = tty_init_dev(ptm_driver, index); ptmx_open()
760 if (IS_ERR(tty)) { ptmx_open()
761 retval = PTR_ERR(tty); ptmx_open()
765 /* The tty returned here is locked so we can safely ptmx_open()
769 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ ptmx_open()
770 tty->driver_data = inode; ptmx_open()
774 * still have /dev/tty opened pointing to the master/slave pair (ptmx ptmx_open()
775 * is closed/released before /dev/tty), we must make sure that the inode ptmx_open()
777 * hold an additional reference to the ptmx inode. For the same /dev/tty ptmx_open()
779 * destroyed (devpts instance unmounted), before /dev/tty is closed and ptmx_open()
784 tty_add_file(tty, filp); ptmx_open()
788 tty->link); ptmx_open()
793 tty->link->driver_data = slave_inode; ptmx_open()
795 retval = ptm_driver->ops->open(tty, filp); ptmx_open()
799 tty_unlock(tty); ptmx_open()
802 tty_unlock(tty); ptmx_open()
H A Dtty_ioctl.c15 #include <linux/tty.h>
42 * @tty: terminal
49 int tty_chars_in_buffer(struct tty_struct *tty) tty_chars_in_buffer() argument
51 if (tty->ops->chars_in_buffer) tty_chars_in_buffer()
52 return tty->ops->chars_in_buffer(tty); tty_chars_in_buffer()
60 * @tty: terminal
69 int tty_write_room(struct tty_struct *tty) tty_write_room() argument
71 if (tty->ops->write_room) tty_write_room()
72 return tty->ops->write_room(tty); tty_write_room()
79 * @tty: terminal
85 void tty_driver_flush_buffer(struct tty_struct *tty) tty_driver_flush_buffer() argument
87 if (tty->ops->flush_buffer) tty_driver_flush_buffer()
88 tty->ops->flush_buffer(tty); tty_driver_flush_buffer()
94 * @tty: terminal
96 * Indicate that a tty should stop transmitting data down the stack.
102 void tty_throttle(struct tty_struct *tty) tty_throttle() argument
104 down_write(&tty->termios_rwsem); tty_throttle()
106 if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) && tty_throttle()
107 tty->ops->throttle) tty_throttle()
108 tty->ops->throttle(tty); tty_throttle()
109 tty->flow_change = 0; tty_throttle()
110 up_write(&tty->termios_rwsem); tty_throttle()
116 * @tty: terminal
118 * Indicate that a tty may continue transmitting data down the stack.
127 void tty_unthrottle(struct tty_struct *tty) tty_unthrottle() argument
129 down_write(&tty->termios_rwsem); tty_unthrottle()
130 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && tty_unthrottle()
131 tty->ops->unthrottle) tty_unthrottle()
132 tty->ops->unthrottle(tty); tty_unthrottle()
133 tty->flow_change = 0; tty_unthrottle()
134 up_write(&tty->termios_rwsem); tty_unthrottle()
140 * @tty: terminal
143 * if tty->flow_change is TTY_THROTTLE_SAFE. Prevents an accidental
147 * Returns 0 if tty is throttled (or was already throttled)
150 int tty_throttle_safe(struct tty_struct *tty) tty_throttle_safe() argument
154 mutex_lock(&tty->throttle_mutex); tty_throttle_safe()
155 if (!test_bit(TTY_THROTTLED, &tty->flags)) { tty_throttle_safe()
156 if (tty->flow_change != TTY_THROTTLE_SAFE) tty_throttle_safe()
159 set_bit(TTY_THROTTLED, &tty->flags); tty_throttle_safe()
160 if (tty->ops->throttle) tty_throttle_safe()
161 tty->ops->throttle(tty); tty_throttle_safe()
164 mutex_unlock(&tty->throttle_mutex); tty_throttle_safe()
171 * @tty: terminal
174 * if tty->flow_change is TTY_UNTHROTTLE_SAFE. Prevents an accidental
178 * Returns 0 if tty is unthrottled (or was already unthrottled)
181 int tty_unthrottle_safe(struct tty_struct *tty) tty_unthrottle_safe() argument
185 mutex_lock(&tty->throttle_mutex); tty_unthrottle_safe()
186 if (test_bit(TTY_THROTTLED, &tty->flags)) { tty_unthrottle_safe()
187 if (tty->flow_change != TTY_UNTHROTTLE_SAFE) tty_unthrottle_safe()
190 clear_bit(TTY_THROTTLED, &tty->flags); tty_unthrottle_safe()
191 if (tty->ops->unthrottle) tty_unthrottle_safe()
192 tty->ops->unthrottle(tty); tty_unthrottle_safe()
195 mutex_unlock(&tty->throttle_mutex); tty_unthrottle_safe()
202 * @tty: tty we are waiting for
205 * Wait for characters pending in a tty driver to hit the wire, or
211 void tty_wait_until_sent(struct tty_struct *tty, long timeout) tty_wait_until_sent() argument
216 printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf)); tty_wait_until_sent()
221 timeout = wait_event_interruptible_timeout(tty->write_wait, tty_wait_until_sent()
222 !tty_chars_in_buffer(tty), timeout); tty_wait_until_sent()
229 if (tty->ops->wait_until_sent) tty_wait_until_sent()
230 tty->ops->wait_until_sent(tty, timeout); tty_wait_until_sent()
264 * Routine which returns the baud rate of the tty
464 printk_once(KERN_WARNING "tty: Unable to return correct " tty_termios_encode_baud_rate()
472 * tty_encode_baud_rate - set baud rate of the tty
476 * Update the current termios data for the tty with the new speed
477 * settings. The caller must hold the termios_rwsem for the tty in
481 void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud) tty_encode_baud_rate() argument
483 tty_termios_encode_baud_rate(&tty->termios, ibaud, obaud); tty_encode_baud_rate()
530 * @tty: tty to update
539 int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) tty_set_termios() argument
544 WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY && tty_set_termios()
545 tty->driver->subtype == PTY_TYPE_MASTER); tty_set_termios()
553 down_write(&tty->termios_rwsem); tty_set_termios()
554 old_termios = tty->termios; tty_set_termios()
555 tty->termios = *new_termios; tty_set_termios()
556 unset_locked_termios(&tty->termios, &old_termios, &tty->termios_locked); tty_set_termios()
558 if (tty->ops->set_termios) tty_set_termios()
559 tty->ops->set_termios(tty, &old_termios); tty_set_termios()
561 tty_termios_copy_hw(&tty->termios, &old_termios); tty_set_termios()
563 ld = tty_ldisc_ref(tty); tty_set_termios()
566 ld->ops->set_termios(tty, &old_termios); tty_set_termios()
569 up_write(&tty->termios_rwsem); tty_set_termios()
575 * set_termios - set termios values for a tty
576 * @tty: terminal device
587 static int set_termios(struct tty_struct *tty, void __user *arg, int opt) set_termios() argument
591 int retval = tty_check_change(tty); set_termios()
596 down_read(&tty->termios_rwsem); set_termios()
597 tmp_termios = tty->termios; set_termios()
598 up_read(&tty->termios_rwsem); set_termios()
625 ld = tty_ldisc_ref(tty);
629 ld->ops->flush_buffer(tty);
634 tty_wait_until_sent(tty, 0);
639 tty_set_termios(tty, &tmp_termios);
641 /* FIXME: Arguably if tmp_termios == tty->termios AND the
648 static void copy_termios(struct tty_struct *tty, struct ktermios *kterm) copy_termios() argument
650 down_read(&tty->termios_rwsem); copy_termios()
651 *kterm = tty->termios; copy_termios()
652 up_read(&tty->termios_rwsem); copy_termios()
655 static void copy_termios_locked(struct tty_struct *tty, struct ktermios *kterm) copy_termios_locked() argument
657 down_read(&tty->termios_rwsem); copy_termios_locked()
658 *kterm = tty->termios_locked; copy_termios_locked()
659 up_read(&tty->termios_rwsem); copy_termios_locked()
662 static int get_termio(struct tty_struct *tty, struct termio __user *termio) get_termio() argument
665 copy_termios(tty, &kterm); get_termio()
676 * @tty: terminal
684 static int set_termiox(struct tty_struct *tty, void __user *arg, int opt) set_termiox() argument
689 if (tty->termiox == NULL) set_termiox()
694 ld = tty_ldisc_ref(tty); set_termiox()
697 ld->ops->flush_buffer(tty); set_termiox()
701 tty_wait_until_sent(tty, 0); set_termiox()
706 down_write(&tty->termios_rwsem); set_termiox()
707 if (tty->ops->set_termiox) set_termiox()
708 tty->ops->set_termiox(tty, &tnew); set_termiox()
709 up_write(&tty->termios_rwsem); set_termiox()
722 static int get_sgflags(struct tty_struct *tty) get_sgflags() argument
726 if (!(tty->termios.c_lflag & ICANON)) { get_sgflags()
727 if (tty->termios.c_lflag & ISIG) get_sgflags()
732 if (tty->termios.c_lflag & ECHO) get_sgflags()
734 if (tty->termios.c_oflag & OPOST) get_sgflags()
735 if (tty->termios.c_oflag & ONLCR) get_sgflags()
740 static int get_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) get_sgttyb() argument
744 down_read(&tty->termios_rwsem); get_sgttyb()
745 tmp.sg_ispeed = tty->termios.c_ispeed; get_sgttyb()
746 tmp.sg_ospeed = tty->termios.c_ospeed; get_sgttyb()
747 tmp.sg_erase = tty->termios.c_cc[VERASE]; get_sgttyb()
748 tmp.sg_kill = tty->termios.c_cc[VKILL]; get_sgttyb()
749 tmp.sg_flags = get_sgflags(tty); get_sgttyb()
750 up_read(&tty->termios_rwsem); get_sgttyb()
783 * @tty: tty structure
792 static int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) set_sgttyb() argument
798 retval = tty_check_change(tty); set_sgttyb()
805 down_write(&tty->termios_rwsem); set_sgttyb()
806 termios = tty->termios; set_sgttyb()
815 up_write(&tty->termios_rwsem); set_sgttyb()
816 tty_set_termios(tty, &termios); set_sgttyb()
822 static int get_tchars(struct tty_struct *tty, struct tchars __user *tchars) get_tchars() argument
826 down_read(&tty->termios_rwsem); get_tchars()
827 tmp.t_intrc = tty->termios.c_cc[VINTR]; get_tchars()
828 tmp.t_quitc = tty->termios.c_cc[VQUIT]; get_tchars()
829 tmp.t_startc = tty->termios.c_cc[VSTART]; get_tchars()
830 tmp.t_stopc = tty->termios.c_cc[VSTOP]; get_tchars()
831 tmp.t_eofc = tty->termios.c_cc[VEOF]; get_tchars()
832 tmp.t_brkc = tty->termios.c_cc[VEOL2]; /* what is brkc anyway? */ get_tchars()
833 up_read(&tty->termios_rwsem); get_tchars()
837 static int set_tchars(struct tty_struct *tty, struct tchars __user *tchars) set_tchars() argument
843 down_write(&tty->termios_rwsem); set_tchars()
844 tty->termios.c_cc[VINTR] = tmp.t_intrc; set_tchars()
845 tty->termios.c_cc[VQUIT] = tmp.t_quitc; set_tchars()
846 tty->termios.c_cc[VSTART] = tmp.t_startc; set_tchars()
847 tty->termios.c_cc[VSTOP] = tmp.t_stopc; set_tchars()
848 tty->termios.c_cc[VEOF] = tmp.t_eofc; set_tchars()
849 tty->termios.c_cc[VEOL2] = tmp.t_brkc; /* what is brkc anyway? */ set_tchars()
850 up_write(&tty->termios_rwsem); set_tchars()
856 static int get_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) get_ltchars() argument
860 down_read(&tty->termios_rwsem); get_ltchars()
861 tmp.t_suspc = tty->termios.c_cc[VSUSP]; get_ltchars()
863 tmp.t_dsuspc = tty->termios.c_cc[VSUSP]; get_ltchars()
864 tmp.t_rprntc = tty->termios.c_cc[VREPRINT]; get_ltchars()
866 tmp.t_flushc = tty->termios.c_cc[VEOL2]; get_ltchars()
867 tmp.t_werasc = tty->termios.c_cc[VWERASE]; get_ltchars()
868 tmp.t_lnextc = tty->termios.c_cc[VLNEXT]; get_ltchars()
869 up_read(&tty->termios_rwsem); get_ltchars()
873 static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars) set_ltchars() argument
880 down_write(&tty->termios_rwsem); set_ltchars()
881 tty->termios.c_cc[VSUSP] = tmp.t_suspc; set_ltchars()
883 tty->termios.c_cc[VEOL2] = tmp.t_dsuspc; set_ltchars()
884 tty->termios.c_cc[VREPRINT] = tmp.t_rprntc; set_ltchars()
886 tty->termios.c_cc[VEOL2] = tmp.t_flushc; set_ltchars()
887 tty->termios.c_cc[VWERASE] = tmp.t_werasc; set_ltchars()
888 tty->termios.c_cc[VLNEXT] = tmp.t_lnextc; set_ltchars()
889 up_write(&tty->termios_rwsem); set_ltchars()
896 * @tty: tty to update
903 static int tty_change_softcar(struct tty_struct *tty, int arg) tty_change_softcar() argument
909 down_write(&tty->termios_rwsem); tty_change_softcar()
910 old = tty->termios; tty_change_softcar()
911 tty->termios.c_cflag &= ~CLOCAL; tty_change_softcar()
912 tty->termios.c_cflag |= bit; tty_change_softcar()
913 if (tty->ops->set_termios) tty_change_softcar()
914 tty->ops->set_termios(tty, &old); tty_change_softcar()
915 if ((tty->termios.c_cflag & CLOCAL) != bit) tty_change_softcar()
917 up_write(&tty->termios_rwsem); tty_change_softcar()
923 * @tty: tty for the ioctl
924 * @file: file pointer for the tty
933 int tty_mode_ioctl(struct tty_struct *tty, struct file *file, tty_mode_ioctl() argument
943 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && tty_mode_ioctl()
944 tty->driver->subtype == PTY_TYPE_MASTER) tty_mode_ioctl()
945 real_tty = tty->link; tty_mode_ioctl()
947 real_tty = tty; tty_mode_ioctl()
1078 static int __tty_perform_flush(struct tty_struct *tty, unsigned long arg) __tty_perform_flush() argument
1080 struct tty_ldisc *ld = tty->ldisc; __tty_perform_flush()
1085 ld->ops->flush_buffer(tty); __tty_perform_flush()
1086 tty_unthrottle(tty); __tty_perform_flush()
1091 ld->ops->flush_buffer(tty); __tty_perform_flush()
1092 tty_unthrottle(tty); __tty_perform_flush()
1096 tty_driver_flush_buffer(tty); __tty_perform_flush()
1104 int tty_perform_flush(struct tty_struct *tty, unsigned long arg) tty_perform_flush() argument
1107 int retval = tty_check_change(tty); tty_perform_flush()
1111 ld = tty_ldisc_ref_wait(tty); tty_perform_flush()
1112 retval = __tty_perform_flush(tty, arg); tty_perform_flush()
1119 int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, n_tty_ioctl_helper() argument
1126 retval = tty_check_change(tty); n_tty_ioctl_helper()
1131 spin_lock_irq(&tty->flow_lock); n_tty_ioctl_helper()
1132 if (!tty->flow_stopped) { n_tty_ioctl_helper()
1133 tty->flow_stopped = 1; n_tty_ioctl_helper()
1134 __stop_tty(tty); n_tty_ioctl_helper()
1136 spin_unlock_irq(&tty->flow_lock); n_tty_ioctl_helper()
1139 spin_lock_irq(&tty->flow_lock); n_tty_ioctl_helper()
1140 if (tty->flow_stopped) { n_tty_ioctl_helper()
1141 tty->flow_stopped = 0; n_tty_ioctl_helper()
1142 __start_tty(tty); n_tty_ioctl_helper()
1144 spin_unlock_irq(&tty->flow_lock); n_tty_ioctl_helper()
1147 if (STOP_CHAR(tty) != __DISABLED_CHAR) n_tty_ioctl_helper()
1148 retval = tty_send_xchar(tty, STOP_CHAR(tty)); n_tty_ioctl_helper()
1151 if (START_CHAR(tty) != __DISABLED_CHAR) n_tty_ioctl_helper()
1152 retval = tty_send_xchar(tty, START_CHAR(tty)); n_tty_ioctl_helper()
1159 retval = tty_check_change(tty); n_tty_ioctl_helper()
1162 return __tty_perform_flush(tty, arg); n_tty_ioctl_helper()
1165 return tty_mode_ioctl(tty, file, cmd, arg); n_tty_ioctl_helper()
1171 long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file, n_tty_compat_ioctl_helper() argument
1177 return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg)); n_tty_compat_ioctl_helper()
H A Dtty_io.c6 * 'tty_io.c' gives an orthogonal feeling to tty's, be they consoles
15 * dynamically allocated only when the tty is open.
18 * between the high-level tty routines (tty_io.c and tty_ioctl.c) and
19 * the low-level tty routines (serial.c, pty.c, console.c). This
30 * Added functionality to the OPOST tty handling. No delays, but all
74 #include <linux/tty.h>
113 struct ktermios tty_std_termios = { /* for the benefit of tty drivers */
127 could do with some rationalisation such as pulling the tty proc function
130 LIST_HEAD(tty_drivers); /* linked list of tty drivers */
132 /* Mutex to protect creating and releasing a tty. This is shared with
137 /* Spinlock to protect the tty->tty_files list */
155 static void release_tty(struct tty_struct *tty, int idx);
158 * free_tty_struct - free a disused tty
159 * @tty: tty struct to free
161 * Free the write buffers, tty queue and tty memory itself.
163 * Locking: none. Must be called after tty is definitely unused
166 void free_tty_struct(struct tty_struct *tty) free_tty_struct() argument
168 if (!tty) free_tty_struct()
170 put_device(tty->dev); free_tty_struct()
171 kfree(tty->write_buf); free_tty_struct()
172 tty->magic = 0xDEADDEAD; free_tty_struct()
173 kfree(tty); free_tty_struct()
178 return ((struct tty_file_private *)file->private_data)->tty; file_tty()
194 /* Associate a new file with the tty structure */ tty_add_file()
195 void tty_add_file(struct tty_struct *tty, struct file *file) tty_add_file() argument
199 priv->tty = tty; tty_add_file()
203 list_add(&priv->list, &tty->tty_files); tty_add_file()
221 /* Delete file from its tty */ tty_del_file()
233 #define TTY_NUMBER(tty) ((tty)->index + (tty)->driver->name_base)
236 * tty_name - return tty naming
237 * @tty: tty structure
240 * Convert a tty structure into a name. The name reflects the kernel
246 char *tty_name(struct tty_struct *tty, char *buf) tty_name() argument
248 if (!tty) /* Hmm. NULL pointer. That's fun. */ tty_name()
249 strcpy(buf, "NULL tty"); tty_name()
251 strcpy(buf, tty->name); tty_name()
257 int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, tty_paranoia_check() argument
261 if (!tty) { tty_paranoia_check()
267 if (tty->magic != TTY_MAGIC) { tty_paranoia_check()
269 "bad magic number for tty struct (%d:%d) in %s\n", tty_paranoia_check()
278 static int check_tty_count(struct tty_struct *tty, const char *routine) check_tty_count() argument
285 list_for_each(p, &tty->tty_files) { check_tty_count()
289 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && check_tty_count()
290 tty->driver->subtype == PTY_TYPE_SLAVE && check_tty_count()
291 tty->link && tty->link->count) check_tty_count()
293 if (tty->count != count) { check_tty_count()
294 printk(KERN_WARNING "Warning: dev (%s) tty->count(%d) " check_tty_count()
296 tty->name, tty->count, count, routine); check_tty_count()
304 * get_tty_driver - find device of a tty
306 * @index: returns the index of the tty
308 * This routine returns a tty driver structure, given a device number
331 * tty_find_polling_driver - find device of a polled tty
333 * @line: pointer to resulting tty line nr
335 * This routine returns a tty driver structure, given a name
336 * and the condition that the tty driver is capable of polled
356 /* Search through the tty devices to look for a match */ tty_find_polling_driver()
382 * @tty: tty to check
391 int tty_check_change(struct tty_struct *tty) tty_check_change() argument
396 if (current->signal->tty != tty) tty_check_change()
399 spin_lock_irqsave(&tty->ctrl_lock, flags); tty_check_change()
401 if (!tty->pgrp) { tty_check_change()
402 printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n"); tty_check_change()
405 if (task_pgrp(current) == tty->pgrp) tty_check_change()
407 spin_unlock_irqrestore(&tty->ctrl_lock, flags); tty_check_change()
420 spin_unlock_irqrestore(&tty->ctrl_lock, flags); tty_check_change()
497 struct tty_struct *tty; proc_clear_tty() local
499 tty = p->signal->tty; proc_clear_tty()
500 p->signal->tty = NULL; proc_clear_tty()
502 tty_kref_put(tty); proc_clear_tty()
515 static void __proc_set_tty(struct tty_struct *tty) __proc_set_tty() argument
519 spin_lock_irqsave(&tty->ctrl_lock, flags); __proc_set_tty()
522 * tiocsctty() is stealing the controlling tty __proc_set_tty()
524 put_pid(tty->session); __proc_set_tty()
525 put_pid(tty->pgrp); __proc_set_tty()
526 tty->pgrp = get_pid(task_pgrp(current)); __proc_set_tty()
527 spin_unlock_irqrestore(&tty->ctrl_lock, flags); __proc_set_tty()
528 tty->session = get_pid(task_session(current)); __proc_set_tty()
529 if (current->signal->tty) { __proc_set_tty()
530 printk(KERN_DEBUG "tty not NULL!!\n"); __proc_set_tty()
531 tty_kref_put(current->signal->tty); __proc_set_tty()
534 current->signal->tty = tty_kref_get(tty); __proc_set_tty()
538 static void proc_set_tty(struct tty_struct *tty) proc_set_tty() argument
541 __proc_set_tty(tty); proc_set_tty()
547 struct tty_struct *tty; get_current_tty() local
551 tty = tty_kref_get(current->signal->tty); get_current_tty()
553 return tty; get_current_tty()
567 * @tty: terminal
569 * Internal and external helper for wakeups of tty. This function
574 void tty_wakeup(struct tty_struct *tty) tty_wakeup() argument
578 if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) { tty_wakeup()
579 ld = tty_ldisc_ref(tty); tty_wakeup()
582 ld->ops->write_wakeup(tty); tty_wakeup()
586 wake_up_interruptible_poll(&tty->write_wait, POLLOUT); tty_wakeup()
593 * @tty controlling tty
599 * Returns the number of processes in the session with this tty
601 * tty references for those processes.
603 static int tty_signal_session_leader(struct tty_struct *tty, int exit_session) tty_signal_session_leader() argument
610 if (tty->session) { tty_signal_session_leader()
611 do_each_pid_task(tty->session, PIDTYPE_SID, p) { tty_signal_session_leader()
613 if (p->signal->tty == tty) { tty_signal_session_leader()
614 p->signal->tty = NULL; tty_signal_session_leader()
626 spin_lock(&tty->ctrl_lock); tty_signal_session_leader()
627 tty_pgrp = get_pid(tty->pgrp); tty_signal_session_leader()
628 if (tty->pgrp) tty_signal_session_leader()
629 p->signal->tty_old_pgrp = get_pid(tty->pgrp); tty_signal_session_leader()
630 spin_unlock(&tty->ctrl_lock); tty_signal_session_leader()
632 } while_each_pid_task(tty->session, PIDTYPE_SID, p); tty_signal_session_leader()
647 * @work: tty device
655 * line discipline hangup and signal delivery. The tty object itself
667 static void __tty_hangup(struct tty_struct *tty, int exit_session) __tty_hangup() argument
675 if (!tty) __tty_hangup()
680 if (redirect && file_tty(redirect) == tty) { __tty_hangup()
686 tty_lock(tty); __tty_hangup()
688 if (test_bit(TTY_HUPPED, &tty->flags)) { __tty_hangup()
689 tty_unlock(tty); __tty_hangup()
693 /* inuse_filps is protected by the single tty lock, __tty_hangup()
696 check_tty_count(tty, "tty_hangup"); __tty_hangup()
700 list_for_each_entry(priv, &tty->tty_files, list) { __tty_hangup()
712 refs = tty_signal_session_leader(tty, exit_session); __tty_hangup()
715 tty_kref_put(tty); __tty_hangup()
717 tty_ldisc_hangup(tty); __tty_hangup()
719 spin_lock_irq(&tty->ctrl_lock); __tty_hangup()
720 clear_bit(TTY_THROTTLED, &tty->flags); __tty_hangup()
721 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); __tty_hangup()
722 put_pid(tty->session); __tty_hangup()
723 put_pid(tty->pgrp); __tty_hangup()
724 tty->session = NULL; __tty_hangup()
725 tty->pgrp = NULL; __tty_hangup()
726 tty->ctrl_status = 0; __tty_hangup()
727 spin_unlock_irq(&tty->ctrl_lock); __tty_hangup()
732 * tty->count and state->count to go out of sync. __tty_hangup()
736 if (tty->ops->close) __tty_hangup()
738 tty->ops->close(tty, cons_filp); __tty_hangup()
739 } else if (tty->ops->hangup) __tty_hangup()
740 tty->ops->hangup(tty); __tty_hangup()
747 set_bit(TTY_HUPPED, &tty->flags); __tty_hangup()
748 tty_unlock(tty); __tty_hangup()
756 struct tty_struct *tty = do_tty_hangup() local
759 __tty_hangup(tty, 0); do_tty_hangup()
764 * @tty: tty to hangup
770 void tty_hangup(struct tty_struct *tty) tty_hangup() argument
774 printk(KERN_DEBUG "%s hangup...\n", tty_name(tty, buf)); tty_hangup()
776 schedule_work(&tty->hangup_work); tty_hangup()
783 * @tty: tty to hangup
790 void tty_vhangup(struct tty_struct *tty) tty_vhangup() argument
795 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf)); tty_vhangup()
797 __tty_hangup(tty, 0); tty_vhangup()
806 * Perform a vhangup on the current controlling tty
811 struct tty_struct *tty; tty_vhangup_self() local
813 tty = get_current_tty(); tty_vhangup_self()
814 if (tty) { tty_vhangup_self()
815 tty_vhangup(tty); tty_vhangup_self()
816 tty_kref_put(tty); tty_vhangup_self()
822 * @tty: tty to hangup
831 static void tty_vhangup_session(struct tty_struct *tty) tty_vhangup_session() argument
836 printk(KERN_DEBUG "%s vhangup session...\n", tty_name(tty, buf)); tty_vhangup_session()
838 __tty_hangup(tty, 1); tty_vhangup_session()
842 * tty_hung_up_p - was tty hung up
843 * @filp: file pointer of tty
845 * Return true if the tty has been subject to a vhangup or a carrier
857 * disassociate_ctty - disconnect controlling tty
861 * it wants to disassociate itself from its controlling tty.
865 * (2) Clears the tty from being controlling the session
866 * (3) Clears the controlling tty for all processes in the
875 * tty_mutex is taken to protect tty
883 struct tty_struct *tty; disassociate_ctty() local
888 tty = get_current_tty(); disassociate_ctty()
889 if (tty) { disassociate_ctty()
890 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) { disassociate_ctty()
891 tty_vhangup_session(tty); disassociate_ctty()
893 struct pid *tty_pgrp = tty_get_pgrp(tty); disassociate_ctty()
901 tty_kref_put(tty); disassociate_ctty()
921 tty = tty_kref_get(current->signal->tty); disassociate_ctty()
922 if (tty) { disassociate_ctty()
924 spin_lock_irqsave(&tty->ctrl_lock, flags); disassociate_ctty()
925 put_pid(tty->session); disassociate_ctty()
926 put_pid(tty->pgrp); disassociate_ctty()
927 tty->session = NULL; disassociate_ctty()
928 tty->pgrp = NULL; disassociate_ctty()
929 spin_unlock_irqrestore(&tty->ctrl_lock, flags); disassociate_ctty()
930 tty_kref_put(tty); disassociate_ctty()
933 printk(KERN_DEBUG "error attempted to write to tty [0x%p]" disassociate_ctty()
934 " = NULL", tty); disassociate_ctty()
939 /* Now clear signal->tty under the lock */ disassociate_ctty()
947 * no_tty - Ensure the current process does not have a controlling tty
962 * @tty: tty to stop
970 * called from any context, may be under the tty atomic_write_lock
977 void __stop_tty(struct tty_struct *tty) __stop_tty() argument
979 if (tty->stopped) __stop_tty()
981 tty->stopped = 1; __stop_tty()
982 if (tty->ops->stop) __stop_tty()
983 tty->ops->stop(tty); __stop_tty()
986 void stop_tty(struct tty_struct *tty) stop_tty() argument
990 spin_lock_irqsave(&tty->flow_lock, flags); stop_tty()
991 __stop_tty(tty); stop_tty()
992 spin_unlock_irqrestore(&tty->flow_lock, flags); stop_tty()
998 * @tty: tty to start
1000 * Start a tty that has been stopped if at all possible. If this
1001 * tty was previous stopped and is now being started, the driver
1008 void __start_tty(struct tty_struct *tty) __start_tty() argument
1010 if (!tty->stopped || tty->flow_stopped) __start_tty()
1012 tty->stopped = 0; __start_tty()
1013 if (tty->ops->start) __start_tty()
1014 tty->ops->start(tty); __start_tty()
1015 tty_wakeup(tty); __start_tty()
1018 void start_tty(struct tty_struct *tty) start_tty() argument
1022 spin_lock_irqsave(&tty->flow_lock, flags); start_tty()
1023 __start_tty(tty); start_tty()
1024 spin_unlock_irqrestore(&tty->flow_lock, flags); start_tty()
1035 * the time of the tty device, otherwise it could be construded as a tty_update_time()
1036 * security leak to let userspace know the exact timing of the tty. tty_update_time()
1043 * tty_read - read method for tty device files
1044 * @file: pointer to tty file
1062 struct tty_struct *tty = file_tty(file); tty_read() local
1065 if (tty_paranoia_check(tty, inode, "tty_read")) tty_read()
1067 if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags))) tty_read()
1072 ld = tty_ldisc_ref_wait(tty); tty_read()
1074 i = ld->ops->read(tty, file, buf, count); tty_read()
1085 static void tty_write_unlock(struct tty_struct *tty) tty_write_unlock() argument
1087 mutex_unlock(&tty->atomic_write_lock); tty_write_unlock()
1088 wake_up_interruptible_poll(&tty->write_wait, POLLOUT); tty_write_unlock()
1091 static int tty_write_lock(struct tty_struct *tty, int ndelay) tty_write_lock() argument
1093 if (!mutex_trylock(&tty->atomic_write_lock)) { tty_write_lock()
1096 if (mutex_lock_interruptible(&tty->atomic_write_lock)) tty_write_lock()
1108 struct tty_struct *tty, do_tty_write()
1116 ret = tty_write_lock(tty, file->f_flags & O_NDELAY); do_tty_write()
1137 if (test_bit(TTY_NO_WRITE_SPLIT, &tty->flags)) do_tty_write()
1143 if (tty->write_cnt < chunk) { do_tty_write()
1154 kfree(tty->write_buf); do_tty_write()
1155 tty->write_cnt = chunk; do_tty_write()
1156 tty->write_buf = buf_chunk; do_tty_write()
1165 if (copy_from_user(tty->write_buf, buf, size)) do_tty_write()
1167 ret = write(tty, file, tty->write_buf, size); do_tty_write()
1185 tty_write_unlock(tty); do_tty_write()
1190 * tty_write_message - write a message to a certain tty, not just the console.
1191 * @tty: the destination tty_struct
1194 * This is used for messages that need to be redirected to a specific tty.
1201 void tty_write_message(struct tty_struct *tty, char *msg) tty_write_message() argument
1203 if (tty) { tty_write_message()
1204 mutex_lock(&tty->atomic_write_lock); tty_write_message()
1205 tty_lock(tty); tty_write_message()
1206 if (tty->ops->write && tty->count > 0) { tty_write_message()
1207 tty_unlock(tty); tty_write_message()
1208 tty->ops->write(tty, msg, strlen(msg)); tty_write_message()
1210 tty_unlock(tty); tty_write_message()
1211 tty_write_unlock(tty); tty_write_message()
1218 * tty_write - write method for tty device file
1219 * @file: tty file pointer
1224 * Write data to a tty device via the line discipline.
1228 * Writes to the tty driver are serialized by the atomic_write_lock
1236 struct tty_struct *tty = file_tty(file); tty_write() local
1240 if (tty_paranoia_check(tty, file_inode(file), "tty_write")) tty_write()
1242 if (!tty || !tty->ops->write || tty_write()
1243 (test_bit(TTY_IO_ERROR, &tty->flags))) tty_write()
1246 if (tty->ops->write_room == NULL) tty_write()
1247 printk(KERN_ERR "tty driver %s lacks a write_room method.\n", tty_write()
1248 tty->driver->name); tty_write()
1249 ld = tty_ldisc_ref_wait(tty); tty_write()
1253 ret = do_tty_write(ld->ops->write, tty, file, buf, count); tty_write()
1280 * Send a high priority character to the tty even if stopped
1285 int tty_send_xchar(struct tty_struct *tty, char ch) tty_send_xchar() argument
1287 int was_stopped = tty->stopped; tty_send_xchar()
1289 if (tty->ops->send_xchar) { tty_send_xchar()
1290 down_read(&tty->termios_rwsem); tty_send_xchar()
1291 tty->ops->send_xchar(tty, ch); tty_send_xchar()
1292 up_read(&tty->termios_rwsem); tty_send_xchar()
1296 if (tty_write_lock(tty, 0) < 0) tty_send_xchar()
1299 down_read(&tty->termios_rwsem); tty_send_xchar()
1301 start_tty(tty); tty_send_xchar()
1302 tty->ops->write(tty, &ch, 1); tty_send_xchar()
1304 stop_tty(tty); tty_send_xchar()
1305 up_read(&tty->termios_rwsem); tty_send_xchar()
1306 tty_write_unlock(tty); tty_send_xchar()
1314 * @driver: the tty driver in use
1326 /* ->name is initialized to "ttyp", but "tty" is expected */ pty_line_name()
1328 driver->subtype == PTY_TYPE_SLAVE ? "tty" : driver->name, pty_line_name()
1333 * tty_line_name - generate name for a tty
1334 * @driver: the tty driver in use
1353 * tty_driver_lookup_tty() - find an existing tty, if any
1354 * @driver: the driver for the tty
1357 * Return the tty, if found. If not found, return NULL or ERR_PTR() if the
1360 * Locking: tty_mutex must be held. If the tty is found, bump the tty kref.
1365 struct tty_struct *tty; tty_driver_lookup_tty() local
1368 tty = driver->ops->lookup(driver, inode, idx); tty_driver_lookup_tty()
1370 tty = driver->ttys[idx]; tty_driver_lookup_tty()
1372 if (!IS_ERR(tty)) tty_driver_lookup_tty()
1373 tty_kref_get(tty); tty_driver_lookup_tty()
1374 return tty; tty_driver_lookup_tty()
1379 * @tty: the tty to set up
1381 * Initialise the termios structures for this tty. Thus runs under
1385 int tty_init_termios(struct tty_struct *tty) tty_init_termios() argument
1388 int idx = tty->index; tty_init_termios()
1390 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) tty_init_termios()
1391 tty->termios = tty->driver->init_termios; tty_init_termios()
1394 tp = tty->driver->termios[idx]; tty_init_termios()
1396 tty->termios = *tp; tty_init_termios()
1398 tty->termios = tty->driver->init_termios; tty_init_termios()
1401 tty->termios.c_ispeed = tty_termios_input_baud_rate(&tty->termios); tty_init_termios()
1402 tty->termios.c_ospeed = tty_termios_baud_rate(&tty->termios); tty_init_termios()
1407 int tty_standard_install(struct tty_driver *driver, struct tty_struct *tty) tty_standard_install() argument
1409 int ret = tty_init_termios(tty); tty_standard_install()
1414 tty->count++; tty_standard_install()
1415 driver->ttys[tty->index] = tty; tty_standard_install()
1421 * tty_driver_install_tty() - install a tty entry in the driver
1422 * @driver: the driver for the tty
1423 * @tty: the tty
1425 * Install a tty object into the driver tables. The tty->index field
1433 struct tty_struct *tty) tty_driver_install_tty()
1435 return driver->ops->install ? driver->ops->install(driver, tty) : tty_driver_install_tty()
1436 tty_standard_install(driver, tty); tty_driver_install_tty()
1440 * tty_driver_remove_tty() - remove a tty from the driver tables
1441 * @driver: the driver for the tty
1444 * Remvoe a tty object from the driver tables. The tty->index field
1449 void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *tty) tty_driver_remove_tty() argument
1452 driver->ops->remove(driver, tty); tty_driver_remove_tty()
1454 driver->ttys[tty->index] = NULL; tty_driver_remove_tty()
1458 * tty_reopen() - fast re-open of an open tty
1459 * @tty - the tty to open
1466 static int tty_reopen(struct tty_struct *tty) tty_reopen() argument
1468 struct tty_driver *driver = tty->driver; tty_reopen()
1470 if (!tty->count) tty_reopen()
1477 if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) tty_reopen()
1480 tty->count++; tty_reopen()
1482 WARN_ON(!tty->ldisc); tty_reopen()
1488 * tty_init_dev - initialise a tty device
1489 * @driver: tty driver we are opening a device on
1491 * @ret_tty: returned tty structure
1493 * Prepare a tty device. This may not be a "new" clean device but
1499 * protects us from the tty struct or driver itself going away.
1501 * On exit the tty device has the line discipline attached and
1502 * a reference count of 1. If a pair was created for pty/tty use
1508 * relaxed for the (most common) case of reopening a tty.
1513 struct tty_struct *tty; tty_init_dev() local
1527 tty = alloc_tty_struct(driver, idx); tty_init_dev()
1528 if (!tty) { tty_init_dev()
1533 tty_lock(tty); tty_init_dev()
1534 retval = tty_driver_install_tty(driver, tty); tty_init_dev()
1538 if (!tty->port) tty_init_dev()
1539 tty->port = driver->ports[idx]; tty_init_dev()
1541 WARN_RATELIMIT(!tty->port, tty_init_dev()
1542 "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n", tty_init_dev()
1543 __func__, tty->driver->name); tty_init_dev()
1545 tty->port->itty = tty; tty_init_dev()
1552 retval = tty_ldisc_setup(tty, tty->link); tty_init_dev()
1555 /* Return the tty locked so that it cannot vanish under the caller */ tty_init_dev()
1556 return tty; tty_init_dev()
1559 tty_unlock(tty); tty_init_dev()
1560 deinitialize_tty_struct(tty); tty_init_dev()
1561 free_tty_struct(tty); tty_init_dev()
1566 /* call the tty release_tty routine to clean out this slot */ tty_init_dev()
1568 tty_unlock(tty); tty_init_dev()
1571 release_tty(tty, idx); tty_init_dev()
1575 void tty_free_termios(struct tty_struct *tty) tty_free_termios() argument
1578 int idx = tty->index; tty_free_termios()
1581 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) tty_free_termios()
1585 tp = tty->driver->termios[idx]; tty_free_termios()
1589 pr_warn("tty: no memory to save termios state.\n"); tty_free_termios()
1592 tty->driver->termios[idx] = tp; tty_free_termios()
1594 *tp = tty->termios; tty_free_termios()
1599 * tty_flush_works - flush all works of a tty/pty pair
1600 * @tty: tty device to flush works for (or either end of a pty pair)
1602 * Sync flush all works belonging to @tty (and the 'other' tty).
1604 static void tty_flush_works(struct tty_struct *tty) tty_flush_works() argument
1606 flush_work(&tty->SAK_work); tty_flush_works()
1607 flush_work(&tty->hangup_work); tty_flush_works()
1608 if (tty->link) { tty_flush_works()
1609 flush_work(&tty->link->SAK_work); tty_flush_works()
1610 flush_work(&tty->link->hangup_work); tty_flush_works()
1615 * release_one_tty - release tty structure memory
1616 * @kref: kref of tty we are obliterating
1618 * Releases memory associated with a tty structure, and clears out the
1631 struct tty_struct *tty = release_one_tty() local
1633 struct tty_driver *driver = tty->driver; release_one_tty()
1636 if (tty->ops->cleanup) release_one_tty()
1637 tty->ops->cleanup(tty); release_one_tty()
1639 tty->magic = 0; release_one_tty()
1644 list_del_init(&tty->tty_files); release_one_tty()
1647 put_pid(tty->pgrp); release_one_tty()
1648 put_pid(tty->session); release_one_tty()
1649 free_tty_struct(tty); release_one_tty()
1654 struct tty_struct *tty = container_of(kref, struct tty_struct, kref); queue_release_one_tty() local
1658 INIT_WORK(&tty->hangup_work, release_one_tty); queue_release_one_tty()
1659 schedule_work(&tty->hangup_work); queue_release_one_tty()
1663 * tty_kref_put - release a tty kref
1664 * @tty: tty device
1666 * Release a reference to a tty device and if need be let the kref
1670 void tty_kref_put(struct tty_struct *tty) tty_kref_put() argument
1672 if (tty) tty_kref_put()
1673 kref_put(&tty->kref, queue_release_one_tty); tty_kref_put()
1678 * release_tty - release tty structure memory
1680 * Release both @tty and a possible linked partner (think pty pair),
1689 static void release_tty(struct tty_struct *tty, int idx) release_tty() argument
1692 WARN_ON(tty->index != idx); release_tty()
1694 if (tty->ops->shutdown) release_tty()
1695 tty->ops->shutdown(tty); release_tty()
1696 tty_free_termios(tty); release_tty()
1697 tty_driver_remove_tty(tty->driver, tty); release_tty()
1698 tty->port->itty = NULL; release_tty()
1699 if (tty->link) release_tty()
1700 tty->link->port->itty = NULL; release_tty()
1701 cancel_work_sync(&tty->port->buf.work); release_tty()
1703 tty_kref_put(tty->link); release_tty()
1704 tty_kref_put(tty); release_tty()
1708 * tty_release_checks - check a tty before real release
1709 * @tty: tty to check
1710 * @o_tty: link of @tty (if any)
1711 * @idx: index of the tty
1713 * Performs some paranoid checking before true release of the @tty.
1716 static int tty_release_checks(struct tty_struct *tty, int idx) tty_release_checks() argument
1719 if (idx < 0 || idx >= tty->driver->num) { tty_release_checks()
1721 __func__, tty->name); tty_release_checks()
1726 if (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) tty_release_checks()
1729 if (tty != tty->driver->ttys[idx]) { tty_release_checks()
1730 printk(KERN_DEBUG "%s: driver.table[%d] not tty for (%s)\n", tty_release_checks()
1731 __func__, idx, tty->name); tty_release_checks()
1734 if (tty->driver->other) { tty_release_checks()
1735 struct tty_struct *o_tty = tty->link; tty_release_checks()
1737 if (o_tty != tty->driver->other->ttys[idx]) { tty_release_checks()
1739 __func__, idx, tty->name); tty_release_checks()
1742 if (o_tty->link != tty) { tty_release_checks()
1753 * @inode: inode of tty
1754 * @filp: file pointer for handle to tty
1757 * this tty. There may however be several such references.
1762 * Even releasing the tty structures is a tricky business.. We have
1772 struct tty_struct *tty = file_tty(filp); tty_release() local
1780 if (tty_paranoia_check(tty, inode, __func__)) tty_release()
1783 tty_lock(tty); tty_release()
1784 check_tty_count(tty, __func__); tty_release()
1788 idx = tty->index; tty_release()
1789 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && tty_release()
1790 tty->driver->subtype == PTY_TYPE_MASTER) tty_release()
1791 o_tty = tty->link; tty_release()
1793 if (tty_release_checks(tty, idx)) { tty_release()
1794 tty_unlock(tty); tty_release()
1799 printk(KERN_DEBUG "%s: %s (tty count=%d)...\n", __func__, tty_release()
1800 tty_name(tty, buf), tty->count); tty_release()
1803 if (tty->ops->close) tty_release()
1804 tty->ops->close(tty, filp); tty_release()
1806 /* If tty is pty master, lock the slave pty (stable lock order) */ tty_release()
1810 * Sanity check: if tty->count is going to zero, there shouldn't be tty_release()
1811 * any waiters on tty->read_wait or tty->write_wait. We test the tty_release()
1813 * close. This ensures that we won't block while releasing the tty tty_release()
1825 if (tty->count <= 1) { tty_release()
1826 if (waitqueue_active(&tty->read_wait)) { tty_release()
1827 wake_up_poll(&tty->read_wait, POLLIN); tty_release()
1830 if (waitqueue_active(&tty->write_wait)) { tty_release()
1831 wake_up_poll(&tty->write_wait, POLLOUT); tty_release()
1851 __func__, tty_name(tty, buf)); tty_release()
1867 if (--tty->count < 0) { tty_release()
1868 printk(KERN_WARNING "%s: bad tty->count (%d) for %s\n", tty_release()
1869 __func__, tty->count, tty_name(tty, buf)); tty_release()
1870 tty->count = 0; tty_release()
1874 * We've decremented tty->count, so we need to remove this file tty_release()
1875 * descriptor off the tty->tty_files list; this serves two tty_release()
1878 * associated with this tty. tty_release()
1888 * processes that still think tty or o_tty is their controlling tty_release()
1889 * tty. tty_release()
1891 if (!tty->count) { tty_release()
1893 session_clear_tty(tty->session); tty_release()
1900 final = !tty->count && !(o_tty && o_tty->count); tty_release()
1903 tty_unlock(tty); tty_release()
1905 /* At this point, the tty->count == 0 should ensure a dead tty tty_release()
1912 printk(KERN_DEBUG "%s: %s: final close\n", __func__, tty_name(tty, buf)); tty_release()
1917 tty_ldisc_release(tty); tty_release()
1919 /* Wait for pending work before tty destruction commmences */ tty_release()
1920 tty_flush_works(tty); tty_release()
1923 printk(KERN_DEBUG "%s: %s: freeing structure...\n", __func__, tty_name(tty, buf)); tty_release()
1928 * should be safe as we keep a kref while the tty is locked (so the tty_release()
1929 * unlock never unlocks a freed tty). tty_release()
1932 release_tty(tty, idx); tty_release()
1939 * tty_open_current_tty - get locked tty of current task
1941 * @filp: file pointer to tty
1942 * @return: locked tty of the current task iff @device is /dev/tty
1944 * Performs a re-open of the current task's controlling tty.
1951 struct tty_struct *tty; tty_open_current_tty() local
1957 tty = get_current_tty(); tty_open_current_tty()
1958 if (!tty) tty_open_current_tty()
1961 filp->f_flags |= O_NONBLOCK; /* Don't let /dev/tty block */ tty_open_current_tty()
1963 tty_lock(tty); tty_open_current_tty()
1964 tty_kref_put(tty); /* safe to drop the kref now */ tty_open_current_tty()
1966 retval = tty_reopen(tty); tty_open_current_tty()
1968 tty_unlock(tty); tty_open_current_tty()
1969 tty = ERR_PTR(retval); tty_open_current_tty()
1971 return tty; tty_open_current_tty()
1975 * tty_lookup_driver - lookup a tty driver for a given device file
1977 * @filp: file pointer to tty
1978 * @noctty: set if the device should not become a controlling tty
2025 * tty_open - open a tty device
2027 * @filp: file pointer to tty
2029 * tty_open and tty_release keep up the tty count that contains the
2030 * number of opens done on a tty. We cannot use the inode-count, as
2031 * different inodes might point to the same tty.
2035 * (This is not done solely through tty->count, now. - Ted 1/27/92)
2040 * Locking: tty_mutex protects tty, tty_lookup_driver and tty_init_dev.
2041 * tty->count should protect the rest.
2050 struct tty_struct *tty; tty_open() local
2068 tty = tty_open_current_tty(device, filp); tty_open()
2069 if (!tty) { tty_open()
2077 /* check whether we're reopening an existing tty */ tty_open()
2078 tty = tty_driver_lookup_tty(driver, inode, index); tty_open()
2079 if (IS_ERR(tty)) { tty_open()
2080 retval = PTR_ERR(tty); tty_open()
2084 if (tty) { tty_open()
2086 tty_lock(tty); tty_open()
2088 tty_kref_put(tty); tty_open()
2089 retval = tty_reopen(tty); tty_open()
2091 tty_unlock(tty); tty_open()
2092 tty = ERR_PTR(retval); tty_open()
2095 tty = tty_init_dev(driver, index); tty_open()
2102 if (IS_ERR(tty)) { tty_open()
2103 retval = PTR_ERR(tty); tty_open()
2107 tty_add_file(tty, filp); tty_open()
2109 check_tty_count(tty, __func__); tty_open()
2110 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && tty_open()
2111 tty->driver->subtype == PTY_TYPE_MASTER) tty_open()
2114 printk(KERN_DEBUG "%s: opening %s...\n", __func__, tty->name); tty_open()
2116 if (tty->ops->open) tty_open()
2117 retval = tty->ops->open(tty, filp); tty_open()
2125 retval, tty->name); tty_open()
2127 tty_unlock(tty); /* need to call tty_release without BTM */ tty_open()
2143 clear_bit(TTY_HUPPED, &tty->flags); tty_open()
2150 !current->signal->tty && tty_open()
2151 tty->session == NULL) { tty_open()
2153 * Don't let a process that only has write access to the tty tty_open()
2154 * obtain the privileges associated with having a tty as tty_open()
2156 * access through /dev/tty, being able to perform pushback). tty_open()
2157 * Many distributions set the group of all ttys to "tty" and tty_open()
2158 * grant write-only access to all terminals for setgid tty tty_open()
2167 __proc_set_tty(tty); tty_open()
2171 tty_unlock(tty); tty_open()
2186 * tty_poll - check tty status
2199 struct tty_struct *tty = file_tty(filp); tty_poll() local
2203 if (tty_paranoia_check(tty, file_inode(filp), "tty_poll")) tty_poll()
2206 ld = tty_ldisc_ref_wait(tty); tty_poll()
2208 ret = ld->ops->poll(tty, filp, wait); tty_poll()
2215 struct tty_struct *tty = file_tty(filp); __tty_fasync() local
2220 if (tty_paranoia_check(tty, file_inode(filp), "tty_fasync")) __tty_fasync()
2223 retval = fasync_helper(fd, filp, on, &tty->fasync); __tty_fasync()
2227 ldisc = tty_ldisc_ref(tty); __tty_fasync()
2230 ldisc->ops->fasync(tty, on); __tty_fasync()
2238 spin_lock_irqsave(&tty->ctrl_lock, flags); __tty_fasync()
2239 if (tty->pgrp) { __tty_fasync()
2240 pid = tty->pgrp; __tty_fasync()
2247 spin_unlock_irqrestore(&tty->ctrl_lock, flags); __tty_fasync()
2258 struct tty_struct *tty = file_tty(filp); tty_fasync() local
2261 tty_lock(tty); tty_fasync()
2263 tty_unlock(tty); tty_fasync()
2270 * @tty: tty to fake input into
2273 * Fake input to a tty device. Does the necessary locking and
2280 * current->signal->tty check is safe without locks
2285 static int tiocsti(struct tty_struct *tty, char __user *p) tiocsti() argument
2290 if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN)) tiocsti()
2294 tty_audit_tiocsti(tty, ch); tiocsti()
2295 ld = tty_ldisc_ref_wait(tty); tiocsti()
2296 ld->ops->receive_buf(tty, &ch, &mbz, 1); tiocsti()
2303 * @tty; tty
2308 * Locking: tty->winsize_mutex is taken to ensure the winsize data
2312 static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) tiocgwinsz() argument
2316 mutex_lock(&tty->winsize_mutex); tiocgwinsz()
2317 err = copy_to_user(arg, &tty->winsize, sizeof(*arg)); tiocgwinsz()
2318 mutex_unlock(&tty->winsize_mutex); tiocgwinsz()
2325 * @tty: tty being resized
2333 int tty_do_resize(struct tty_struct *tty, struct winsize *ws) tty_do_resize() argument
2337 /* Lock the tty */ tty_do_resize()
2338 mutex_lock(&tty->winsize_mutex); tty_do_resize()
2339 if (!memcmp(ws, &tty->winsize, sizeof(*ws))) tty_do_resize()
2343 pgrp = tty_get_pgrp(tty); tty_do_resize()
2348 tty->winsize = *ws; tty_do_resize()
2350 mutex_unlock(&tty->winsize_mutex); tty_do_resize()
2357 * @tty; tty side of tty
2366 * tty termios mutex and ctrl_lock. The console takes its own lock
2370 static int tiocswinsz(struct tty_struct *tty, struct winsize __user *arg) tiocswinsz() argument
2376 if (tty->ops->resize) tiocswinsz()
2377 return tty->ops->resize(tty, &tmp_ws); tiocswinsz()
2379 return tty_do_resize(tty, &tmp_ws); tiocswinsz()
2420 * Historical tty interfaces had a blocking control ioctl before
2422 * in the expected tty API of posix OS's.
2444 * tiocsctty - set controlling tty
2445 * @tty: tty structure
2449 * leader to set this tty as the controlling tty for the session.
2452 * Takes tty_lock() to serialize proc_set_tty() for this tty
2454 * Takes ->siglock() when updating signal->tty
2457 static int tiocsctty(struct tty_struct *tty, struct file *file, int arg) tiocsctty() argument
2461 tty_lock(tty); tiocsctty()
2464 if (current->signal->leader && (task_session(current) == tty->session)) tiocsctty()
2469 * not have a controlling tty already. tiocsctty()
2471 if (!current->signal->leader || current->signal->tty) { tiocsctty()
2476 if (tty->session) { tiocsctty()
2478 * This tty is already the controlling tiocsctty()
2479 * tty for another session group! tiocsctty()
2485 session_clear_tty(tty->session); tiocsctty()
2498 proc_set_tty(tty); tiocsctty()
2501 tty_unlock(tty); tiocsctty()
2507 * @tty: tty to read
2510 * group controlling the tty.
2513 struct pid *tty_get_pgrp(struct tty_struct *tty) tty_get_pgrp() argument
2518 spin_lock_irqsave(&tty->ctrl_lock, flags); tty_get_pgrp()
2519 pgrp = get_pid(tty->pgrp); tty_get_pgrp()
2520 spin_unlock_irqrestore(&tty->ctrl_lock, flags); tty_get_pgrp()
2549 * @tty: tty passed by user
2550 * @real_tty: tty side of the tty passed by the user if a pty else the tty
2553 * Obtain the process group of the tty. If there is no process group
2556 * Locking: none. Reference to current->signal->tty is safe.
2559 static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) tiocgpgrp() argument
2564 * (tty == real_tty) is a cheap way of tiocgpgrp()
2565 * testing if the tty is NOT a master pty. tiocgpgrp()
2567 if (tty == real_tty && current->signal->tty != real_tty) tiocgpgrp()
2577 * @tty: tty passed by user
2578 * @real_tty: tty side device matching tty passed by user
2581 * Set the process group of the tty to the session passed. Only
2582 * permitted where the tty session is our session.
2587 static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) tiocspgrp() argument
2598 if (!current->signal->tty || tiocspgrp()
2599 (current->signal->tty != real_tty) || tiocspgrp()
2615 spin_lock_irqsave(&tty->ctrl_lock, flags); tiocspgrp()
2618 spin_unlock_irqrestore(&tty->ctrl_lock, flags); tiocspgrp()
2626 * @tty: tty passed by user
2627 * @real_tty: tty side of the tty passed by the user if a pty else the tty
2630 * Obtain the session id of the tty. If there is no session
2633 * Locking: none. Reference to current->signal->tty is safe.
2636 static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) tiocgsid() argument
2639 * (tty == real_tty) is a cheap way of tiocgsid()
2640 * testing if the tty is NOT a master pty. tiocgsid()
2642 if (tty == real_tty && current->signal->tty != real_tty) tiocgsid()
2651 * @tty: tty device
2659 static int tiocsetd(struct tty_struct *tty, int __user *p) tiocsetd() argument
2667 ret = tty_set_ldisc(tty, ldisc); tiocsetd()
2674 * @tty: tty device
2680 * is changing or the tty is being hungup)
2683 static int tiocgetd(struct tty_struct *tty, int __user *p) tiocgetd() argument
2688 ld = tty_ldisc_ref_wait(tty); tiocgetd()
2696 * @tty: device to break on
2707 static int send_break(struct tty_struct *tty, unsigned int duration) send_break() argument
2711 if (tty->ops->break_ctl == NULL) send_break()
2714 if (tty->driver->flags & TTY_DRIVER_HARDWARE_BREAK) send_break()
2715 retval = tty->ops->break_ctl(tty, duration); send_break()
2718 if (tty_write_lock(tty, 0) < 0) send_break()
2720 retval = tty->ops->break_ctl(tty, -1); send_break()
2725 retval = tty->ops->break_ctl(tty, 0); send_break()
2727 tty_write_unlock(tty); send_break()
2736 * @tty: tty device
2740 * Obtain the modem status bits from the tty driver if the feature
2746 static int tty_tiocmget(struct tty_struct *tty, int __user *p) tty_tiocmget() argument
2750 if (tty->ops->tiocmget) { tty_tiocmget()
2751 retval = tty->ops->tiocmget(tty); tty_tiocmget()
2761 * @tty: tty device
2765 * Set the modem status bits from the tty driver if the feature
2771 static int tty_tiocmset(struct tty_struct *tty, unsigned int cmd, tty_tiocmset() argument
2777 if (tty->ops->tiocmset == NULL) tty_tiocmset()
2798 return tty->ops->tiocmset(tty, set, clear); tty_tiocmset()
2801 static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) tty_tiocgicount() argument
2806 if (tty->ops->get_icount) tty_tiocgicount()
2807 retval = tty->ops->get_icount(tty, &icount); tty_tiocgicount()
2837 static struct tty_struct *tty_pair_get_tty(struct tty_struct *tty) tty_pair_get_tty() argument
2839 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && tty_pair_get_tty()
2840 tty->driver->subtype == PTY_TYPE_MASTER) tty_pair_get_tty()
2841 tty = tty->link; tty_pair_get_tty()
2842 return tty; tty_pair_get_tty()
2850 struct tty_struct *tty = file_tty(file); tty_ioctl() local
2856 if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) tty_ioctl()
2859 real_tty = tty_pair_get_tty(tty); tty_ioctl()
2870 retval = tty_check_change(tty); tty_ioctl()
2874 tty_wait_until_sent(tty, 0); tty_ioctl()
2886 return tiocsti(tty, p); tty_ioctl()
2892 return real_tty != tty ? -EINVAL : tioccons(file); tty_ioctl()
2896 set_bit(TTY_EXCLUSIVE, &tty->flags); tty_ioctl()
2899 clear_bit(TTY_EXCLUSIVE, &tty->flags); tty_ioctl()
2903 int excl = test_bit(TTY_EXCLUSIVE, &tty->flags); tty_ioctl()
2907 if (current->signal->tty != tty) tty_ioctl()
2912 return tiocsctty(tty, file, arg); tty_ioctl()
2914 return tiocgpgrp(tty, real_tty, p); tty_ioctl()
2916 return tiocspgrp(tty, real_tty, p); tty_ioctl()
2918 return tiocgsid(tty, real_tty, p); tty_ioctl()
2920 return tiocgetd(tty, p); tty_ioctl()
2922 return tiocsetd(tty, p); tty_ioctl()
2926 tty_vhangup(tty); tty_ioctl()
2937 if (tty->ops->break_ctl) tty_ioctl()
2938 return tty->ops->break_ctl(tty, -1); tty_ioctl()
2941 if (tty->ops->break_ctl) tty_ioctl()
2942 return tty->ops->break_ctl(tty, 0); tty_ioctl()
2950 return send_break(tty, 250); tty_ioctl()
2953 return send_break(tty, arg ? arg*100 : 250); tty_ioctl()
2956 return tty_tiocmget(tty, p); tty_ioctl()
2960 return tty_tiocmset(tty, cmd, p); tty_ioctl()
2962 retval = tty_tiocgicount(tty, p); tty_ioctl()
2971 /* flush tty buffer and allow ldisc to process ioctl */ tty_ioctl()
2972 tty_buffer_flush(tty, NULL); tty_ioctl()
2980 if (tty->ops->ioctl) { tty_ioctl()
2981 retval = tty->ops->ioctl(tty, cmd, arg); tty_ioctl()
2985 ld = tty_ldisc_ref_wait(tty); tty_ioctl()
2988 retval = ld->ops->ioctl(tty, file, cmd, arg); tty_ioctl()
3000 struct tty_struct *tty = file_tty(file); tty_compat_ioctl() local
3004 if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) tty_compat_ioctl()
3007 if (tty->ops->compat_ioctl) { tty_compat_ioctl()
3008 retval = tty->ops->compat_ioctl(tty, cmd, arg); tty_compat_ioctl()
3013 ld = tty_ldisc_ref_wait(tty); tty_compat_ioctl()
3015 retval = ld->ops->compat_ioctl(tty, file, cmd, arg); tty_compat_ioctl()
3017 retval = n_tty_compat_ioctl_helper(tty, file, cmd, arg); tty_compat_ioctl()
3034 * tty when the user hits the "Secure Attention Key". Required for
3040 * with the current tty must be dead before the new getty is allowed
3050 void __do_SAK(struct tty_struct *tty) __do_SAK() argument
3053 tty_hangup(tty); __do_SAK()
3059 if (!tty) __do_SAK()
3061 session = tty->session; __do_SAK()
3063 tty_ldisc_flush(tty); __do_SAK()
3065 tty_driver_flush_buffer(tty); __do_SAK()
3071 " (%s): task_session(p)==tty->session\n", __do_SAK()
3076 * tty open. __do_SAK()
3079 if (p->signal->tty == tty) { __do_SAK()
3081 " (%s): task_session(p)==tty->session\n", __do_SAK()
3087 i = iterate_fd(p->files, 0, this_tty, tty); __do_SAK()
3090 " (%s): fd#%d opened to the tty\n", __do_SAK()
3102 struct tty_struct *tty = do_SAK_work() local
3104 __do_SAK(tty); do_SAK_work()
3108 * The tq handling here is a little racy - tty->SAK_work may already be queued.
3113 void do_SAK(struct tty_struct *tty) do_SAK() argument
3115 if (!tty) do_SAK()
3117 schedule_work(&tty->SAK_work); do_SAK()
3129 static struct device *tty_get_device(struct tty_struct *tty) tty_get_device() argument
3131 dev_t devt = tty_devnum(tty); tty_get_device()
3139 * This subroutine allocates and initializes a tty structure.
3141 * Locking: none - tty in question is not exposed at this point
3146 struct tty_struct *tty; alloc_tty_struct() local
3148 tty = kzalloc(sizeof(*tty), GFP_KERNEL); alloc_tty_struct()
3149 if (!tty) alloc_tty_struct()
3152 kref_init(&tty->kref); alloc_tty_struct()
3153 tty->magic = TTY_MAGIC; alloc_tty_struct()
3154 tty_ldisc_init(tty); alloc_tty_struct()
3155 tty->session = NULL; alloc_tty_struct()
3156 tty->pgrp = NULL; alloc_tty_struct()
3157 mutex_init(&tty->legacy_mutex); alloc_tty_struct()
3158 mutex_init(&tty->throttle_mutex); alloc_tty_struct()
3159 init_rwsem(&tty->termios_rwsem); alloc_tty_struct()
3160 mutex_init(&tty->winsize_mutex); alloc_tty_struct()
3161 init_ldsem(&tty->ldisc_sem); alloc_tty_struct()
3162 init_waitqueue_head(&tty->write_wait); alloc_tty_struct()
3163 init_waitqueue_head(&tty->read_wait); alloc_tty_struct()
3164 INIT_WORK(&tty->hangup_work, do_tty_hangup); alloc_tty_struct()
3165 mutex_init(&tty->atomic_write_lock); alloc_tty_struct()
3166 spin_lock_init(&tty->ctrl_lock); alloc_tty_struct()
3167 spin_lock_init(&tty->flow_lock); alloc_tty_struct()
3168 INIT_LIST_HEAD(&tty->tty_files); alloc_tty_struct()
3169 INIT_WORK(&tty->SAK_work, do_SAK_work); alloc_tty_struct()
3171 tty->driver = driver; alloc_tty_struct()
3172 tty->ops = driver->ops; alloc_tty_struct()
3173 tty->index = idx; alloc_tty_struct()
3174 tty_line_name(driver, idx, tty->name); alloc_tty_struct()
3175 tty->dev = tty_get_device(tty); alloc_tty_struct()
3177 return tty; alloc_tty_struct()
3182 * @tty: tty to deinitialize
3184 * This subroutine deinitializes a tty structure that has been newly
3187 * Locking: none - tty in question must not be exposed at this point
3189 void deinitialize_tty_struct(struct tty_struct *tty) deinitialize_tty_struct() argument
3191 tty_ldisc_deinit(tty); deinitialize_tty_struct()
3195 * tty_put_char - write one character to a tty
3196 * @tty: tty
3199 * Write one byte to the tty using the provided put_char method
3206 int tty_put_char(struct tty_struct *tty, unsigned char ch) tty_put_char() argument
3208 if (tty->ops->put_char) tty_put_char()
3209 return tty->ops->put_char(tty, ch); tty_put_char()
3210 return tty->ops->write(tty, &ch, 1); tty_put_char()
3226 * tty_register_device - register a tty device
3227 * @driver: the tty driver that describes the tty device
3228 * @index: the index in the tty driver for this tty device
3229 * @device: a struct device that is associated with this tty device.
3231 * for this tty device it can be set to NULL safely.
3233 * Returns a pointer to the struct device for this tty device
3236 * This call is required to be made to register an individual tty device
3237 * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If
3238 * that bit is not set, this function should not be called by a tty
3258 * tty_register_device_attr - register a tty device
3259 * @driver: the tty driver that describes the tty device
3260 * @index: the index in the tty driver for this tty device
3261 * @device: a struct device that is associated with this tty device.
3263 * for this tty device it can be set to NULL safely.
3267 * Returns a pointer to the struct device for this tty device
3270 * This call is required to be made to register an individual tty device
3271 * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If
3272 * that bit is not set, this function should not be called by a tty
3289 printk(KERN_ERR "Attempt to register invalid tty line number " tty_register_device_attr()
3335 * tty_unregister_device - unregister a tty device
3336 * @driver: the tty driver that describes the tty device
3337 * @index: the index in the tty driver for this tty device
3339 * If a tty device is registered with a call to tty_register_device() then
3340 * this function must be called when the tty device is gone.
3355 * __tty_alloc_driver -- allocate tty driver
3429 * we don't want to get memory leaks when modular tty destruct_tty_driver()
3472 * Called by a tty driver to register itself.
3534 * Called by a tty driver to unregister itself.
3553 dev_t tty_devnum(struct tty_struct *tty) tty_devnum() argument
3555 return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index; tty_devnum()
3600 tty_class = class_create(THIS_MODULE, "tty"); tty_class_init()
3667 * Ok, now we can initialize the rest of the tty devices and can count
3674 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) tty_init()
3675 panic("Couldn't register /dev/tty driver\n"); tty_init()
3676 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); tty_init()
1106 do_tty_write( ssize_t (write)struct tty_struct *, struct file *, const unsigned char *, size_t), struct tty_struct *tty, struct file *file, const char __user *buf, size_t count) do_tty_write() argument
1432 tty_driver_install_tty(struct tty_driver *driver, struct tty_struct *tty) tty_driver_install_tty() argument
H A Dtty_port.c7 #include <linux/tty.h>
37 * tty_port_link_device - link tty and tty_port
40 * @index: index of the tty
42 * Provide the tty layer wit ha link from a tty (specified by @index) to a
57 * tty_port_register_device - register tty device
60 * @index: index of the tty
64 * a concrete tty specified by @index. Use this or tty_port_install (or both).
77 * tty_port_register_device_attr - register tty device
80 * @index: index of the tty
86 * linked to a concrete tty specified by @index. Use this or tty_port_install
126 * @port: tty port to be doestroyed
143 /* check if last port ref was dropped before tty release */ tty_port_destructor()
163 * tty_port_tty_get - get a tty reference
164 * @port: tty port
166 * Return a refcount protected tty instance or NULL if the port is not
167 * associated with a tty (eg due to close or hangup)
173 struct tty_struct *tty; tty_port_tty_get() local
176 tty = tty_kref_get(port->tty); tty_port_tty_get()
178 return tty; tty_port_tty_get()
183 * tty_port_tty_set - set the tty of a port
184 * @port: tty port
185 * @tty: the tty
187 * Associate the port and tty pair. Manages any internal refcounts.
191 void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) tty_port_tty_set() argument
196 tty_kref_put(port->tty); tty_port_tty_set()
197 port->tty = tty_kref_get(tty); tty_port_tty_set()
202 static void tty_port_shutdown(struct tty_port *port, struct tty_struct *tty) tty_port_shutdown() argument
213 if (tty && C_HUPCL(tty)) tty_port_shutdown()
225 * @port: tty port
227 * Perform port level tty hangup flag and count changes. Drop the tty
230 * Caller holds tty lock.
235 struct tty_struct *tty; tty_port_hangup() local
241 tty = port->tty; tty_port_hangup()
242 if (tty) tty_port_hangup()
243 set_bit(TTY_IO_ERROR, &tty->flags); tty_port_hangup()
244 port->tty = NULL; tty_port_hangup()
246 tty_port_shutdown(port, tty); tty_port_hangup()
247 tty_kref_put(tty); tty_port_hangup()
254 * tty_port_tty_hangup - helper to hang up a tty
256 * @port: tty port
261 struct tty_struct *tty = tty_port_tty_get(port); tty_port_tty_hangup() local
263 if (tty && (!check_clocal || !C_CLOCAL(tty))) tty_port_tty_hangup()
264 tty_hangup(tty); tty_port_tty_hangup()
265 tty_kref_put(tty); tty_port_tty_hangup()
270 * tty_port_tty_wakeup - helper to wake up a tty
272 * @port: tty port
276 struct tty_struct *tty = tty_port_tty_get(port); tty_port_tty_wakeup() local
278 if (tty) { tty_port_tty_wakeup()
279 tty_wakeup(tty); tty_port_tty_wakeup()
280 tty_kref_put(tty); tty_port_tty_wakeup()
287 * @port: tty port
291 * internal to the tty port.
304 * @port: tty port
308 * internal to the tty port.
320 * @port: tty port
324 * internal to the tty port.
335 * tty_port_block_til_ready - Waiting logic for tty open
336 * @port: the tty port being opened
337 * @tty: the tty device being bound
340 * Implement the core POSIX/SuS tty behaviour when opening a tty device.
353 * Caller holds tty lock.
355 * NB: May drop and reacquire tty lock when blocking, so tty and tty_port
360 struct tty_struct *tty, struct file *filp) tty_port_block_til_ready()
368 wait_event_interruptible_tty(tty, port->close_wait, tty_port_block_til_ready()
378 if (tty->flags & (1 << TTY_IO_ERROR)) { tty_port_block_til_ready()
384 if (tty->termios.c_cflag & CBAUD) tty_port_block_til_ready()
390 if (C_CLOCAL(tty)) tty_port_block_til_ready()
407 if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) tty_port_block_til_ready()
433 tty_unlock(tty); tty_port_block_til_ready()
435 tty_lock(tty); tty_port_block_til_ready()
452 static void tty_port_drain_delay(struct tty_port *port, struct tty_struct *tty) tty_port_drain_delay() argument
454 unsigned int bps = tty_get_baud_rate(tty); tty_port_drain_delay()
466 /* Caller holds tty lock.
467 * NB: may drop and reacquire tty lock (in tty_wait_until_sent_from_close())
468 * so tty and tty port may have changed state (but not hung up or reopened).
471 struct tty_struct *tty, struct file *filp) tty_port_close_start()
479 if (tty->count == 1 && port->count != 1) { tty_port_close_start()
481 "tty_port_close_start: tty->count = 1 port count = %d.\n", tty_port_close_start()
498 tty->closing = 1; tty_port_close_start()
502 if (tty->flow_stopped) tty_port_close_start()
503 tty_driver_flush_buffer(tty); tty_port_close_start()
505 tty_wait_until_sent_from_close(tty, port->closing_wait); tty_port_close_start()
507 tty_port_drain_delay(port, tty); tty_port_close_start()
510 tty_ldisc_flush(tty); tty_port_close_start()
517 /* Caller holds tty lock */ tty_port_close_end()
518 void tty_port_close_end(struct tty_port *port, struct tty_struct *tty) tty_port_close_end() argument
522 tty_ldisc_flush(tty); tty_port_close_end()
523 tty->closing = 0; tty_port_close_end()
545 * Caller holds tty lock
547 * NB: may drop and reacquire tty lock (in tty_port_close_start()->
548 * tty_wait_until_sent_from_close()) so tty and tty_port may have changed
551 void tty_port_close(struct tty_port *port, struct tty_struct *tty, tty_port_close() argument
554 if (tty_port_close_start(port, tty, filp) == 0) tty_port_close()
556 tty_port_shutdown(port, tty); tty_port_close()
557 set_bit(TTY_IO_ERROR, &tty->flags); tty_port_close()
558 tty_port_close_end(port, tty); tty_port_close()
564 * tty_port_install - generic tty->ops->install handler
567 * @tty: tty to be installed
570 * to a concrete tty specified by @tty. Use this or tty_port_register_device
574 struct tty_struct *tty) tty_port_install()
576 tty->port = port; tty_port_install()
577 return tty_standard_install(driver, tty); tty_port_install()
584 * Caller holds tty lock.
586 * NB: may drop and reacquire tty lock (in tty_port_block_til_ready()) so
587 * tty and tty_port may have changed state (eg., may be hung up now)
589 int tty_port_open(struct tty_port *port, struct tty_struct *tty, tty_port_open() argument
595 tty_port_tty_set(port, tty); tty_port_open()
606 clear_bit(TTY_IO_ERROR, &tty->flags); tty_port_open()
608 int retval = port->ops->activate(port, tty); tty_port_open()
617 return tty_port_block_til_ready(port, tty, filp); tty_port_open()
359 tty_port_block_til_ready(struct tty_port *port, struct tty_struct *tty, struct file *filp) tty_port_block_til_ready() argument
470 tty_port_close_start(struct tty_port *port, struct tty_struct *tty, struct file *filp) tty_port_close_start() argument
573 tty_port_install(struct tty_port *port, struct tty_driver *driver, struct tty_struct *tty) tty_port_install() argument
H A Damiserial.c13 * The port is registered with the tty driver as minor device 64, and
48 tty->name, (info->tport.flags), serial_driver->refcount,info->count,tty->count,s)
70 #include <linux/tty.h>
122 static void change_speed(struct tty_struct *tty, struct serial_state *info,
124 static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
183 * This routines are called before setting or resetting tty->stopped.
187 static void rs_stop(struct tty_struct *tty) rs_stop() argument
189 struct serial_state *info = tty->driver_data; rs_stop()
192 if (serial_paranoia_check(info, tty->name, "rs_stop")) rs_stop()
207 static void rs_start(struct tty_struct *tty) rs_start() argument
209 struct serial_state *info = tty->driver_data; rs_start()
212 if (serial_paranoia_check(info, tty->name, "rs_start")) rs_start()
316 do_SAK(info->tport.tty); receive_chars()
350 || info->tport.tty->stopped transmit_chars()
351 || info->tport.tty->hw_stopped) { transmit_chars()
366 tty_wakeup(info->tport.tty); transmit_chars()
413 if (port->tty) check_modem_status()
414 tty_hangup(port->tty); check_modem_status()
418 if (port->tty->hw_stopped) { check_modem_status()
423 port->tty->hw_stopped = 0; check_modem_status()
430 tty_wakeup(port->tty); check_modem_status()
438 port->tty->hw_stopped = 1; check_modem_status()
471 if (!info->tport.tty) ser_rx_int()
490 if (!info->tport.tty) ser_tx_int()
516 static int startup(struct tty_struct *tty, struct serial_state *info) startup() argument
551 set_bit(TTY_IO_ERROR, &tty->flags); startup()
566 if (C_BAUD(tty)) startup()
570 clear_bit(TTY_IO_ERROR, &tty->flags); startup()
574 * Set up the tty->alt_speed kludge startup()
577 tty->alt_speed = 57600; startup()
579 tty->alt_speed = 115200; startup()
581 tty->alt_speed = 230400; startup()
583 tty->alt_speed = 460800; startup()
588 change_speed(tty, info, NULL); startup()
603 static void shutdown(struct tty_struct *tty, struct serial_state *info) shutdown() argument
643 if (tty->termios.c_cflag & HUPCL) shutdown()
647 set_bit(TTY_IO_ERROR, &tty->flags); shutdown()
658 static void change_speed(struct tty_struct *tty, struct serial_state *info, change_speed() argument
667 cflag = tty->termios.c_cflag; change_speed()
688 baud = tty_get_baud_rate(tty); change_speed()
703 /* FIXME: Will need updating for new tty in the end */ change_speed()
704 tty->termios.c_cflag &= ~CBAUD; change_speed()
705 tty->termios.c_cflag |= (old_termios->c_cflag & CBAUD); change_speed()
706 baud = tty_get_baud_rate(tty); change_speed()
751 if (I_INPCK(tty)) change_speed()
753 if (I_BRKINT(tty) || I_PARMRK(tty)) change_speed()
760 if (I_IGNPAR(tty)) change_speed()
762 if (I_IGNBRK(tty)) { change_speed()
768 if (I_IGNPAR(tty)) change_speed()
796 static int rs_put_char(struct tty_struct *tty, unsigned char ch) rs_put_char() argument
801 info = tty->driver_data; rs_put_char()
803 if (serial_paranoia_check(info, tty->name, "rs_put_char")) rs_put_char()
823 static void rs_flush_chars(struct tty_struct *tty) rs_flush_chars() argument
825 struct serial_state *info = tty->driver_data; rs_flush_chars()
828 if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) rs_flush_chars()
832 || tty->stopped rs_flush_chars()
833 || tty->hw_stopped rs_flush_chars()
847 static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) rs_write() argument
850 struct serial_state *info = tty->driver_data; rs_write()
853 if (serial_paranoia_check(info, tty->name, "rs_write")) rs_write()
879 && !tty->stopped rs_write()
880 && !tty->hw_stopped rs_write()
894 static int rs_write_room(struct tty_struct *tty) rs_write_room() argument
896 struct serial_state *info = tty->driver_data; rs_write_room()
898 if (serial_paranoia_check(info, tty->name, "rs_write_room")) rs_write_room()
903 static int rs_chars_in_buffer(struct tty_struct *tty) rs_chars_in_buffer() argument
905 struct serial_state *info = tty->driver_data; rs_chars_in_buffer()
907 if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) rs_chars_in_buffer()
912 static void rs_flush_buffer(struct tty_struct *tty) rs_flush_buffer() argument
914 struct serial_state *info = tty->driver_data; rs_flush_buffer()
917 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) rs_flush_buffer()
922 tty_wakeup(tty); rs_flush_buffer()
929 static void rs_send_xchar(struct tty_struct *tty, char ch) rs_send_xchar() argument
931 struct serial_state *info = tty->driver_data; rs_send_xchar()
934 if (serial_paranoia_check(info, tty->name, "rs_send_xchar")) rs_send_xchar()
960 * This routine is called by the upper-layer tty layer to signal that
964 static void rs_throttle(struct tty_struct * tty) rs_throttle() argument
966 struct serial_state *info = tty->driver_data; rs_throttle()
971 printk("throttle %s: %d....\n", tty_name(tty, buf), rs_throttle()
972 tty->ldisc.chars_in_buffer(tty)); rs_throttle()
975 if (serial_paranoia_check(info, tty->name, "rs_throttle")) rs_throttle()
978 if (I_IXOFF(tty)) rs_throttle()
979 rs_send_xchar(tty, STOP_CHAR(tty)); rs_throttle()
981 if (tty->termios.c_cflag & CRTSCTS) rs_throttle()
989 static void rs_unthrottle(struct tty_struct * tty) rs_unthrottle() argument
991 struct serial_state *info = tty->driver_data; rs_unthrottle()
996 printk("unthrottle %s: %d....\n", tty_name(tty, buf), rs_unthrottle()
997 tty->ldisc.chars_in_buffer(tty)); rs_unthrottle()
1000 if (serial_paranoia_check(info, tty->name, "rs_unthrottle")) rs_unthrottle()
1003 if (I_IXOFF(tty)) { rs_unthrottle()
1007 rs_send_xchar(tty, START_CHAR(tty)); rs_unthrottle()
1009 if (tty->termios.c_cflag & CRTSCTS) rs_unthrottle()
1022 static int get_serial_info(struct tty_struct *tty, struct serial_state *state, get_serial_info() argument
1030 tty_lock(tty); get_serial_info()
1031 tmp.line = tty->index; get_serial_info()
1039 tty_unlock(tty); get_serial_info()
1045 static int set_serial_info(struct tty_struct *tty, struct serial_state *state, set_serial_info() argument
1056 tty_lock(tty); set_serial_info()
1061 tty_unlock(tty); set_serial_info()
1071 tty_unlock(tty); set_serial_info()
1081 tty_unlock(tty); set_serial_info()
1102 tty->alt_speed = 57600; set_serial_info()
1104 tty->alt_speed = 115200; set_serial_info()
1106 tty->alt_speed = 230400; set_serial_info()
1108 tty->alt_speed = 460800; set_serial_info()
1109 change_speed(tty, state, NULL); set_serial_info()
1112 retval = startup(tty, state); set_serial_info()
1113 tty_unlock(tty); set_serial_info()
1145 static int rs_tiocmget(struct tty_struct *tty) rs_tiocmget() argument
1147 struct serial_state *info = tty->driver_data; rs_tiocmget()
1151 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) rs_tiocmget()
1153 if (tty->flags & (1 << TTY_IO_ERROR)) rs_tiocmget()
1167 static int rs_tiocmset(struct tty_struct *tty, unsigned int set, rs_tiocmset() argument
1170 struct serial_state *info = tty->driver_data; rs_tiocmset()
1173 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) rs_tiocmset()
1175 if (tty->flags & (1 << TTY_IO_ERROR)) rs_tiocmset()
1195 static int rs_break(struct tty_struct *tty, int break_state) rs_break() argument
1197 struct serial_state *info = tty->driver_data; rs_break()
1200 if (serial_paranoia_check(info, tty->name, "rs_break")) rs_break()
1219 static int rs_get_icount(struct tty_struct *tty, rs_get_icount() argument
1222 struct serial_state *info = tty->driver_data; rs_get_icount()
1244 static int rs_ioctl(struct tty_struct *tty, rs_ioctl() argument
1247 struct serial_state *info = tty->driver_data; rs_ioctl()
1254 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) rs_ioctl()
1260 if (tty->flags & (1 << TTY_IO_ERROR)) rs_ioctl()
1266 return get_serial_info(tty, info, argp); rs_ioctl()
1268 return set_serial_info(tty, info, argp); rs_ioctl()
1333 static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) rs_set_termios() argument
1335 struct serial_state *info = tty->driver_data; rs_set_termios()
1337 unsigned int cflag = tty->termios.c_cflag; rs_set_termios()
1339 change_speed(tty, info, old_termios); rs_set_termios()
1354 if (!(tty->termios.c_cflag & CRTSCTS) || rs_set_termios()
1355 !test_bit(TTY_THROTTLED, &tty->flags)) { rs_set_termios()
1365 !(tty->termios.c_cflag & CRTSCTS)) { rs_set_termios()
1366 tty->hw_stopped = 0; rs_set_termios()
1367 rs_start(tty); rs_set_termios()
1378 (tty->termios.c_cflag & CLOCAL)) rs_set_termios()
1393 static void rs_close(struct tty_struct *tty, struct file * filp) rs_close() argument
1395 struct serial_state *state = tty->driver_data; rs_close()
1398 if (serial_paranoia_check(state, tty->name, "rs_close")) rs_close()
1401 if (tty_port_close_start(port, tty, filp) == 0) rs_close()
1424 rs_wait_until_sent(tty, state->timeout); rs_close()
1426 shutdown(tty, state); rs_close()
1427 rs_flush_buffer(tty); rs_close()
1429 tty_ldisc_flush(tty); rs_close()
1430 port->tty = NULL; rs_close()
1432 tty_port_close_end(port, tty); rs_close()
1438 static void rs_wait_until_sent(struct tty_struct *tty, int timeout) rs_wait_until_sent() argument
1440 struct serial_state *info = tty->driver_data; rs_wait_until_sent()
1444 if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent")) rs_wait_until_sent()
1501 static void rs_hangup(struct tty_struct *tty) rs_hangup() argument
1503 struct serial_state *info = tty->driver_data; rs_hangup()
1505 if (serial_paranoia_check(info, tty->name, "rs_hangup")) rs_hangup()
1508 rs_flush_buffer(tty); rs_hangup()
1509 shutdown(tty, info); rs_hangup()
1512 info->tport.tty = NULL; rs_hangup()
1520 * initialization for the tty structure.
1522 static int rs_open(struct tty_struct *tty, struct file * filp) rs_open() argument
1524 struct serial_state *info = rs_table + tty->index; rs_open()
1529 port->tty = tty; rs_open()
1530 tty->driver_data = info; rs_open()
1531 tty->port = port; rs_open()
1532 if (serial_paranoia_check(info, tty->name, "rs_open")) rs_open()
1537 retval = startup(tty, info); rs_open()
1542 return tty_port_block_til_ready(port, tty, filp); rs_open()
H A Dn_hdlc.c16 * This module implements the tty line discipline N_HDLC for use with
17 * tty device drivers that support bit-synchronous HDLC communications.
21 * 1. tty write calls represent one complete transmit frame of data
34 * the tty flip buffer and call the line discipline receive
40 * tty read calls.
42 * 3. tty read calls returns an entire frame of data or nothing.
46 * of the tty flags
53 * These conventions allow the standard tty programming interface
98 #include <linux/tty.h>
100 #include <linux/string.h> /* used in new tty drivers */
101 #include <linux/signal.h> /* used in new tty drivers */
135 * @tty - ptr to TTY structure
136 * @backup_tty - TTY to use if tty gets closed
148 struct tty_struct *tty; member in struct:n_hdlc
180 static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
182 static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
184 static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
186 static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
188 static int n_hdlc_tty_open(struct tty_struct *tty);
189 static void n_hdlc_tty_close(struct tty_struct *tty);
190 static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *cp,
192 static void n_hdlc_tty_wakeup(struct tty_struct *tty);
196 #define tty2n_hdlc(tty) ((struct n_hdlc *) ((tty)->disc_data))
197 #define n_hdlc2tty(n_hdlc) ((n_hdlc)->tty)
199 static void flush_rx_queue(struct tty_struct *tty) flush_rx_queue() argument
201 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); flush_rx_queue()
208 static void flush_tx_queue(struct tty_struct *tty) flush_tx_queue() argument
210 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); flush_tx_queue()
245 struct tty_struct *tty = n_hdlc2tty (n_hdlc); n_hdlc_release() local
252 wake_up_interruptible (&tty->read_wait); n_hdlc_release()
253 wake_up_interruptible (&tty->write_wait); n_hdlc_release()
255 if (tty->disc_data == n_hdlc) n_hdlc_release()
256 tty->disc_data = NULL; /* Break the tty->n_hdlc link */ n_hdlc_release()
294 * @tty - pointer to tty info structure
297 * else, the tty is closed, or the tty detects a hangup.
299 static void n_hdlc_tty_close(struct tty_struct *tty) n_hdlc_tty_close() argument
301 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); n_hdlc_tty_close()
308 printk (KERN_WARNING"n_hdlc: trying to close unopened tty!\n"); n_hdlc_tty_close()
312 clear_bit(TTY_NO_WRITE_SPLIT,&tty->flags); n_hdlc_tty_close()
314 tty->disc_data = NULL; n_hdlc_tty_close()
315 if (tty == n_hdlc->backup_tty) n_hdlc_tty_close()
317 if (tty != n_hdlc->tty) n_hdlc_tty_close()
320 n_hdlc->tty = n_hdlc->backup_tty; n_hdlc_tty_close()
333 * @tty - pointer to tty info structure
337 static int n_hdlc_tty_open (struct tty_struct *tty) n_hdlc_tty_open() argument
339 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); n_hdlc_tty_open()
344 tty->name); n_hdlc_tty_open()
348 printk (KERN_ERR"n_hdlc_tty_open:tty already associated!\n" ); n_hdlc_tty_open()
358 tty->disc_data = n_hdlc; n_hdlc_tty_open()
359 n_hdlc->tty = tty; n_hdlc_tty_open()
360 tty->receive_room = 65536; n_hdlc_tty_open()
364 set_bit(TTY_NO_WRITE_SPLIT,&tty->flags); n_hdlc_tty_open()
368 tty_driver_flush_buffer(tty); n_hdlc_tty_open()
380 * @tty - pointer to tty instance data
384 * list and by the tty wakeup callback.
386 static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty) n_hdlc_send_frames() argument
419 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); n_hdlc_send_frames()
420 actual = tty->ops->write(tty, tbuf->buf, tbuf->count); n_hdlc_send_frames()
444 wake_up_interruptible(&tty->write_wait); n_hdlc_send_frames()
461 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); n_hdlc_send_frames()
478 * @tty - pointer to associated tty instance data
482 static void n_hdlc_tty_wakeup(struct tty_struct *tty) n_hdlc_tty_wakeup() argument
484 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); n_hdlc_tty_wakeup()
492 if (tty != n_hdlc->tty) { n_hdlc_tty_wakeup()
493 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); n_hdlc_tty_wakeup()
497 n_hdlc_send_frames (n_hdlc, tty); n_hdlc_tty_wakeup()
502 * n_hdlc_tty_receive - Called by tty driver when receive data is available
503 * @tty - pointer to tty instance data
508 * Called by tty low level driver when receive data is available. Data is
511 static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data, n_hdlc_tty_receive() argument
514 register struct n_hdlc *n_hdlc = tty2n_hdlc (tty); n_hdlc_tty_receive()
521 /* This can happen if stuff comes in on the backup tty */ n_hdlc_tty_receive()
522 if (!n_hdlc || tty != n_hdlc->tty) n_hdlc_tty_receive()
563 wake_up_interruptible (&tty->read_wait); n_hdlc_tty_receive()
564 if (n_hdlc->tty->fasync != NULL) n_hdlc_tty_receive()
565 kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN); n_hdlc_tty_receive()
571 * @tty - pointer to tty instance data
578 static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file, n_hdlc_tty_read() argument
581 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); n_hdlc_tty_read()
600 add_wait_queue(&tty->read_wait, &wait); n_hdlc_tty_read()
603 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { n_hdlc_tty_read()
646 remove_wait_queue(&tty->read_wait, &wait); n_hdlc_tty_read()
655 * @tty - pointer to associated tty device instance data
662 static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, n_hdlc_tty_write() argument
665 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); n_hdlc_tty_write()
691 add_wait_queue(&tty->write_wait, &wait); n_hdlc_tty_write()
706 n_hdlc = tty2n_hdlc (tty); n_hdlc_tty_write()
708 tty != n_hdlc->tty) { n_hdlc_tty_write()
721 remove_wait_queue(&tty->write_wait, &wait); n_hdlc_tty_write()
730 n_hdlc_send_frames(n_hdlc,tty); n_hdlc_tty_write()
738 * n_hdlc_tty_ioctl - process IOCTL system call for the tty device.
739 * @tty - pointer to tty instance data
746 static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file, n_hdlc_tty_ioctl() argument
749 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); n_hdlc_tty_ioctl()
777 count = tty_chars_in_buffer(tty); n_hdlc_tty_ioctl()
790 flush_tx_queue(tty); n_hdlc_tty_ioctl()
795 error = n_tty_ioctl_helper(tty, file, cmd, arg); n_hdlc_tty_ioctl()
804 * @tty - pointer to tty instance data
812 static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp, n_hdlc_tty_poll() argument
815 struct n_hdlc *n_hdlc = tty2n_hdlc (tty); n_hdlc_tty_poll()
821 if (n_hdlc && n_hdlc->magic == HDLC_MAGIC && tty == n_hdlc->tty) { n_hdlc_tty_poll()
825 poll_wait(filp, &tty->read_wait, wait); n_hdlc_tty_poll()
826 poll_wait(filp, &tty->write_wait, wait); n_hdlc_tty_poll()
831 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) n_hdlc_tty_poll()
835 if (!tty_is_writelocked(tty) && n_hdlc_tty_poll()
983 /* Release tty registration of line discipline */ n_hdlc_exit()
H A Dtty_buffer.c7 #include <linux/tty.h>
31 * We default to dicing tty buffer allocations to this many characters
108 * tty_buffer_free_all - free buffers used by a tty
109 * @tty: tty to free from
111 * Remove all the buffers pending on a tty whether queued with data
112 * or in the free ring. Must be called when the tty is no longer in use
138 * tty_buffer_alloc - allocate a tty buffer
139 * @tty: tty device
142 * Allocate a new tty buffer to hold the desired number of characters.
180 * tty_buffer_free - free a tty buffer
181 * @tty: tty owning the buffer
184 * Free a tty buffer, or add it to the free list according to our
202 * tty_buffer_flush - flush full tty buffers
203 * @tty: tty to flush
213 void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld) tty_buffer_flush() argument
215 struct tty_port *port = tty->port; tty_buffer_flush()
229 ld->ops->flush_buffer(tty); tty_buffer_flush()
236 * tty_buffer_request_room - grow tty buffer if needed
237 * @tty: tty structure
241 * Make at least size bytes of linear space available for the tty
289 * tty_insert_flip_string_fixed_flag - Add characters to the tty buffer
290 * @port: tty port
295 * Queue a series of bytes to the tty buffering. All the characters
324 * tty_insert_flip_string_flags - Add characters to the tty buffer
325 * @port: tty port
330 * Queue a series of bytes to the tty buffering. For each character
360 * @port: tty port to push from
378 * @port: tty port
406 receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count) receive_buf() argument
408 struct tty_ldisc *disc = tty->ldisc; receive_buf()
416 count = disc->ops->receive_buf2(tty, p, f, count); receive_buf()
418 count = min_t(int, count, tty->receive_room); receive_buf()
420 disc->ops->receive_buf(tty, p, f, count); receive_buf()
428 * @work: tty structure passed from work queue.
433 * The receive_buf method is single threaded for each tty instance.
443 struct tty_struct *tty; flush_to_ldisc() local
446 tty = port->itty; flush_to_ldisc()
447 if (tty == NULL) flush_to_ldisc()
450 disc = tty_ldisc_ref(tty); flush_to_ldisc()
480 count = receive_buf(tty, head, count); flush_to_ldisc()
492 * @port: tty port to push
508 * tty_buffer_init - prepare a tty buffer structure
509 * @tty: tty to initialise
511 * Set up the initial state of the buffer management for a tty device.
512 * Must be called before the other tty buffer functions are used.
531 * tty_buffer_set_limit - change the tty buffer memory limit
532 * @port: tty port to change
534 * Change the tty buffer memory limit.
535 * Must be called before the other tty buffer functions are used.
H A Dgoldfish.c19 #include <linux/tty.h>
93 static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty) goldfish_tty_activate() argument
108 static int goldfish_tty_open(struct tty_struct *tty, struct file *filp) goldfish_tty_open() argument
110 struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; goldfish_tty_open()
111 return tty_port_open(&qtty->port, tty, filp); goldfish_tty_open()
114 static void goldfish_tty_close(struct tty_struct *tty, struct file *filp) goldfish_tty_close() argument
116 tty_port_close(tty->port, tty, filp); goldfish_tty_close()
119 static void goldfish_tty_hangup(struct tty_struct *tty) goldfish_tty_hangup() argument
121 tty_port_hangup(tty->port); goldfish_tty_hangup()
124 static int goldfish_tty_write(struct tty_struct *tty, const unsigned char *buf, goldfish_tty_write() argument
127 goldfish_tty_do_write(tty->index, buf, count); goldfish_tty_write()
131 static int goldfish_tty_write_room(struct tty_struct *tty) goldfish_tty_write_room() argument
136 static int goldfish_tty_chars_in_buffer(struct tty_struct *tty) goldfish_tty_chars_in_buffer() argument
138 struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; goldfish_tty_chars_in_buffer()
182 struct tty_driver *tty; goldfish_tty_create_driver() local
190 tty = alloc_tty_driver(goldfish_tty_line_count); goldfish_tty_create_driver()
191 if (tty == NULL) { goldfish_tty_create_driver()
195 tty->driver_name = "goldfish"; goldfish_tty_create_driver()
196 tty->name = "ttyGF"; goldfish_tty_create_driver()
197 tty->type = TTY_DRIVER_TYPE_SERIAL; goldfish_tty_create_driver()
198 tty->subtype = SERIAL_TYPE_NORMAL; goldfish_tty_create_driver()
199 tty->init_termios = tty_std_termios; goldfish_tty_create_driver()
200 tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | goldfish_tty_create_driver()
202 tty_set_operations(tty, &goldfish_tty_ops); goldfish_tty_create_driver()
203 ret = tty_register_driver(tty); goldfish_tty_create_driver()
207 goldfish_tty_driver = tty; goldfish_tty_create_driver()
211 put_tty_driver(tty); goldfish_tty_create_driver()
H A Dtty_audit.c14 #include <linux/tty.h>
102 tty_audit_log("tty", buf->major, buf->minor, buf->data, buf->valid); tty_audit_buf_push()
142 void tty_audit_tiocsti(struct tty_struct *tty, char ch) tty_audit_tiocsti() argument
155 major = tty->driver->major; tty_audit_tiocsti()
156 minor = tty->driver->minor_start + tty->index; tty_audit_tiocsti()
178 * Try to lock sighand and get a reference to the tty audit buffer if available.
215 * Get an audit buffer for @tty, allocate it if necessary. Return %NULL
219 static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty, tty_audit_buf_get() argument
237 buf2 = tty_audit_buf_alloc(tty->driver->major, tty_audit_buf_get()
238 tty->driver->minor_start + tty->index, tty_audit_buf_get()
266 * Audit @data of @size from @tty, if necessary.
268 void tty_audit_add_data(struct tty_struct *tty, const void *data, tty_audit_add_data() argument
282 if (!audit_log_tty_passwd && icanon && !L_ECHO(tty)) tty_audit_add_data()
285 if (tty->driver->type == TTY_DRIVER_TYPE_PTY tty_audit_add_data()
286 && tty->driver->subtype == PTY_TYPE_MASTER) tty_audit_add_data()
289 buf = tty_audit_buf_get(tty, icanon); tty_audit_add_data()
294 major = tty->driver->major; tty_audit_add_data()
295 minor = tty->driver->minor_start + tty->index; tty_audit_add_data()
323 * Make sure no audit data is pending for @tty on the current process.
325 void tty_audit_push(struct tty_struct *tty) tty_audit_push() argument
343 major = tty->driver->major; tty_audit_push()
344 minor = tty->driver->minor_start + tty->index; tty_audit_push()
H A Dn_tracerouter.c2 * n_tracerouter.c - Trace data router through tty space
31 #include <linux/tty.h>
51 * kref_tty holds the tty reference the ldisc sits on top of.
59 /* lock for when tty reference is being used */
63 * n_tracerouter_open() - Called when a tty is opened by a SW entity.
64 * @tty: terminal device to the ldisc.
71 static int n_tracerouter_open(struct tty_struct *tty) n_tracerouter_open() argument
78 tr_data->kref_tty = tty_kref_get(tty); n_tracerouter_open()
83 tty->disc_data = tr_data; n_tracerouter_open()
84 tty->receive_room = RECEIVE_ROOM; n_tracerouter_open()
85 tty_driver_flush_buffer(tty); n_tracerouter_open()
95 * @tty: terminal device to the ldisc.
99 static void n_tracerouter_close(struct tty_struct *tty) n_tracerouter_close() argument
101 struct tracerouter_data *tptr = tty->disc_data; n_tracerouter_close()
105 tty_driver_flush_buffer(tty); n_tracerouter_close()
109 tty->disc_data = NULL; n_tracerouter_close()
115 * @tty: terminal device passed into the ldisc.
130 static ssize_t n_tracerouter_read(struct tty_struct *tty, struct file *file, n_tracerouter_read() argument
137 * @tty: terminal device passed into the ldisc.
154 static ssize_t n_tracerouter_write(struct tty_struct *tty, struct file *file, n_tracerouter_write() argument
161 * @tty: terminal device passed into the ldisc. It's assumed
162 * tty will never be NULL.
171 static void n_tracerouter_receivebuf(struct tty_struct *tty, n_tracerouter_receivebuf() argument
213 /* Note N_TRACEROUTER is defined in linux/tty.h */ n_tracerouter_init()
H A Dn_tracesink.c2 * n_tracesink.c - Trace data router and sink path through tty space.
21 * to a user-desired tty port, like USB.
33 #include <linux/tty.h>
50 * to a tty from anyone calling his kernel API, which
55 * would crash the system if tty is not checked.
61 * n_tracesink_open() - Called when a tty is opened by a SW entity.
62 * @tty: terminal device to the ldisc.
66 * -EFAULT = couldn't get a tty kref n_tracesink will sit
74 static int n_tracesink_open(struct tty_struct *tty) n_tracesink_open() argument
80 this_tty = tty_kref_get(tty); n_tracesink_open()
84 tty->disc_data = this_tty; n_tracesink_open()
85 tty_driver_flush_buffer(tty); n_tracesink_open()
96 * @tty: terminal device to the ldisc.
100 static void n_tracesink_close(struct tty_struct *tty) n_tracesink_close() argument
103 tty_driver_flush_buffer(tty); n_tracesink_close()
106 tty->disc_data = NULL; n_tracesink_close()
112 * @tty: terminal device passed into the ldisc.
127 static ssize_t n_tracesink_read(struct tty_struct *tty, struct file *file, n_tracesink_read() argument
134 * @tty: terminal device passed into the ldisc.
151 static ssize_t n_tracesink_write(struct tty_struct *tty, struct file *file, n_tracesink_write() argument
161 * @buf: Trace debuging data buffer to write to tty target
166 * Caveat: If this line discipline does not set the tty it sits
168 * call the tty's write() call because it will have no pointer
210 /* Note N_TRACESINK is defined in linux/tty.h */ n_tracesink_init()
H A Disicom.c121 #include <linux/tty.h>
178 static void isicom_start(struct tty_struct *tty);
408 struct tty_struct *tty; isicom_tx() local
435 tty = tty_port_tty_get(&port->port); isicom_tx()
436 if (tty == NULL) isicom_tx()
446 if (txcount <= 0 || tty->stopped || tty->hw_stopped) isicom_tx()
499 tty_wakeup(tty); isicom_tx()
503 tty_kref_put(tty); isicom_tx()
519 struct tty_struct *tty; isicom_interrupt() local
562 tty = tty_port_tty_get(&port->port); isicom_interrupt()
563 if (tty == NULL) { isicom_interrupt()
587 tty_hangup(tty); isicom_interrupt()
604 if (tty->hw_stopped) { isicom_interrupt()
606 tty->hw_stopped = 0; isicom_interrupt()
610 tty_wakeup(tty); isicom_interrupt()
613 tty->hw_stopped = 1; isicom_interrupt()
639 do_SAK(tty); isicom_interrupt()
678 tty_kref_put(tty); isicom_interrupt()
683 static void isicom_config_port(struct tty_struct *tty) isicom_config_port() argument
685 struct isi_port *port = tty->driver_data; isicom_config_port()
693 /* FIXME: Switch to new tty baud API */ isicom_config_port()
694 baud = C_BAUD(tty); isicom_config_port()
705 tty->termios.c_cflag &= ~CBAUDEX; isicom_config_port()
736 switch (C_CSIZE(tty)) { isicom_config_port()
751 if (C_CSTOPB(tty)) isicom_config_port()
753 if (C_PARENB(tty)) { isicom_config_port()
755 if (C_PARODD(tty)) isicom_config_port()
761 if (C_CLOCAL(tty)) isicom_config_port()
769 if (C_CRTSCTS(tty)) { isicom_config_port()
773 if (I_IXON(tty)) isicom_config_port()
775 if (I_IXOFF(tty)) isicom_config_port()
781 outw((STOP_CHAR(tty)) << 8 | (START_CHAR(tty)), base); isicom_config_port()
786 if (C_CREAD(tty)) { isicom_config_port()
811 static int isicom_activate(struct tty_port *tport, struct tty_struct *tty) isicom_activate() argument
832 isicom_config_port(tty); isicom_activate()
844 static struct tty_port *isicom_find_port(struct tty_struct *tty) isicom_find_port() argument
849 int line = tty->index; isicom_find_port()
862 if (isicom_paranoia_check(port, tty->name, "isicom_open")) isicom_find_port()
868 static int isicom_open(struct tty_struct *tty, struct file *filp) isicom_open() argument
873 tport = isicom_find_port(tty); isicom_open()
878 tty->driver_data = port; isicom_open()
879 return tty_port_open(tport, tty, filp); isicom_open()
899 static void isicom_flush_buffer(struct tty_struct *tty) isicom_flush_buffer() argument
901 struct isi_port *port = tty->driver_data; isicom_flush_buffer()
905 if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer")) isicom_flush_buffer()
912 tty_wakeup(tty); isicom_flush_buffer()
931 static void isicom_close(struct tty_struct *tty, struct file *filp) isicom_close() argument
933 struct isi_port *ip = tty->driver_data; isicom_close()
940 if (isicom_paranoia_check(ip, tty->name, "isicom_close")) isicom_close()
942 tty_port_close(port, tty, filp); isicom_close()
946 static int isicom_write(struct tty_struct *tty, const unsigned char *buf, isicom_write() argument
949 struct isi_port *port = tty->driver_data; isicom_write()
954 if (isicom_paranoia_check(port, tty->name, "isicom_write")) isicom_write()
973 if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped) isicom_write()
980 static int isicom_put_char(struct tty_struct *tty, unsigned char ch) isicom_put_char() argument
982 struct isi_port *port = tty->driver_data; isicom_put_char()
986 if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) isicom_put_char()
1003 static void isicom_flush_chars(struct tty_struct *tty) isicom_flush_chars() argument
1005 struct isi_port *port = tty->driver_data; isicom_flush_chars()
1007 if (isicom_paranoia_check(port, tty->name, "isicom_flush_chars")) isicom_flush_chars()
1010 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || isicom_flush_chars()
1020 static int isicom_write_room(struct tty_struct *tty) isicom_write_room() argument
1022 struct isi_port *port = tty->driver_data; isicom_write_room()
1025 if (isicom_paranoia_check(port, tty->name, "isicom_write_room")) isicom_write_room()
1035 static int isicom_chars_in_buffer(struct tty_struct *tty) isicom_chars_in_buffer() argument
1037 struct isi_port *port = tty->driver_data; isicom_chars_in_buffer()
1038 if (isicom_paranoia_check(port, tty->name, "isicom_chars_in_buffer")) isicom_chars_in_buffer()
1044 static int isicom_send_break(struct tty_struct *tty, int length) isicom_send_break() argument
1046 struct isi_port *port = tty->driver_data; isicom_send_break()
1065 static int isicom_tiocmget(struct tty_struct *tty) isicom_tiocmget() argument
1067 struct isi_port *port = tty->driver_data; isicom_tiocmget()
1071 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) isicom_tiocmget()
1082 static int isicom_tiocmset(struct tty_struct *tty, isicom_tiocmset() argument
1085 struct isi_port *port = tty->driver_data; isicom_tiocmset()
1088 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) isicom_tiocmset()
1106 static int isicom_set_serial_info(struct tty_struct *tty, isicom_set_serial_info() argument
1109 struct isi_port *port = tty->driver_data; isicom_set_serial_info()
1139 isicom_config_port(tty); isicom_set_serial_info()
1167 static int isicom_ioctl(struct tty_struct *tty, isicom_ioctl() argument
1170 struct isi_port *port = tty->driver_data; isicom_ioctl()
1173 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) isicom_ioctl()
1181 return isicom_set_serial_info(tty, argp); isicom_ioctl()
1190 static void isicom_set_termios(struct tty_struct *tty, isicom_set_termios() argument
1193 struct isi_port *port = tty->driver_data; isicom_set_termios()
1196 if (isicom_paranoia_check(port, tty->name, "isicom_set_termios")) isicom_set_termios()
1199 if (tty->termios.c_cflag == old_termios->c_cflag && isicom_set_termios()
1200 tty->termios.c_iflag == old_termios->c_iflag) isicom_set_termios()
1204 isicom_config_port(tty); isicom_set_termios()
1208 !(tty->termios.c_cflag & CRTSCTS)) { isicom_set_termios()
1209 tty->hw_stopped = 0; isicom_set_termios()
1210 isicom_start(tty); isicom_set_termios()
1215 static void isicom_throttle(struct tty_struct *tty) isicom_throttle() argument
1217 struct isi_port *port = tty->driver_data; isicom_throttle()
1220 if (isicom_paranoia_check(port, tty->name, "isicom_throttle")) isicom_throttle()
1229 static void isicom_unthrottle(struct tty_struct *tty) isicom_unthrottle() argument
1231 struct isi_port *port = tty->driver_data; isicom_unthrottle()
1234 if (isicom_paranoia_check(port, tty->name, "isicom_unthrottle")) isicom_unthrottle()
1243 static void isicom_stop(struct tty_struct *tty) isicom_stop() argument
1245 struct isi_port *port = tty->driver_data; isicom_stop()
1247 if (isicom_paranoia_check(port, tty->name, "isicom_stop")) isicom_stop()
1256 static void isicom_start(struct tty_struct *tty) isicom_start() argument
1258 struct isi_port *port = tty->driver_data; isicom_start()
1260 if (isicom_paranoia_check(port, tty->name, "isicom_start")) isicom_start()
1268 static void isicom_hangup(struct tty_struct *tty) isicom_hangup() argument
1270 struct isi_port *port = tty->driver_data; isicom_hangup()
1272 if (isicom_paranoia_check(port, tty->name, "isicom_hangup")) isicom_hangup()
1675 /* tty driver structure initialization */ isicom_init()
H A Dmxser.c28 #include <linux/tty.h>
571 static int mxser_set_baud(struct tty_struct *tty, long newspd) mxser_set_baud() argument
573 struct mxser_port *info = tty->driver_data; mxser_set_baud()
585 tty_encode_baud_rate(tty, 134, 134); mxser_set_baud()
591 tty_encode_baud_rate(tty, baud, baud); mxser_set_baud()
617 if (C_BAUD(tty) == BOTHER) { mxser_set_baud()
638 static int mxser_change_speed(struct tty_struct *tty, mxser_change_speed() argument
641 struct mxser_port *info = tty->driver_data; mxser_change_speed()
646 cflag = tty->termios.c_cflag; mxser_change_speed()
650 if (mxser_set_baud_method[tty->index] == 0) mxser_change_speed()
651 mxser_set_baud(tty, tty_get_baud_rate(tty)); mxser_change_speed()
720 if (tty->hw_stopped) { mxser_change_speed()
722 tty->hw_stopped = 0; mxser_change_speed()
732 tty_wakeup(tty); mxser_change_speed()
736 tty->hw_stopped = 1; mxser_change_speed()
762 if (I_INPCK(tty)) mxser_change_speed()
764 if (I_BRKINT(tty) || I_PARMRK(tty)) mxser_change_speed()
769 if (I_IGNBRK(tty)) { mxser_change_speed()
776 if (I_IGNPAR(tty)) { mxser_change_speed()
788 mxser_set_must_xon1_value(info->ioaddr, START_CHAR(tty)); mxser_change_speed()
789 mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(tty)); mxser_change_speed()
790 if (I_IXON(tty)) { mxser_change_speed()
797 if (I_IXOFF(tty)) { mxser_change_speed()
813 static void mxser_check_modem_status(struct tty_struct *tty, mxser_check_modem_status() argument
834 if (tty->hw_stopped) { mxser_check_modem_status()
836 tty->hw_stopped = 0; mxser_check_modem_status()
846 tty_wakeup(tty); mxser_check_modem_status()
850 tty->hw_stopped = 1; mxser_check_modem_status()
862 static int mxser_activate(struct tty_port *port, struct tty_struct *tty) mxser_activate() argument
875 set_bit(TTY_IO_ERROR, &tty->flags); mxser_activate()
902 set_bit(TTY_IO_ERROR, &tty->flags); mxser_activate()
940 clear_bit(TTY_IO_ERROR, &tty->flags); mxser_activate()
946 mxser_change_speed(tty, NULL); mxser_activate()
1002 * initialization for the tty structure.
1004 static int mxser_open(struct tty_struct *tty, struct file *filp) mxser_open() argument
1009 line = tty->index; mxser_open()
1016 tty->driver_data = info; mxser_open()
1017 return tty_port_open(&info->port, tty, filp); mxser_open()
1020 static void mxser_flush_buffer(struct tty_struct *tty) mxser_flush_buffer() argument
1022 struct mxser_port *info = tty->driver_data; mxser_flush_buffer()
1037 tty_wakeup(tty); mxser_flush_buffer()
1075 static void mxser_close(struct tty_struct *tty, struct file *filp) mxser_close() argument
1077 struct mxser_port *info = tty->driver_data; mxser_close()
1080 if (tty->index == MXSER_PORTS || info == NULL) mxser_close()
1082 if (tty_port_close_start(port, tty, filp) == 0) mxser_close()
1086 mxser_flush_buffer(tty); mxser_close()
1088 if (C_HUPCL(tty)) mxser_close()
1096 tty_port_close_end(port, tty); mxser_close()
1100 static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) mxser_write() argument
1103 struct mxser_port *info = tty->driver_data; mxser_write()
1127 if (info->xmit_cnt && !tty->stopped) { mxser_write()
1128 if (!tty->hw_stopped || mxser_write()
1142 static int mxser_put_char(struct tty_struct *tty, unsigned char ch) mxser_put_char() argument
1144 struct mxser_port *info = tty->driver_data; mxser_put_char()
1158 if (!tty->stopped) { mxser_put_char()
1159 if (!tty->hw_stopped || mxser_put_char()
1173 static void mxser_flush_chars(struct tty_struct *tty) mxser_flush_chars() argument
1175 struct mxser_port *info = tty->driver_data; mxser_flush_chars()
1178 if (info->xmit_cnt <= 0 || tty->stopped || !info->port.xmit_buf || mxser_flush_chars()
1179 (tty->hw_stopped && info->type != PORT_16550A && mxser_flush_chars()
1192 static int mxser_write_room(struct tty_struct *tty) mxser_write_room() argument
1194 struct mxser_port *info = tty->driver_data; mxser_write_room()
1201 static int mxser_chars_in_buffer(struct tty_struct *tty) mxser_chars_in_buffer() argument
1203 struct mxser_port *info = tty->driver_data; mxser_chars_in_buffer()
1212 static int mxser_get_serial_info(struct tty_struct *tty, mxser_get_serial_info() argument
1215 struct mxser_port *info = tty->driver_data; mxser_get_serial_info()
1218 .line = tty->index, mxser_get_serial_info()
1233 static int mxser_set_serial_info(struct tty_struct *tty, mxser_set_serial_info() argument
1236 struct mxser_port *info = tty->driver_data; mxser_set_serial_info()
1279 tty_encode_baud_rate(tty, baud, baud); mxser_set_serial_info()
1290 mxser_change_speed(tty, NULL); mxser_set_serial_info()
1294 retval = mxser_activate(port, tty); mxser_set_serial_info()
1325 static int mxser_tiocmget(struct tty_struct *tty) mxser_tiocmget() argument
1327 struct mxser_port *info = tty->driver_data; mxser_tiocmget()
1332 if (tty->index == MXSER_PORTS) mxser_tiocmget()
1334 if (test_bit(TTY_IO_ERROR, &tty->flags)) mxser_tiocmget()
1342 mxser_check_modem_status(tty, info, status); mxser_tiocmget()
1352 static int mxser_tiocmset(struct tty_struct *tty, mxser_tiocmset() argument
1355 struct mxser_port *info = tty->driver_data; mxser_tiocmset()
1359 if (tty->index == MXSER_PORTS) mxser_tiocmset()
1361 if (test_bit(TTY_IO_ERROR, &tty->flags)) mxser_tiocmset()
1488 struct tty_struct *tty; mxser_ioctl_special() local
1525 tty = tty_port_tty_get(port); mxser_ioctl_special()
1527 if (!tty) mxser_ioctl_special()
1530 ms.cflag = tty->termios.c_cflag; mxser_ioctl_special()
1531 tty_kref_put(tty); mxser_ioctl_special()
1594 tty = tty_port_tty_get(&ip->port); mxser_ioctl_special()
1596 if (!tty) { mxser_ioctl_special()
1601 cflag = tty->termios.c_cflag; mxser_ioctl_special()
1602 iflag = tty->termios.c_iflag; mxser_ioctl_special()
1603 me->baudrate[p] = tty_get_baud_rate(tty); mxser_ioctl_special()
1605 tty_kref_put(tty); mxser_ioctl_special()
1663 static int mxser_ioctl(struct tty_struct *tty, mxser_ioctl() argument
1666 struct mxser_port *info = tty->driver_data; mxser_ioctl()
1673 if (tty->index == MXSER_PORTS) mxser_ioctl()
1686 p = tty->index % 4; mxser_ioctl()
1716 test_bit(TTY_IO_ERROR, &tty->flags)) mxser_ioctl()
1722 retval = mxser_get_serial_info(tty, argp); mxser_ioctl()
1727 retval = mxser_set_serial_info(tty, argp); mxser_ioctl()
1757 len = mxser_chars_in_buffer(tty); mxser_ioctl()
1769 status = mxser_get_msr(info->ioaddr, 1, tty->index); mxser_ioctl()
1770 mxser_check_modem_status(tty, info, status); mxser_ioctl()
1785 if (tty->hw_stopped) mxser_ioctl()
1808 mxser_set_baud_method[tty->index] = method; mxser_ioctl()
1824 static int mxser_get_icount(struct tty_struct *tty, mxser_get_icount() argument
1828 struct mxser_port *info = tty->driver_data; mxser_get_icount()
1850 static void mxser_stoprx(struct tty_struct *tty) mxser_stoprx() argument
1852 struct mxser_port *info = tty->driver_data; mxser_stoprx()
1855 if (I_IXOFF(tty)) { mxser_stoprx()
1860 info->x_char = STOP_CHAR(tty); mxser_stoprx()
1867 if (tty->termios.c_cflag & CRTSCTS) { mxser_stoprx()
1874 * This routine is called by the upper-layer tty layer to signal that
1877 static void mxser_throttle(struct tty_struct *tty) mxser_throttle() argument
1879 mxser_stoprx(tty); mxser_throttle()
1882 static void mxser_unthrottle(struct tty_struct *tty) mxser_unthrottle() argument
1884 struct mxser_port *info = tty->driver_data; mxser_unthrottle()
1888 if (I_IXOFF(tty)) { mxser_unthrottle()
1896 info->x_char = START_CHAR(tty); mxser_unthrottle()
1904 if (tty->termios.c_cflag & CRTSCTS) { mxser_unthrottle()
1913 * This routines are called before setting or resetting tty->stopped.
1916 static void mxser_stop(struct tty_struct *tty) mxser_stop() argument
1918 struct mxser_port *info = tty->driver_data; mxser_stop()
1929 static void mxser_start(struct tty_struct *tty) mxser_start() argument
1931 struct mxser_port *info = tty->driver_data; mxser_start()
1943 static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termios) mxser_set_termios() argument
1945 struct mxser_port *info = tty->driver_data; mxser_set_termios()
1949 mxser_change_speed(tty, old_termios); mxser_set_termios()
1953 !(tty->termios.c_cflag & CRTSCTS)) { mxser_set_termios()
1954 tty->hw_stopped = 0; mxser_set_termios()
1955 mxser_start(tty); mxser_set_termios()
1960 !(tty->termios.c_iflag & IXON)) { mxser_set_termios()
1961 tty->stopped = 0; mxser_set_termios()
1970 mxser_start(tty); mxser_set_termios()
1977 static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) mxser_wait_until_sent() argument
1979 struct mxser_port *info = tty->driver_data; mxser_wait_until_sent()
2034 static void mxser_hangup(struct tty_struct *tty) mxser_hangup() argument
2036 struct mxser_port *info = tty->driver_data; mxser_hangup()
2038 mxser_flush_buffer(tty); mxser_hangup()
2045 static int mxser_rs_break(struct tty_struct *tty, int break_state) mxser_rs_break() argument
2047 struct mxser_port *info = tty->driver_data; mxser_rs_break()
2061 static void mxser_receive_chars(struct tty_struct *tty, mxser_receive_chars() argument
2070 recv_room = tty->receive_room; mxser_receive_chars()
2072 mxser_stoprx(tty); mxser_receive_chars()
2089 mxser_stoprx(tty); mxser_receive_chars()
2119 do_SAK(tty); mxser_receive_chars()
2136 mxser_stoprx(tty); mxser_receive_chars()
2149 mxvar_log.rxcnt[tty->index] += cnt; mxser_receive_chars()
2163 static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port) mxser_transmit_chars() argument
2170 mxvar_log.txcnt[tty->index]++; mxser_transmit_chars()
2180 if (port->xmit_cnt <= 0 || tty->stopped || mxser_transmit_chars()
2181 (tty->hw_stopped && mxser_transmit_chars()
2198 mxvar_log.txcnt[tty->index] += (cnt - port->xmit_cnt); mxser_transmit_chars()
2205 tty_wakeup(tty); mxser_transmit_chars()
2224 struct tty_struct *tty; mxser_interrupt() local
2257 tty = tty_port_tty_get(&port->port); mxser_interrupt()
2258 if (!tty || mxser_interrupt()
2265 tty_kref_put(tty); mxser_interrupt()
2286 mxser_receive_chars(tty, port, mxser_interrupt()
2292 mxser_receive_chars(tty, port, mxser_interrupt()
2297 mxser_check_modem_status(tty, port, msr); mxser_interrupt()
2302 mxser_transmit_chars(tty, port); mxser_interrupt()
2305 mxser_transmit_chars(tty, port); mxser_interrupt()
2307 tty_kref_put(tty); mxser_interrupt()
2734 "tty driver !\n"); mxser_module_init()
H A Dn_gsm.c2 * n_gsm.c GSM 0710 tty multiplexor
22 * Partly done: hooks so you can pull off frames to non tty devs
30 * Use newest tty open/close port helpers and install hooks
33 * Do we need a 'which mux are you' ioctl to correlate mux and tty sets
44 #include <linux/tty.h>
121 * the link layer to an optional tty (if the tty side is open). To avoid
143 /* Uplink tty if active */
144 struct tty_port port; /* The tty bound to this DLCI if there is one */
191 * To consider further: tty open versus mux shutdown.
195 struct tty_struct *tty; /* The tty our ldisc is bound to */ member in struct:gsm_mux
272 * Mux objects - needed so that we can translate a tty index into the
428 * the current status of the DLCI and attached tty object
673 * The tty device has called us to indicate that room has appeared in
728 * out of the mux tty if not already doing so. The Caller must hold
779 * out of the mux tty if not already doing so. Take the
797 * is data. Keep to the MRU of the mux. This path handles the usual tty
963 * a tty wakeup except when we filled the pipe so we need to fire off
1019 * @tty: virtual tty bound to the DLCI
1027 static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci, gsm_process_modem() argument
1067 if (tty) { gsm_process_modem()
1069 if (!(tty->termios.c_cflag & CLOCAL)) gsm_process_modem()
1070 tty_hangup(tty); gsm_process_modem()
1086 * and if need be stuff a break message down the tty.
1097 struct tty_struct *tty; gsm_control_modem() local
1130 tty = tty_port_tty_get(&dlci->port); gsm_control_modem()
1131 gsm_process_modem(tty, dlci, modem, clen); gsm_control_modem()
1132 if (tty) { gsm_control_modem()
1133 tty_wakeup(tty); gsm_control_modem()
1134 tty_kref_put(tty); gsm_control_modem()
1147 * this into the uplink tty if present
1423 * is an attached tty this is hung up
1454 /* This will let a tty open continue */ gsm_dlci_open()
1547 * other than the control channel. If the relevant virtual tty is
1555 struct tty_struct *tty; gsm_dlci_data() local
1560 pr_debug("%d bytes for tty\n", len); gsm_dlci_data()
1576 tty = tty_port_tty_get(port); gsm_dlci_data()
1577 if (tty) { gsm_dlci_data()
1578 gsm_process_modem(tty, dlci, modem, clen); gsm_dlci_data()
1579 tty_kref_put(tty); gsm_dlci_data()
1707 * mux is closed or tty is closed - whichever is last.
1713 struct tty_struct *tty = tty_port_tty_get(&dlci->port); gsm_dlci_release() local
1714 if (tty) { gsm_dlci_release()
1719 tty_vhangup(tty); gsm_dlci_release()
1722 tty_kref_put(tty); gsm_dlci_release()
2004 * gsm_error - handle tty error
2193 gsm->dead = 1; /* Avoid early tty opens */ gsm_alloc_mux()
2210 if (tty_write_room(gsm->tty) < len) { gsmld_output()
2211 set_bit(TTY_DO_WRITE_WAKEUP, &gsm->tty->flags); gsmld_output()
2217 gsm->tty->ops->write(gsm->tty, data, len); gsmld_output()
2223 * @tty: our tty structure
2231 static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) gsmld_attach_gsm() argument
2235 gsm->tty = tty_kref_get(tty); gsmld_attach_gsm()
2239 tty_kref_put(gsm->tty); gsmld_attach_gsm()
2242 a usable tty interface */ gsmld_attach_gsm()
2253 * @tty: tty attached to the mux
2259 static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) gsmld_detach_gsm() argument
2264 WARN_ON(tty != gsm->tty); gsmld_detach_gsm()
2268 tty_kref_put(gsm->tty); gsmld_detach_gsm()
2269 gsm->tty = NULL; gsmld_detach_gsm()
2272 static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp, gsmld_receive_buf() argument
2275 struct gsm_mux *gsm = tty->disc_data; gsmld_receive_buf()
2301 tty_name(tty, buf), flags); gsmld_receive_buf()
2306 /* If clogged call tty_throttle(tty); */ gsmld_receive_buf()
2311 * @tty: tty device
2319 static ssize_t gsmld_chars_in_buffer(struct tty_struct *tty) gsmld_chars_in_buffer() argument
2326 * @tty: terminal device
2329 * being closed, when the tty layer wants the buffer flushed (eg
2333 static void gsmld_flush_buffer(struct tty_struct *tty) gsmld_flush_buffer() argument
2338 * gsmld_close - close the ldisc for this tty
2339 * @tty: device
2347 static void gsmld_close(struct tty_struct *tty) gsmld_close() argument
2349 struct gsm_mux *gsm = tty->disc_data; gsmld_close()
2351 gsmld_detach_gsm(tty, gsm); gsmld_close()
2353 gsmld_flush_buffer(tty); gsmld_close()
2360 * @tty: terminal to open
2368 static int gsmld_open(struct tty_struct *tty) gsmld_open() argument
2373 if (tty->ops->write == NULL) gsmld_open()
2381 tty->disc_data = gsm; gsmld_open()
2382 tty->receive_room = 65536; gsmld_open()
2387 ret = gsmld_attach_gsm(tty, gsm); gsmld_open()
2397 * @tty: tty device
2404 static void gsmld_write_wakeup(struct tty_struct *tty) gsmld_write_wakeup() argument
2406 struct gsm_mux *gsm = tty->disc_data; gsmld_write_wakeup()
2410 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); gsmld_write_wakeup()
2420 * gsmld_read - read function for tty
2421 * @tty: tty device
2434 static ssize_t gsmld_read(struct tty_struct *tty, struct file *file, gsmld_read() argument
2441 * gsmld_write - write function for tty
2442 * @tty: tty device
2454 static ssize_t gsmld_write(struct tty_struct *tty, struct file *file, gsmld_write() argument
2457 int space = tty_write_room(tty); gsmld_write()
2459 return tty->ops->write(tty, buf, nr); gsmld_write()
2460 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); gsmld_write()
2466 * @tty: terminal device
2478 static unsigned int gsmld_poll(struct tty_struct *tty, struct file *file, gsmld_poll() argument
2482 struct gsm_mux *gsm = tty->disc_data; gsmld_poll()
2484 poll_wait(file, &tty->read_wait, wait); gsmld_poll()
2485 poll_wait(file, &tty->write_wait, wait); gsmld_poll()
2488 if (!tty_is_writelocked(tty) && tty_write_room(tty) > 0) gsmld_poll()
2495 static int gsmld_config(struct tty_struct *tty, struct gsm_mux *gsm, gsmld_config() argument
2578 static int gsmld_ioctl(struct tty_struct *tty, struct file *file, gsmld_ioctl() argument
2582 struct gsm_mux *gsm = tty->disc_data; gsmld_ioctl()
2608 return gsmld_config(tty, gsm, &c); gsmld_ioctl()
2610 return n_tty_ioctl_helper(tty, file, cmd, arg); gsmld_ioctl()
2784 /* Already in a non tty mode */ gsm_create_network()
2828 /* Line discipline for real tty */
2846 * Virtual tty side
2902 static int gsmtty_install(struct tty_driver *driver, struct tty_struct *tty) gsmtty_install() argument
2906 unsigned int line = tty->index; gsmtty_install()
2941 ret = tty_port_install(&dlci->port, driver, tty); gsmtty_install()
2952 tty->driver_data = dlci; gsmtty_install()
2958 static int gsmtty_open(struct tty_struct *tty, struct file *filp) gsmtty_open() argument
2960 struct gsm_dlci *dlci = tty->driver_data; gsmtty_open()
2964 tty_port_tty_set(port, tty); gsmtty_open()
2973 return tty_port_block_til_ready(port, tty, filp); gsmtty_open()
2976 static void gsmtty_close(struct tty_struct *tty, struct file *filp) gsmtty_close() argument
2978 struct gsm_dlci *dlci = tty->driver_data; gsmtty_close()
2989 if (tty_port_close_start(&dlci->port, tty, filp) == 0) gsmtty_close()
2993 if (C_HUPCL(tty)) gsmtty_close()
2996 tty_port_close_end(&dlci->port, tty); gsmtty_close()
3001 static void gsmtty_hangup(struct tty_struct *tty) gsmtty_hangup() argument
3003 struct gsm_dlci *dlci = tty->driver_data; gsmtty_hangup()
3010 static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf, gsmtty_write() argument
3014 struct gsm_dlci *dlci = tty->driver_data; gsmtty_write()
3024 static int gsmtty_write_room(struct tty_struct *tty) gsmtty_write_room() argument
3026 struct gsm_dlci *dlci = tty->driver_data; gsmtty_write_room()
3032 static int gsmtty_chars_in_buffer(struct tty_struct *tty) gsmtty_chars_in_buffer() argument
3034 struct gsm_dlci *dlci = tty->driver_data; gsmtty_chars_in_buffer()
3040 static void gsmtty_flush_buffer(struct tty_struct *tty) gsmtty_flush_buffer() argument
3042 struct gsm_dlci *dlci = tty->driver_data; gsmtty_flush_buffer()
3053 static void gsmtty_wait_until_sent(struct tty_struct *tty, int timeout) gsmtty_wait_until_sent() argument
3060 static int gsmtty_tiocmget(struct tty_struct *tty) gsmtty_tiocmget() argument
3062 struct gsm_dlci *dlci = tty->driver_data; gsmtty_tiocmget()
3068 static int gsmtty_tiocmset(struct tty_struct *tty, gsmtty_tiocmset() argument
3071 struct gsm_dlci *dlci = tty->driver_data; gsmtty_tiocmset()
3087 static int gsmtty_ioctl(struct tty_struct *tty, gsmtty_ioctl() argument
3090 struct gsm_dlci *dlci = tty->driver_data; gsmtty_ioctl()
3120 static void gsmtty_set_termios(struct tty_struct *tty, struct ktermios *old) gsmtty_set_termios() argument
3122 struct gsm_dlci *dlci = tty->driver_data; gsmtty_set_termios()
3130 tty_termios_copy_hw(&tty->termios, old); gsmtty_set_termios()
3133 static void gsmtty_throttle(struct tty_struct *tty) gsmtty_throttle() argument
3135 struct gsm_dlci *dlci = tty->driver_data; gsmtty_throttle()
3138 if (tty->termios.c_cflag & CRTSCTS) gsmtty_throttle()
3145 static void gsmtty_unthrottle(struct tty_struct *tty) gsmtty_unthrottle() argument
3147 struct gsm_dlci *dlci = tty->driver_data; gsmtty_unthrottle()
3150 if (tty->termios.c_cflag & CRTSCTS) gsmtty_unthrottle()
3157 static int gsmtty_break_ctl(struct tty_struct *tty, int state) gsmtty_break_ctl() argument
3159 struct gsm_dlci *dlci = tty->driver_data; gsmtty_break_ctl()
3175 static void gsmtty_cleanup(struct tty_struct *tty) gsmtty_cleanup() argument
3177 struct gsm_dlci *dlci = tty->driver_data; gsmtty_cleanup()
3221 pr_err("gsm_init: tty allocation failed.\n"); gsm_init()
3242 pr_err("gsm_init: tty registration failed.\n"); gsm_init()
H A Dbfin_jtag_comm.c25 #include <linux/tty.h>
74 struct tty_struct *tty = tty_port_tty_get(&port); bfin_jc_emudat_manager() local
76 if (tty == NULL && circ_empty(&bfin_jc_write_buf)) { bfin_jc_emudat_manager()
87 tty_kref_put(tty); bfin_jc_emudat_manager()
128 if (tty) bfin_jc_emudat_manager()
129 tty_wakeup(tty); bfin_jc_emudat_manager()
133 tty_kref_put(tty); bfin_jc_emudat_manager()
141 bfin_jc_open(struct tty_struct *tty, struct file *filp) bfin_jc_open() argument
148 tty_port_tty_set(&port, tty); bfin_jc_open()
154 bfin_jc_close(struct tty_struct *tty, struct file *filp) bfin_jc_close() argument
185 bfin_jc_write(struct tty_struct *tty, const unsigned char *buf, int count) bfin_jc_write() argument
196 bfin_jc_flush_chars(struct tty_struct *tty) bfin_jc_flush_chars() argument
202 bfin_jc_write_room(struct tty_struct *tty) bfin_jc_write_room() argument
208 bfin_jc_chars_in_buffer(struct tty_struct *tty) bfin_jc_chars_in_buffer() argument
H A Dn_r3964.c29 * Updated to newly registered tty-ldisc number 9
60 #include <linux/tty.h>
62 #include <linux/string.h> /* used in new tty drivers */
63 #include <linux/signal.h> /* used in new tty drivers */
131 static int r3964_open(struct tty_struct *tty);
132 static void r3964_close(struct tty_struct *tty);
133 static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
135 static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
137 static int r3964_ioctl(struct tty_struct *tty, struct file *file,
139 static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
140 static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
142 static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
204 * Register the tty line discipline r3964_init()
373 struct tty_struct *tty = pInfo->tty; put_char() local
375 tty_put_char(tty, ch); put_char()
381 struct tty_struct *tty = pInfo->tty; flush() local
383 if (tty == NULL || tty->ops->flush_chars == NULL) flush()
385 tty->ops->flush_chars(tty); flush()
439 struct tty_struct *tty = pInfo->tty; transmit_block() local
443 if (tty == NULL || pBlock == NULL) { transmit_block()
447 room = tty_write_room(tty); transmit_block()
942 static int r3964_open(struct tty_struct *tty) r3964_open() argument
947 TRACE_L("tty=%p, PID=%d, disc_data=%p", r3964_open()
948 tty, current->pid, tty->disc_data); r3964_open()
981 pInfo->tty = tty; r3964_open()
995 tty->disc_data = pInfo; r3964_open()
996 tty->receive_room = 65536; r3964_open()
1003 static void r3964_close(struct tty_struct *tty) r3964_close() argument
1005 struct r3964_info *pInfo = tty->disc_data; r3964_close()
1057 static ssize_t r3964_read(struct tty_struct *tty, struct file *file, r3964_read() argument
1060 struct r3964_info *pInfo = tty->disc_data; r3964_read()
1068 tty_lock(tty); r3964_read()
1080 wait_event_interruptible_tty(tty, pInfo->read_wait, r3964_read()
1110 tty_unlock(tty); r3964_read()
1114 static ssize_t r3964_write(struct tty_struct *tty, struct file *file, r3964_write() argument
1117 struct r3964_info *pInfo = tty->disc_data; r3964_write()
1159 tty_lock(tty); r3964_write()
1178 tty_unlock(tty); r3964_write()
1183 static int r3964_ioctl(struct tty_struct *tty, struct file *file, r3964_ioctl() argument
1186 struct r3964_info *pInfo = tty->disc_data; r3964_ioctl()
1211 static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old) r3964_set_termios() argument
1217 static unsigned int r3964_poll(struct tty_struct *tty, struct file *file, r3964_poll() argument
1220 struct r3964_info *pInfo = tty->disc_data; r3964_poll()
1242 static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, r3964_receive_buf() argument
1245 struct r3964_info *pInfo = tty->disc_data; r3964_receive_buf()
H A Drocket.c72 #include <linux/tty.h>
230 static void rp_wait_until_sent(struct tty_struct *tty, int timeout);
231 static void rp_flush_buffer(struct tty_struct *tty);
234 static void rp_start(struct tty_struct *tty);
312 * tty layer.
413 /* Push the data up to the tty layer */ rp_do_receive()
419 * result of a bit set in xmit_flags[], indicating data (from the tty layer) is ready
427 struct tty_struct *tty; rp_do_transmit() local
435 tty = tty_port_tty_get(&info->port); rp_do_transmit()
437 if (tty == NULL) { rp_do_transmit()
438 printk(KERN_WARNING "rp: WARNING %s called with tty==NULL\n", __func__); rp_do_transmit()
448 if (tty->stopped) rp_do_transmit()
470 tty_wakeup(tty); rp_do_transmit()
472 wake_up_interruptible(&tty->poll_wait); rp_do_transmit()
477 tty_kref_put(tty); rp_do_transmit()
705 static void configure_r_port(struct tty_struct *tty, struct r_port *info, configure_r_port() argument
713 struct ktermios *t = &tty->termios; configure_r_port()
746 baud = tty_get_baud_rate(tty); configure_r_port()
764 tty_encode_baud_rate(tty, baud, baud); configure_r_port()
789 if (I_IXON(tty)) { configure_r_port()
791 if (I_IXANY(tty)) { configure_r_port()
796 sSetTxXONChar(cp, START_CHAR(tty)); configure_r_port()
797 sSetTxXOFFChar(cp, STOP_CHAR(tty)); configure_r_port()
809 if (I_INPCK(tty)) configure_r_port()
811 if (I_BRKINT(tty) || I_PARMRK(tty)) configure_r_port()
818 if (I_IGNPAR(tty)) configure_r_port()
820 if (I_IGNBRK(tty)) { configure_r_port()
826 if (I_IGNPAR(tty)) configure_r_port()
881 static int rp_open(struct tty_struct *tty, struct file *filp) rp_open() argument
889 info = rp_table[tty->index]; rp_open()
914 tty->driver_data = info; rp_open()
915 tty_port_tty_set(port, tty); rp_open()
959 * Set up the tty->alt_speed kludge rp_open()
962 tty->alt_speed = 57600; rp_open()
964 tty->alt_speed = 115200; rp_open()
966 tty->alt_speed = 230400; rp_open()
968 tty->alt_speed = 460800; rp_open()
970 configure_r_port(tty, info, NULL); rp_open()
971 if (tty->termios.c_cflag & CBAUD) { rp_open()
979 retval = tty_port_block_til_ready(port, tty, filp); rp_open()
992 static void rp_close(struct tty_struct *tty, struct file *filp) rp_close() argument
994 struct r_port *info = tty->driver_data; rp_close()
1006 if (tty_port_close_start(port, tty, filp) == 0) rp_close()
1019 rp_wait_until_sent(tty, timeout); rp_close()
1030 if (C_HUPCL(tty)) rp_close()
1033 rp_flush_buffer(tty); rp_close()
1035 tty_ldisc_flush(tty); rp_close()
1055 tty->closing = 0; rp_close()
1072 static void rp_set_termios(struct tty_struct *tty, rp_set_termios() argument
1075 struct r_port *info = tty->driver_data; rp_set_termios()
1082 cflag = tty->termios.c_cflag; rp_set_termios()
1088 tty->termios.c_cflag = rp_set_termios()
1091 tty->termios.c_cflag &= ~CMSPAR; rp_set_termios()
1093 configure_r_port(tty, info, old_termios); rp_set_termios()
1098 if ((old_termios->c_cflag & CBAUD) && !(tty->termios.c_cflag & CBAUD)) { rp_set_termios()
1104 if (!(old_termios->c_cflag & CBAUD) && (tty->termios.c_cflag & CBAUD)) { rp_set_termios()
1109 if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios.c_cflag & CRTSCTS)) rp_set_termios()
1110 rp_start(tty); rp_set_termios()
1113 static int rp_break(struct tty_struct *tty, int break_state) rp_break() argument
1115 struct r_port *info = tty->driver_data; rp_break()
1159 static int rp_tiocmget(struct tty_struct *tty) rp_tiocmget() argument
1161 struct r_port *info = tty->driver_data; rp_tiocmget()
1179 static int rp_tiocmset(struct tty_struct *tty, rp_tiocmset() argument
1182 struct r_port *info = tty->driver_data; rp_tiocmset()
1217 static int set_config(struct tty_struct *tty, struct r_port *info, set_config() argument
1233 configure_r_port(tty, info, NULL); set_config()
1243 tty->alt_speed = 57600; set_config()
1245 tty->alt_speed = 115200; set_config()
1247 tty->alt_speed = 230400; set_config()
1249 tty->alt_speed = 460800; set_config()
1252 configure_r_port(tty, info, NULL); set_config()
1316 static int rp_ioctl(struct tty_struct *tty, rp_ioctl() argument
1319 struct r_port *info = tty->driver_data; rp_ioctl()
1335 ret = set_config(tty, info, argp); rp_ioctl()
1352 static void rp_send_xchar(struct tty_struct *tty, char ch) rp_send_xchar() argument
1354 struct r_port *info = tty->driver_data; rp_send_xchar()
1367 static void rp_throttle(struct tty_struct *tty) rp_throttle() argument
1369 struct r_port *info = tty->driver_data; rp_throttle()
1372 printk(KERN_INFO "throttle %s: %d....\n", tty->name, rp_throttle()
1373 tty->ldisc.chars_in_buffer(tty)); rp_throttle()
1379 if (I_IXOFF(tty)) rp_throttle()
1380 rp_send_xchar(tty, STOP_CHAR(tty)); rp_throttle()
1385 static void rp_unthrottle(struct tty_struct *tty) rp_unthrottle() argument
1387 struct r_port *info = tty->driver_data; rp_unthrottle()
1389 printk(KERN_INFO "unthrottle %s: %d....\n", tty->name, rp_unthrottle()
1390 tty->ldisc.chars_in_buffer(tty)); rp_unthrottle()
1396 if (I_IXOFF(tty)) rp_unthrottle()
1397 rp_send_xchar(tty, START_CHAR(tty)); rp_unthrottle()
1406 * This routines are called before setting or resetting tty->stopped.
1410 static void rp_stop(struct tty_struct *tty) rp_stop() argument
1412 struct r_port *info = tty->driver_data; rp_stop()
1415 printk(KERN_INFO "stop %s: %d %d....\n", tty->name, rp_stop()
1426 static void rp_start(struct tty_struct *tty) rp_start() argument
1428 struct r_port *info = tty->driver_data; rp_start()
1431 printk(KERN_INFO "start %s: %d %d....\n", tty->name, rp_start()
1446 static void rp_wait_until_sent(struct tty_struct *tty, int timeout) rp_wait_until_sent() argument
1448 struct r_port *info = tty->driver_data; rp_wait_until_sent()
1500 static void rp_hangup(struct tty_struct *tty) rp_hangup() argument
1503 struct r_port *info = tty->driver_data; rp_hangup()
1512 rp_flush_buffer(tty); rp_hangup()
1544 static int rp_put_char(struct tty_struct *tty, unsigned char ch) rp_put_char() argument
1546 struct r_port *info = tty->driver_data; rp_put_char()
1566 if (!tty->stopped && info->xmit_fifo_room == 0) rp_put_char()
1569 if (tty->stopped || info->xmit_fifo_room == 0 || info->xmit_cnt != 0) { rp_put_char()
1590 static int rp_write(struct tty_struct *tty, rp_write() argument
1593 struct r_port *info = tty->driver_data; rp_write()
1610 if (!tty->stopped && info->xmit_fifo_room < count) rp_write()
1617 if (!tty->stopped && info->xmit_cnt == 0 && info->xmit_fifo_room > 0) { rp_write()
1665 if ((retval > 0) && !tty->stopped) rp_write()
1670 tty_wakeup(tty); rp_write()
1672 wake_up_interruptible(&tty->poll_wait); rp_write()
1684 static int rp_write_room(struct tty_struct *tty) rp_write_room() argument
1686 struct r_port *info = tty->driver_data; rp_write_room()
1705 static int rp_chars_in_buffer(struct tty_struct *tty) rp_chars_in_buffer() argument
1707 struct r_port *info = tty->driver_data; rp_chars_in_buffer()
1723 static void rp_flush_buffer(struct tty_struct *tty) rp_flush_buffer() argument
1725 struct r_port *info = tty->driver_data; rp_flush_buffer()
1737 wake_up_interruptible(&tty->poll_wait); rp_flush_buffer()
1739 tty_wakeup(tty); rp_flush_buffer()
2424 * Set up the tty driver structure and then register this rp_init()
2425 * driver with the tty layer. rp_init()
2447 printk(KERN_ERR "Couldn't install tty RocketPort driver\n"); rp_init()
H A Dsynclinkmp.c44 #include <linux/tty.h>
504 /* tty callbacks */
506 static int open(struct tty_struct *tty, struct file * filp);
507 static void close(struct tty_struct *tty, struct file * filp);
508 static void hangup(struct tty_struct *tty);
509 static void set_termios(struct tty_struct *tty, struct ktermios *old_termios);
511 static int write(struct tty_struct *tty, const unsigned char *buf, int count);
512 static int put_char(struct tty_struct *tty, unsigned char ch);
513 static void send_xchar(struct tty_struct *tty, char ch);
514 static void wait_until_sent(struct tty_struct *tty, int timeout);
515 static int write_room(struct tty_struct *tty);
516 static void flush_chars(struct tty_struct *tty);
517 static void flush_buffer(struct tty_struct *tty);
518 static void tx_hold(struct tty_struct *tty);
519 static void tx_release(struct tty_struct *tty);
521 static int ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
522 static int chars_in_buffer(struct tty_struct *tty);
523 static void throttle(struct tty_struct * tty);
524 static void unthrottle(struct tty_struct * tty);
525 static int set_break(struct tty_struct *tty, int break_state);
547 static int tiocmget(struct tty_struct *tty);
548 static int tiocmset(struct tty_struct *tty,
550 static int set_break(struct tty_struct *tty, int break_state);
558 static int block_til_ready(struct tty_struct *tty, struct file * filp,SLMP_INFO *info);
697 static void ldisc_receive_buf(struct tty_struct *tty, ldisc_receive_buf() argument
701 if (!tty) ldisc_receive_buf()
703 ld = tty_ldisc_ref(tty); ldisc_receive_buf()
706 ld->ops->receive_buf(tty, data, flags, count); ldisc_receive_buf()
711 /* tty callbacks */
713 static int install(struct tty_driver *driver, struct tty_struct *tty) install() argument
716 int line = tty->index; install()
727 if (sanity_check(info, tty->name, "open")) install()
736 tty->driver_data = info; install()
738 return tty_port_install(&info->port, driver, tty); install()
743 static int open(struct tty_struct *tty, struct file *filp) open() argument
745 SLMP_INFO *info = tty->driver_data; open()
749 info->port.tty = tty; open()
753 __FILE__,__LINE__,tty->driver->name, info->port.count); open()
757 wait_event_interruptible_tty(tty, info->port.close_wait, open()
782 retval = block_til_ready(tty, filp, info); open()
797 if (tty->count == 1) open()
798 info->port.tty = NULL; /* tty layer will release tty struct */ open()
809 static void close(struct tty_struct *tty, struct file *filp) close() argument
811 SLMP_INFO * info = tty->driver_data; close()
813 if (sanity_check(info, tty->name, "close")) close()
820 if (tty_port_close_start(&info->port, tty, filp) == 0) close()
825 wait_until_sent(tty, info->timeout); close()
827 flush_buffer(tty); close()
828 tty_ldisc_flush(tty); close()
832 tty_port_close_end(&info->port, tty); close()
833 info->port.tty = NULL; close()
837 tty->driver->name, info->port.count); close()
843 static void hangup(struct tty_struct *tty) hangup() argument
845 SLMP_INFO *info = tty->driver_data; hangup()
852 if (sanity_check(info, tty->name, "hangup")) hangup()
856 flush_buffer(tty); hangup()
862 info->port.tty = NULL; hangup()
871 static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) set_termios() argument
873 SLMP_INFO *info = tty->driver_data; set_termios()
878 tty->driver->name ); set_termios()
884 !(tty->termios.c_cflag & CBAUD)) { set_termios()
893 tty->termios.c_cflag & CBAUD) { set_termios()
895 if (!(tty->termios.c_cflag & CRTSCTS) || set_termios()
896 !test_bit(TTY_THROTTLED, &tty->flags)) { set_termios()
906 !(tty->termios.c_cflag & CRTSCTS)) { set_termios()
907 tty->hw_stopped = 0; set_termios()
908 tx_release(tty); set_termios()
916 * tty pointer to tty information structure
922 static int write(struct tty_struct *tty, write() argument
926 SLMP_INFO *info = tty->driver_data; write()
933 if (sanity_check(info, tty->name, "write")) write()
986 if (info->tx_count && !tty->stopped && !tty->hw_stopped) { write()
1002 static int put_char(struct tty_struct *tty, unsigned char ch) put_char() argument
1004 SLMP_INFO *info = tty->driver_data; put_char()
1013 if (sanity_check(info, tty->name, "put_char")) put_char()
1039 static void send_xchar(struct tty_struct *tty, char ch) send_xchar() argument
1041 SLMP_INFO *info = tty->driver_data; send_xchar()
1048 if (sanity_check(info, tty->name, "send_xchar")) send_xchar()
1063 static void wait_until_sent(struct tty_struct *tty, int timeout) wait_until_sent() argument
1065 SLMP_INFO * info = tty->driver_data; wait_until_sent()
1075 if (sanity_check(info, tty->name, "wait_until_sent")) wait_until_sent()
1129 static int write_room(struct tty_struct *tty) write_room() argument
1131 SLMP_INFO *info = tty->driver_data; write_room()
1134 if (sanity_check(info, tty->name, "write_room")) write_room()
1154 static void flush_chars(struct tty_struct *tty) flush_chars() argument
1156 SLMP_INFO *info = tty->driver_data; flush_chars()
1163 if (sanity_check(info, tty->name, "flush_chars")) flush_chars()
1166 if (info->tx_count <= 0 || tty->stopped || tty->hw_stopped || flush_chars()
1193 static void flush_buffer(struct tty_struct *tty) flush_buffer() argument
1195 SLMP_INFO *info = tty->driver_data; flush_buffer()
1202 if (sanity_check(info, tty->name, "flush_buffer")) flush_buffer()
1210 tty_wakeup(tty); flush_buffer()
1215 static void tx_hold(struct tty_struct *tty) tx_hold() argument
1217 SLMP_INFO *info = tty->driver_data; tx_hold()
1220 if (sanity_check(info, tty->name, "tx_hold")) tx_hold()
1235 static void tx_release(struct tty_struct *tty) tx_release() argument
1237 SLMP_INFO *info = tty->driver_data; tx_release()
1240 if (sanity_check(info, tty->name, "tx_release")) tx_release()
1257 * tty pointer to tty instance data
1263 static int ioctl(struct tty_struct *tty, ioctl() argument
1266 SLMP_INFO *info = tty->driver_data; ioctl()
1273 if (sanity_check(info, tty->name, "ioctl")) ioctl()
1278 if (tty->flags & (1 << TTY_IO_ERROR)) ioctl()
1321 static int get_icount(struct tty_struct *tty, get_icount() argument
1324 SLMP_INFO *info = tty->driver_data; get_icount()
1453 static int chars_in_buffer(struct tty_struct *tty) chars_in_buffer() argument
1455 SLMP_INFO *info = tty->driver_data; chars_in_buffer()
1457 if (sanity_check(info, tty->name, "chars_in_buffer")) chars_in_buffer()
1469 static void throttle(struct tty_struct * tty) throttle() argument
1471 SLMP_INFO *info = tty->driver_data; throttle()
1478 if (sanity_check(info, tty->name, "throttle")) throttle()
1481 if (I_IXOFF(tty)) throttle()
1482 send_xchar(tty, STOP_CHAR(tty)); throttle()
1484 if (tty->termios.c_cflag & CRTSCTS) { throttle()
1494 static void unthrottle(struct tty_struct * tty) unthrottle() argument
1496 SLMP_INFO *info = tty->driver_data; unthrottle()
1503 if (sanity_check(info, tty->name, "unthrottle")) unthrottle()
1506 if (I_IXOFF(tty)) { unthrottle()
1510 send_xchar(tty, START_CHAR(tty)); unthrottle()
1513 if (tty->termios.c_cflag & CRTSCTS) { unthrottle()
1524 static int set_break(struct tty_struct *tty, int break_state) set_break() argument
1527 SLMP_INFO * info = tty->driver_data; set_break()
1534 if (sanity_check(info, tty->name, "set_break")) set_break()
1661 /* arbitrate between network and tty opens */ hdlcdev_open()
2059 struct tty_struct *tty = info->port.tty; bh_transmit() local
2065 if (tty) bh_transmit()
2066 tty_wakeup(tty); bh_transmit()
2109 struct tty_struct *tty = info->port.tty; isr_rxint() local
2129 /* process break detection if tty control isr_rxint()
2135 if (tty && (info->port.flags & ASYNC_SAK)) isr_rxint()
2136 do_SAK(tty); isr_rxint()
2194 /* discard char if tty control flags say so */ isr_rxrdy()
2275 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) { isr_txeom()
2330 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) { isr_txrdy()
2487 if (info->port.tty) isr_io_pin()
2488 tty_hangup(info->port.tty); isr_io_pin()
2494 if ( info->port.tty ) { isr_io_pin()
2495 if (info->port.tty->hw_stopped) { isr_io_pin()
2499 info->port.tty->hw_stopped = 0; isr_io_pin()
2508 info->port.tty->hw_stopped = 1; isr_io_pin()
2673 if (info->port.tty) startup()
2674 clear_bit(TTY_IO_ERROR, &info->port.tty->flags); startup()
2709 if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { shutdown()
2716 if (info->port.tty) shutdown()
2717 set_bit(TTY_IO_ERROR, &info->port.tty->flags); shutdown()
2750 if (info->netcount || (info->port.tty && info->port.tty->termios.c_cflag & CREAD) ) program_hw()
2763 if (!info->port.tty) change_params()
2770 cflag = info->port.tty->termios.c_cflag; change_params()
2814 * allow tty settings to override, otherwise keep the change_params()
2818 info->params.data_rate = tty_get_baud_rate(info->port.tty); change_params()
2837 /* process tty input control flags */ change_params()
2840 if (I_INPCK(info->port.tty)) change_params()
2842 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty)) change_params()
2844 if (I_IGNPAR(info->port.tty)) change_params()
2846 if (I_IGNBRK(info->port.tty)) { change_params()
2851 if (I_IGNPAR(info->port.tty)) change_params()
3206 static int tiocmget(struct tty_struct *tty) tiocmget() argument
3208 SLMP_INFO *info = tty->driver_data; tiocmget()
3231 static int tiocmset(struct tty_struct *tty, tiocmset() argument
3234 SLMP_INFO *info = tty->driver_data; tiocmset()
3285 static int block_til_ready(struct tty_struct *tty, struct file *filp, block_til_ready() argument
3297 __FILE__,__LINE__, tty->driver->name ); block_til_ready()
3299 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ block_til_ready()
3306 if (tty->termios.c_cflag & CLOCAL) block_til_ready()
3321 __FILE__,__LINE__, tty->driver->name, port->count ); block_til_ready()
3329 if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) block_til_ready()
3352 __FILE__,__LINE__, tty->driver->name, port->count ); block_til_ready()
3354 tty_unlock(tty); block_til_ready()
3356 tty_lock(tty); block_til_ready()
3367 __FILE__,__LINE__, tty->driver->name, port->count ); block_til_ready()
3924 printk("%s(%d) failed to unregister tty driver err=%d\n", synclinkmp_cleanup()
4006 printk("%s %s, tty major#%d\n", synclinkmp_init()
4847 struct tty_struct *tty = info->port.tty; rx_get_frame() local
4988 ldisc_receive_buf(tty,info->tmp_rx_buf, rx_get_frame()
5254 struct tty_struct *oldtty = info->port.tty; loopback_test()
5258 info->port.tty = NULL; loopback_test()
5302 info->port.tty = oldtty; loopback_test()
H A Dsynclink_gt.c54 #include <linux/tty.h>
137 * tty support and callbacks
141 static int open(struct tty_struct *tty, struct file * filp);
142 static void close(struct tty_struct *tty, struct file * filp);
143 static void hangup(struct tty_struct *tty);
144 static void set_termios(struct tty_struct *tty, struct ktermios *old_termios);
146 static int write(struct tty_struct *tty, const unsigned char *buf, int count);
147 static int put_char(struct tty_struct *tty, unsigned char ch);
148 static void send_xchar(struct tty_struct *tty, char ch);
149 static void wait_until_sent(struct tty_struct *tty, int timeout);
150 static int write_room(struct tty_struct *tty);
151 static void flush_chars(struct tty_struct *tty);
152 static void flush_buffer(struct tty_struct *tty);
153 static void tx_hold(struct tty_struct *tty);
154 static void tx_release(struct tty_struct *tty);
156 static int ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
157 static int chars_in_buffer(struct tty_struct *tty);
158 static void throttle(struct tty_struct * tty);
159 static void unthrottle(struct tty_struct * tty);
160 static int set_break(struct tty_struct *tty, int break_state);
257 int line; /* tty line instance number */
442 static int block_til_ready(struct tty_struct *tty, struct file * filp,struct slgt_info *info);
513 static int tiocmget(struct tty_struct *tty);
514 static int tiocmset(struct tty_struct *tty,
516 static int set_break(struct tty_struct *tty, int break_state);
632 static void ldisc_receive_buf(struct tty_struct *tty, ldisc_receive_buf() argument
636 if (!tty) ldisc_receive_buf()
638 ld = tty_ldisc_ref(tty); ldisc_receive_buf()
641 ld->ops->receive_buf(tty, data, flags, count); ldisc_receive_buf()
646 /* tty callbacks */
648 static int open(struct tty_struct *tty, struct file *filp) open() argument
654 line = tty->index; open()
663 if (sanity_check(info, tty->name, "open")) open()
670 tty->driver_data = info; open()
671 info->port.tty = tty; open()
677 wait_event_interruptible_tty(tty, info->port.close_wait, open()
706 retval = block_til_ready(tty, filp, info); open()
716 if (tty->count == 1) open()
717 info->port.tty = NULL; /* tty layer will release tty struct */ open()
726 static void close(struct tty_struct *tty, struct file *filp) close() argument
728 struct slgt_info *info = tty->driver_data; close()
730 if (sanity_check(info, tty->name, "close")) close()
734 if (tty_port_close_start(&info->port, tty, filp) == 0) close()
739 wait_until_sent(tty, info->timeout); close()
740 flush_buffer(tty); close()
741 tty_ldisc_flush(tty); close()
746 tty_port_close_end(&info->port, tty); close()
747 info->port.tty = NULL; close()
749 DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count)); close()
752 static void hangup(struct tty_struct *tty) hangup() argument
754 struct slgt_info *info = tty->driver_data; hangup()
757 if (sanity_check(info, tty->name, "hangup")) hangup()
761 flush_buffer(tty); hangup()
769 info->port.tty = NULL; hangup()
776 static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) set_termios() argument
778 struct slgt_info *info = tty->driver_data; set_termios()
781 DBGINFO(("%s set_termios\n", tty->driver->name)); set_termios()
787 !(tty->termios.c_cflag & CBAUD)) { set_termios()
796 tty->termios.c_cflag & CBAUD) { set_termios()
798 if (!(tty->termios.c_cflag & CRTSCTS) || set_termios()
799 !test_bit(TTY_THROTTLED, &tty->flags)) { set_termios()
809 !(tty->termios.c_cflag & CRTSCTS)) { set_termios()
810 tty->hw_stopped = 0; set_termios()
811 tx_release(tty); set_termios()
827 static int write(struct tty_struct *tty, write() argument
831 struct slgt_info *info = tty->driver_data; write()
834 if (sanity_check(info, tty->name, "write")) write()
842 if (!count || tty->stopped || tty->hw_stopped) write()
863 static int put_char(struct tty_struct *tty, unsigned char ch) put_char() argument
865 struct slgt_info *info = tty->driver_data; put_char()
869 if (sanity_check(info, tty->name, "put_char")) put_char()
883 static void send_xchar(struct tty_struct *tty, char ch) send_xchar() argument
885 struct slgt_info *info = tty->driver_data; send_xchar()
888 if (sanity_check(info, tty->name, "send_xchar")) send_xchar()
900 static void wait_until_sent(struct tty_struct *tty, int timeout) wait_until_sent() argument
902 struct slgt_info *info = tty->driver_data; wait_until_sent()
907 if (sanity_check(info, tty->name, "wait_until_sent")) wait_until_sent()
942 static int write_room(struct tty_struct *tty) write_room() argument
944 struct slgt_info *info = tty->driver_data; write_room()
947 if (sanity_check(info, tty->name, "write_room")) write_room()
954 static void flush_chars(struct tty_struct *tty) flush_chars() argument
956 struct slgt_info *info = tty->driver_data; flush_chars()
959 if (sanity_check(info, tty->name, "flush_chars")) flush_chars()
963 if (info->tx_count <= 0 || tty->stopped || flush_chars()
964 tty->hw_stopped || !info->tx_buf) flush_chars()
975 static void flush_buffer(struct tty_struct *tty) flush_buffer() argument
977 struct slgt_info *info = tty->driver_data; flush_buffer()
980 if (sanity_check(info, tty->name, "flush_buffer")) flush_buffer()
988 tty_wakeup(tty); flush_buffer()
994 static void tx_hold(struct tty_struct *tty) tx_hold() argument
996 struct slgt_info *info = tty->driver_data; tx_hold()
999 if (sanity_check(info, tty->name, "tx_hold")) tx_hold()
1011 static void tx_release(struct tty_struct *tty) tx_release() argument
1013 struct slgt_info *info = tty->driver_data; tx_release()
1016 if (sanity_check(info, tty->name, "tx_release")) tx_release()
1030 * tty pointer to tty instance data
1036 static int ioctl(struct tty_struct *tty, ioctl() argument
1039 struct slgt_info *info = tty->driver_data; ioctl()
1043 if (sanity_check(info, tty->name, "ioctl")) ioctl()
1049 if (tty->flags & (1 << TTY_IO_ERROR)) ioctl()
1112 static int get_icount(struct tty_struct *tty, get_icount() argument
1116 struct slgt_info *info = tty->driver_data; get_icount()
1200 static long slgt_compat_ioctl(struct tty_struct *tty, slgt_compat_ioctl() argument
1203 struct slgt_info *info = tty->driver_data; slgt_compat_ioctl()
1206 if (sanity_check(info, tty->name, "compat_ioctl")) slgt_compat_ioctl()
1239 rc = ioctl(tty, cmd, arg); slgt_compat_ioctl()
1350 static int chars_in_buffer(struct tty_struct *tty) chars_in_buffer() argument
1352 struct slgt_info *info = tty->driver_data; chars_in_buffer()
1354 if (sanity_check(info, tty->name, "chars_in_buffer")) chars_in_buffer()
1364 static void throttle(struct tty_struct * tty) throttle() argument
1366 struct slgt_info *info = tty->driver_data; throttle()
1369 if (sanity_check(info, tty->name, "throttle")) throttle()
1372 if (I_IXOFF(tty)) throttle()
1373 send_xchar(tty, STOP_CHAR(tty)); throttle()
1374 if (tty->termios.c_cflag & CRTSCTS) { throttle()
1385 static void unthrottle(struct tty_struct * tty) unthrottle() argument
1387 struct slgt_info *info = tty->driver_data; unthrottle()
1390 if (sanity_check(info, tty->name, "unthrottle")) unthrottle()
1393 if (I_IXOFF(tty)) { unthrottle()
1397 send_xchar(tty, START_CHAR(tty)); unthrottle()
1399 if (tty->termios.c_cflag & CRTSCTS) { unthrottle()
1411 static int set_break(struct tty_struct *tty, int break_state) set_break() argument
1413 struct slgt_info *info = tty->driver_data; set_break()
1417 if (sanity_check(info, tty->name, "set_break")) set_break()
1545 /* arbitrate between network and tty opens */ hdlcdev_open()
1887 /* discard char if tty control flags say so */ rx_async()
2004 struct tty_struct *tty = info->port.tty; bh_transmit() local
2007 if (tty) bh_transmit()
2008 tty_wakeup(tty); bh_transmit()
2051 if (info->port.tty) { cts_change()
2052 if (info->port.tty->hw_stopped) { cts_change()
2054 info->port.tty->hw_stopped = 0; cts_change()
2060 info->port.tty->hw_stopped = 1; cts_change()
2097 if (info->port.tty) dcd_change()
2098 tty_hangup(info->port.tty); dcd_change()
2176 /* process break detection if tty control allows */ isr_serial()
2177 if (info->port.tty) { isr_serial()
2182 do_SAK(info->port.tty); isr_serial()
2336 if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) { isr_txeom()
2452 if (info->port.tty) startup()
2453 clear_bit(TTY_IO_ERROR, &info->port.tty->flags); startup()
2490 if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { shutdown()
2499 if (info->port.tty) shutdown()
2500 set_bit(TTY_IO_ERROR, &info->port.tty->flags); shutdown()
2531 (info->port.tty && info->port.tty->termios.c_cflag & CREAD)) program_hw()
2545 if (!info->port.tty) change_params()
2549 cflag = info->port.tty->termios.c_cflag; change_params()
2581 info->params.data_rate = tty_get_baud_rate(info->port.tty); change_params()
2599 /* process tty input control flags */ change_params()
2602 if (I_INPCK(info->port.tty)) change_params()
2604 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty)) change_params()
2606 if (I_IGNPAR(info->port.tty)) change_params()
2608 if (I_IGNBRK(info->port.tty)) { change_params()
2613 if (I_IGNPAR(info->port.tty)) change_params()
3190 static int tiocmget(struct tty_struct *tty) tiocmget() argument
3192 struct slgt_info *info = tty->driver_data; tiocmget()
3218 static int tiocmset(struct tty_struct *tty, tiocmset() argument
3221 struct slgt_info *info = tty->driver_data; tiocmset()
3270 static int block_til_ready(struct tty_struct *tty, struct file *filp, block_til_ready() argument
3280 DBGINFO(("%s block_til_ready\n", tty->driver->name)); block_til_ready()
3282 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ block_til_ready()
3288 if (tty->termios.c_cflag & CLOCAL) block_til_ready()
3307 if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) block_til_ready()
3328 DBGINFO(("%s block_til_ready wait\n", tty->driver->name)); block_til_ready()
3329 tty_unlock(tty); block_til_ready()
3331 tty_lock(tty); block_til_ready()
3344 DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval)); block_til_ready()
3801 printk("%s can't allocate tty driver\n", driver_name); slgt_init()
3827 printk(KERN_INFO "%s, tty major#%d\n", slgt_init()
4656 struct tty_struct *tty = info->port.tty; rx_get_frame() local
4773 ldisc_receive_buf(tty, info->tmp_rbuf, info->flag_buf, framesize); rx_get_frame()
4784 * pass receive buffer (RAW synchronous mode) to tty layer
4807 ldisc_receive_buf(info->port.tty, info->rbufs[i].buf, rx_get_buf()
4994 struct tty_struct *oldtty = info->port.tty; irq_test()
4998 info->port.tty = NULL; irq_test()
5026 info->port.tty = oldtty; irq_test()
5066 struct tty_struct *oldtty = info->port.tty; loopback_test()
5074 info->port.tty = NULL; loopback_test()
5110 info->port.tty = oldtty; loopback_test()
H A Dnozomi.c48 #include <linux/tty.h>
389 spinlock_t spin_mutex; /* secures access to registers and tty */
418 static inline struct nozomi *get_dc_by_tty(const struct tty_struct *tty) get_dc_by_tty() argument
420 return tty ? ndevs[tty->index / MAX_PORT] : NULL; get_dc_by_tty()
423 static inline struct port *get_port_by_tty(const struct tty_struct *tty) get_port_by_tty() argument
425 struct nozomi *ndev = get_dc_by_tty(tty); get_port_by_tty()
426 return ndev ? &ndev->port[tty->index % MAX_PORT] : NULL; get_port_by_tty()
795 /* Get data from tty and place in buf for now */ send_data()
823 struct tty_struct *tty = tty_port_tty_get(&port->port); receive_data() local
829 if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { receive_data()
830 DBG1("No room in tty, don't read data, don't ack interrupt, " receive_data()
865 tty_kref_put(tty); receive_data()
1367 dev_err(&pdev->dev, "no free tty range for this card left\n"); nozomi_card_init()
1469 dev_err(&pdev->dev, "Could not allocate tty?\n"); nozomi_card_init()
1562 static void set_rts(const struct tty_struct *tty, int rts) set_rts() argument
1564 struct port *port = get_port_by_tty(tty); set_rts()
1568 enable_transmit_ul(PORT_CTRL, get_dc_by_tty(tty)); set_rts()
1571 static void set_dtr(const struct tty_struct *tty, int dtr) set_dtr() argument
1573 struct port *port = get_port_by_tty(tty); set_dtr()
1575 DBG1("SETTING DTR index: %d, dtr: %d", tty->index, dtr); set_dtr()
1579 enable_transmit_ul(PORT_CTRL, get_dc_by_tty(tty)); set_dtr()
1588 static int ntty_install(struct tty_driver *driver, struct tty_struct *tty) ntty_install() argument
1590 struct port *port = get_port_by_tty(tty); ntty_install()
1591 struct nozomi *dc = get_dc_by_tty(tty); ntty_install()
1595 ret = tty_standard_install(driver, tty); ntty_install()
1597 tty->driver_data = port; ntty_install()
1601 static void ntty_cleanup(struct tty_struct *tty) ntty_cleanup() argument
1603 tty->driver_data = NULL; ntty_cleanup()
1606 static int ntty_activate(struct tty_port *tport, struct tty_struct *tty) ntty_activate() argument
1618 printk("noz: activated %d: %p\n", tty->index, tport); ntty_activate()
1622 static int ntty_open(struct tty_struct *tty, struct file *filp) ntty_open() argument
1624 struct port *port = tty->driver_data; ntty_open()
1625 return tty_port_open(&port->port, tty, filp); ntty_open()
1643 static void ntty_close(struct tty_struct *tty, struct file *filp) ntty_close() argument
1645 struct port *port = tty->driver_data; ntty_close()
1647 tty_port_close(&port->port, tty, filp); ntty_close()
1650 static void ntty_hangup(struct tty_struct *tty) ntty_hangup() argument
1652 struct port *port = tty->driver_data; ntty_hangup()
1657 * called when the userspace process writes to the tty (/dev/noz*).
1660 static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, ntty_write() argument
1664 struct nozomi *dc = get_dc_by_tty(tty); ntty_write()
1665 struct port *port = tty->driver_data; ntty_write()
1680 enable_transmit_ul(tty->index % MAX_PORT, dc); ntty_write()
1686 enable_transmit_ul(tty->index % MAX_PORT, dc); ntty_write()
1695 * This method is called by the upper tty layer.
1702 static int ntty_write_room(struct tty_struct *tty) ntty_write_room() argument
1704 struct port *port = tty->driver_data; ntty_write_room()
1706 const struct nozomi *dc = get_dc_by_tty(tty); ntty_write_room()
1715 static int ntty_tiocmget(struct tty_struct *tty) ntty_tiocmget() argument
1717 const struct port *port = tty->driver_data; ntty_tiocmget()
1732 static int ntty_tiocmset(struct tty_struct *tty, ntty_tiocmset() argument
1735 struct nozomi *dc = get_dc_by_tty(tty); ntty_tiocmset()
1740 set_rts(tty, 1); ntty_tiocmset()
1742 set_rts(tty, 0); ntty_tiocmset()
1745 set_dtr(tty, 1); ntty_tiocmset()
1747 set_dtr(tty, 0); ntty_tiocmset()
1769 static int ntty_tiocgicount(struct tty_struct *tty, ntty_tiocgicount() argument
1772 struct port *port = tty->driver_data; ntty_tiocgicount()
1789 static int ntty_ioctl(struct tty_struct *tty, ntty_ioctl() argument
1792 struct port *port = tty->driver_data; ntty_ioctl()
1814 * Called by the upper tty layer when tty buffers are ready
1817 static void ntty_unthrottle(struct tty_struct *tty) ntty_unthrottle() argument
1819 struct nozomi *dc = get_dc_by_tty(tty); ntty_unthrottle()
1824 enable_transmit_dl(tty->index % MAX_PORT, dc); ntty_unthrottle()
1825 set_rts(tty, 1); ntty_unthrottle()
1831 * Called by the upper tty layer when the tty buffers are almost full.
1834 static void ntty_throttle(struct tty_struct *tty) ntty_throttle() argument
1836 struct nozomi *dc = get_dc_by_tty(tty); ntty_throttle()
1841 set_rts(tty, 0); ntty_throttle()
1845 /* Returns number of chars in buffer, called by tty layer */ ntty_chars_in_buffer()
1846 static s32 ntty_chars_in_buffer(struct tty_struct *tty) ntty_chars_in_buffer() argument
1848 struct port *port = tty->driver_data; ntty_chars_in_buffer()
1849 struct nozomi *dc = get_dc_by_tty(tty); ntty_chars_in_buffer()
H A Dcyclades.c62 #include <linux/tty.h>
90 static void cy_send_xchar(struct tty_struct *tty, char ch);
486 struct tty_struct *tty = cyy_chip_rx() local
488 if (tty) { cyy_chip_rx()
489 do_SAK(tty); cyy_chip_rx()
490 tty_kref_put(tty); cyy_chip_rx()
572 struct tty_struct *tty; cyy_chip_tx() local
590 tty = tty_port_tty_get(&info->port); cyy_chip_tx()
591 if (tty == NULL) { cyy_chip_tx()
638 if (tty->stopped || tty->hw_stopped) { cyy_chip_tx()
673 tty_wakeup(tty); cyy_chip_tx()
674 tty_kref_put(tty); cyy_chip_tx()
685 struct tty_struct *tty; cyy_chip_modem() local
699 tty = tty_port_tty_get(&info->port); cyy_chip_modem()
700 if (!tty) cyy_chip_modem()
721 tty_hangup(tty); cyy_chip_modem()
724 if (tty->hw_stopped) { cyy_chip_modem()
728 tty->hw_stopped = 0; cyy_chip_modem()
731 tty_wakeup(tty); cyy_chip_modem()
737 tty->hw_stopped = 1; cyy_chip_modem()
747 tty_kref_put(tty); cyy_chip_modem()
1013 struct tty_struct *tty; cyz_handle_tx() local
1036 tty = tty_port_tty_get(&info->port); cyz_handle_tx()
1037 if (tty == NULL) cyz_handle_tx()
1080 tty_wakeup(tty); cyz_handle_tx()
1081 tty_kref_put(tty); cyz_handle_tx()
1265 static int cy_startup(struct cyclades_port *info, struct tty_struct *tty) cy_startup() argument
1286 set_bit(TTY_IO_ERROR, &tty->flags); cy_startup()
1297 cy_set_line_char(info, tty); cy_startup()
1369 clear_bit(TTY_IO_ERROR, &tty->flags); cy_startup()
1422 static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty) cy_shutdown() argument
1443 if (tty->termios.c_cflag & HUPCL) cy_shutdown()
1450 set_bit(TTY_IO_ERROR, &tty->flags); cy_shutdown()
1472 if (tty->termios.c_cflag & HUPCL) cy_shutdown()
1475 set_bit(TTY_IO_ERROR, &tty->flags); cy_shutdown()
1494 * performs the serial-specific initialization for the tty structure.
1496 static int cy_open(struct tty_struct *tty, struct file *filp) cy_open() argument
1499 unsigned int i, line = tty->index; cy_open()
1565 tty->driver_data = info; cy_open()
1566 if (serial_paranoia_check(info, tty->name, "cy_open")) cy_open()
1583 wait_event_interruptible_tty(tty, info->port.close_wait, cy_open()
1591 retval = cy_startup(info, tty); cy_open()
1595 retval = tty_port_block_til_ready(&info->port, tty, filp); cy_open()
1605 tty_port_tty_set(&info->port, tty); cy_open()
1616 static void cy_wait_until_sent(struct tty_struct *tty, int timeout) cy_wait_until_sent() argument
1619 struct cyclades_port *info = tty->driver_data; cy_wait_until_sent()
1623 if (serial_paranoia_check(info, tty->name, "cy_wait_until_sent")) cy_wait_until_sent()
1672 static void cy_flush_buffer(struct tty_struct *tty) cy_flush_buffer() argument
1674 struct cyclades_port *info = tty->driver_data; cy_flush_buffer()
1683 if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) cy_flush_buffer()
1703 tty_wakeup(tty); cy_flush_buffer()
1727 cy_wait_until_sent(port->tty, info->timeout); cy_do_close()
1750 cy_shutdown(info, port->tty); cy_do_close()
1754 * This routine is called when a particular tty device is closed.
1756 static void cy_close(struct tty_struct *tty, struct file *filp) cy_close() argument
1758 struct cyclades_port *info = tty->driver_data; cy_close()
1759 if (!info || serial_paranoia_check(info, tty->name, "cy_close")) cy_close()
1761 tty_port_close(&info->port, tty, filp); cy_close()
1777 static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count) cy_write() argument
1779 struct cyclades_port *info = tty->driver_data; cy_write()
1787 if (serial_paranoia_check(info, tty->name, "cy_write")) cy_write()
1814 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) cy_write()
1822 * character to the tty device. If the kernel uses this routine,
1827 static int cy_put_char(struct tty_struct *tty, unsigned char ch) cy_put_char() argument
1829 struct cyclades_port *info = tty->driver_data; cy_put_char()
1836 if (serial_paranoia_check(info, tty->name, "cy_put_char")) cy_put_char()
1859 * series of characters to the tty device using put_char().
1861 static void cy_flush_chars(struct tty_struct *tty) cy_flush_chars() argument
1863 struct cyclades_port *info = tty->driver_data; cy_flush_chars()
1869 if (serial_paranoia_check(info, tty->name, "cy_flush_chars")) cy_flush_chars()
1872 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || cy_flush_chars()
1880 * This routine returns the numbers of characters the tty driver
1885 static int cy_write_room(struct tty_struct *tty) cy_write_room() argument
1887 struct cyclades_port *info = tty->driver_data; cy_write_room()
1894 if (serial_paranoia_check(info, tty->name, "cy_write_room")) cy_write_room()
1902 static int cy_chars_in_buffer(struct tty_struct *tty) cy_chars_in_buffer() argument
1904 struct cyclades_port *info = tty->driver_data; cy_chars_in_buffer()
1906 if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer")) cy_chars_in_buffer()
1974 static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty) cy_set_line_char() argument
1986 cflag = tty->termios.c_cflag; cy_set_line_char()
1987 iflag = tty->termios.c_iflag; cy_set_line_char()
1990 * Set up the tty->alt_speed kludge cy_set_line_char()
1993 tty->alt_speed = 57600; cy_set_line_char()
1995 tty->alt_speed = 115200; cy_set_line_char()
1997 tty->alt_speed = 230400; cy_set_line_char()
1999 tty->alt_speed = 460800; cy_set_line_char()
2008 baud = tty_get_baud_rate(tty); cy_set_line_char()
2131 cyy_writeb(info, CySCHR1, START_CHAR(tty)); cy_set_line_char()
2132 cyy_writeb(info, CySCHR2, STOP_CHAR(tty)); cy_set_line_char()
2149 if (!C_CLOCAL(tty)) cy_set_line_char()
2166 clear_bit(TTY_IO_ERROR, &tty->flags); cy_set_line_char()
2178 baud = tty_get_baud_rate(tty); cy_set_line_char()
2289 clear_bit(TTY_IO_ERROR, &tty->flags); cy_set_line_char()
2314 cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty, cy_set_serial_info() argument
2355 cy_set_line_char(info, tty); cy_set_serial_info()
2358 ret = cy_startup(info, tty); cy_set_serial_info()
2393 static int cy_tiocmget(struct tty_struct *tty) cy_tiocmget() argument
2395 struct cyclades_port *info = tty->driver_data; cy_tiocmget()
2399 if (serial_paranoia_check(info, tty->name, __func__)) cy_tiocmget()
2447 cy_tiocmset(struct tty_struct *tty, cy_tiocmset() argument
2450 struct cyclades_port *info = tty->driver_data; cy_tiocmset()
2454 if (serial_paranoia_check(info, tty->name, __func__)) cy_tiocmset()
2503 static int cy_break(struct tty_struct *tty, int break_state) cy_break() argument
2505 struct cyclades_port *info = tty->driver_data; cy_break()
2510 if (serial_paranoia_check(info, tty->name, "cy_break")) cy_break()
2639 * This routine allows the tty driver to implement device-
2644 cy_ioctl(struct tty_struct *tty, cy_ioctl() argument
2647 struct cyclades_port *info = tty->driver_data; cy_ioctl()
2653 if (serial_paranoia_check(info, tty->name, "cy_ioctl")) cy_ioctl()
2730 ret_val = cy_set_serial_info(info, tty, argp); cy_ioctl()
2766 static int cy_get_icount(struct tty_struct *tty, cy_get_icount() argument
2769 struct cyclades_port *info = tty->driver_data; cy_get_icount()
2792 * This routine allows the tty driver to be notified when
2794 * well-designed tty driver should be prepared to accept the case
2797 static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios) cy_set_termios() argument
2799 struct cyclades_port *info = tty->driver_data; cy_set_termios()
2805 cy_set_line_char(info, tty); cy_set_termios()
2808 !(tty->termios.c_cflag & CRTSCTS)) { cy_set_termios()
2809 tty->hw_stopped = 0; cy_set_termios()
2810 cy_start(tty); cy_set_termios()
2820 (tty->termios.c_cflag & CLOCAL)) cy_set_termios()
2828 static void cy_send_xchar(struct tty_struct *tty, char ch) cy_send_xchar() argument
2830 struct cyclades_port *info = tty->driver_data; cy_send_xchar()
2834 if (serial_paranoia_check(info, tty->name, "cy_send_xchar")) cy_send_xchar()
2840 cy_start(tty); cy_send_xchar()
2846 if (ch == STOP_CHAR(tty)) cy_send_xchar()
2848 else if (ch == START_CHAR(tty)) cy_send_xchar()
2853 /* This routine is called by the upper-layer tty layer to signal
2857 static void cy_throttle(struct tty_struct *tty) cy_throttle() argument
2859 struct cyclades_port *info = tty->driver_data; cy_throttle()
2866 printk(KERN_DEBUG "cyc:throttle %s: %ld...ttyC%d\n", tty_name(tty, buf), cy_throttle()
2867 tty->ldisc.chars_in_buffer(tty), info->line); cy_throttle()
2870 if (serial_paranoia_check(info, tty->name, "cy_throttle")) cy_throttle()
2875 if (I_IXOFF(tty)) { cy_throttle()
2877 cy_send_xchar(tty, STOP_CHAR(tty)); cy_throttle()
2882 if (tty->termios.c_cflag & CRTSCTS) { cy_throttle()
2894 * This routine notifies the tty driver that it should signal
2895 * that characters can now be sent to the tty without fear of
2898 static void cy_unthrottle(struct tty_struct *tty) cy_unthrottle() argument
2900 struct cyclades_port *info = tty->driver_data; cy_unthrottle()
2908 tty_name(tty, buf), tty_chars_in_buffer(tty), info->line); cy_unthrottle()
2911 if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) cy_unthrottle()
2914 if (I_IXOFF(tty)) { cy_unthrottle()
2918 cy_send_xchar(tty, START_CHAR(tty)); cy_unthrottle()
2921 if (tty->termios.c_cflag & CRTSCTS) { cy_unthrottle()
2936 static void cy_stop(struct tty_struct *tty) cy_stop() argument
2939 struct cyclades_port *info = tty->driver_data; cy_stop()
2947 if (serial_paranoia_check(info, tty->name, "cy_stop")) cy_stop()
2960 static void cy_start(struct tty_struct *tty) cy_start() argument
2963 struct cyclades_port *info = tty->driver_data; cy_start()
2971 if (serial_paranoia_check(info, tty->name, "cy_start")) cy_start()
2987 static void cy_hangup(struct tty_struct *tty) cy_hangup() argument
2989 struct cyclades_port *info = tty->driver_data; cy_hangup()
2995 if (serial_paranoia_check(info, tty->name, "cy_hangup")) cy_hangup()
2998 cy_flush_buffer(tty); cy_hangup()
2999 cy_shutdown(info, tty); cy_hangup()
3979 struct tty_struct *tty; cyclades_proc_show() local
3982 tty = tty_port_tty_get(&info->port); cyclades_proc_show()
3983 if (tty) { cyclades_proc_show()
3984 ld = tty_ldisc_ref(tty); cyclades_proc_show()
3989 tty_kref_put(tty); cyclades_proc_show()
4026 These ports are mapped to the tty ports 32 and upward in monotonic
H A Dmetag_da.c2 * dashtty.c - tty driver for Dash channels interface.
28 #include <linux/tty.h>
232 struct tty_struct *tty; put_channel_data() local
259 /* if we've made more data available, wake up tty */ put_channel_data()
261 tty = tty_port_tty_get(&dport->port); put_channel_data()
262 if (tty) { put_channel_data()
263 tty_wakeup(tty); put_channel_data()
264 tty_kref_put(tty); put_channel_data()
341 static int dashtty_port_activate(struct tty_port *port, struct tty_struct *tty) dashtty_port_activate() argument
419 static int dashtty_install(struct tty_driver *driver, struct tty_struct *tty) dashtty_install() argument
421 return tty_port_install(&dashtty_ports[tty->index].port, driver, tty); dashtty_install()
424 static int dashtty_open(struct tty_struct *tty, struct file *filp) dashtty_open() argument
426 return tty_port_open(tty->port, tty, filp); dashtty_open()
429 static void dashtty_close(struct tty_struct *tty, struct file *filp) dashtty_close() argument
431 return tty_port_close(tty->port, tty, filp); dashtty_close()
434 static void dashtty_hangup(struct tty_struct *tty) dashtty_hangup() argument
439 channel = tty->index; dashtty_hangup()
453 tty_port_hangup(tty->port); dashtty_hangup()
470 static int dashtty_write(struct tty_struct *tty, const unsigned char *buf, dashtty_write() argument
477 channel = tty->index; dashtty_write()
527 static int dashtty_write_room(struct tty_struct *tty) dashtty_write_room() argument
533 channel = tty->index; dashtty_write_room()
544 static int dashtty_chars_in_buffer(struct tty_struct *tty) dashtty_chars_in_buffer() argument
550 channel = tty->index; dashtty_chars_in_buffer()
H A Dmoxa.c34 #include <linux/tty.h>
203 static int moxa_tiocmget(struct tty_struct *tty);
204 static int moxa_tiocmset(struct tty_struct *tty,
291 static int moxa_ioctl(struct tty_struct *tty, moxa_ioctl() argument
294 struct moxa_port *ch = tty->driver_data; moxa_ioctl()
298 if (tty->index == MAX_PORTS) { moxa_ioctl()
399 static int moxa_break_ctl(struct tty_struct *tty, int state) moxa_break_ctl() argument
401 struct moxa_port *port = tty->driver_data; moxa_break_ctl()
810 /* we skip the tty section (lens[1]), since we don't need it */ moxa_load_fw()
818 /* skip another tty */ moxa_load_fw()
1068 printk(KERN_ERR "can't register MOXA Smartio tty driver!\n"); moxa_init()
1168 static int moxa_open(struct tty_struct *tty, struct file *filp) moxa_open() argument
1174 port = tty->index; moxa_open()
1193 tty->driver_data = ch; moxa_open()
1194 tty_port_tty_set(&ch->port, tty); moxa_open()
1198 moxa_set_tty_param(tty, &tty->termios); moxa_open()
1207 return tty_port_block_til_ready(&ch->port, tty, filp); moxa_open()
1210 static void moxa_close(struct tty_struct *tty, struct file *filp) moxa_close() argument
1212 struct moxa_port *ch = tty->driver_data; moxa_close()
1213 ch->cflag = tty->termios.c_cflag; moxa_close()
1214 tty_port_close(&ch->port, tty, filp); moxa_close()
1217 static int moxa_write(struct tty_struct *tty, moxa_write() argument
1220 struct moxa_port *ch = tty->driver_data; moxa_write()
1228 len = MoxaPortWriteData(tty, buf, count); moxa_write()
1235 static int moxa_write_room(struct tty_struct *tty) moxa_write_room() argument
1239 if (tty->stopped) moxa_write_room()
1241 ch = tty->driver_data; moxa_write_room()
1247 static void moxa_flush_buffer(struct tty_struct *tty) moxa_flush_buffer() argument
1249 struct moxa_port *ch = tty->driver_data; moxa_flush_buffer()
1254 tty_wakeup(tty); moxa_flush_buffer()
1257 static int moxa_chars_in_buffer(struct tty_struct *tty) moxa_chars_in_buffer() argument
1259 struct moxa_port *ch = tty->driver_data; moxa_chars_in_buffer()
1272 static int moxa_tiocmget(struct tty_struct *tty) moxa_tiocmget() argument
1274 struct moxa_port *ch = tty->driver_data; moxa_tiocmget()
1292 static int moxa_tiocmset(struct tty_struct *tty, moxa_tiocmset() argument
1299 ch = tty->driver_data; moxa_tiocmset()
1319 static void moxa_set_termios(struct tty_struct *tty, moxa_set_termios() argument
1322 struct moxa_port *ch = tty->driver_data; moxa_set_termios()
1326 moxa_set_tty_param(tty, old_termios); moxa_set_termios()
1327 if (!(old_termios->c_cflag & CLOCAL) && C_CLOCAL(tty)) moxa_set_termios()
1331 static void moxa_stop(struct tty_struct *tty) moxa_stop() argument
1333 struct moxa_port *ch = tty->driver_data; moxa_stop()
1342 static void moxa_start(struct tty_struct *tty) moxa_start() argument
1344 struct moxa_port *ch = tty->driver_data; moxa_start()
1356 static void moxa_hangup(struct tty_struct *tty) moxa_hangup() argument
1358 struct moxa_port *ch = tty->driver_data; moxa_hangup()
1381 struct tty_struct *tty = tty_port_tty_get(&p->port); moxa_poll_port() local
1386 if (tty) { moxa_poll_port()
1390 tty_wakeup(tty); moxa_poll_port()
1392 if (test_bit(LOWWAIT, &p->statusflags) && !tty->stopped && moxa_poll_port()
1395 tty_wakeup(tty); moxa_poll_port()
1398 if (inited && !test_bit(TTY_THROTTLED, &tty->flags) && moxa_poll_port()
1424 if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */ moxa_poll_port()
1432 tty_kref_put(tty); moxa_poll_port()
1479 static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_termios) moxa_set_tty_param() argument
1481 register struct ktermios *ts = &tty->termios; moxa_set_tty_param()
1482 struct moxa_port *ch = tty->driver_data; moxa_set_tty_param()
1498 baud = MoxaPortSetTermio(ch, ts, tty_get_baud_rate(tty)); moxa_set_tty_param()
1502 tty_encode_baud_rate(tty, baud, baud); moxa_set_tty_param()
1661 * int MoxaPortReadData(int port, struct tty_struct *tty);
1663 * struct tty_struct *tty : tty for data
1874 static int MoxaPortWriteData(struct tty_struct *tty, MoxaPortWriteData() argument
1877 struct moxa_port *port = tty->driver_data; MoxaPortWriteData()
1893 moxaLog.txcnt[port->port.tty->index] += c; MoxaPortWriteData()
1935 struct tty_struct *tty = port->port.tty; MoxaPortReadData() local
1954 moxaLog.rxcnt[tty->index] += total; MoxaPortReadData()
2042 .line = info->port.tty->index, moxa_get_serial_info()
H A Dn_tracesink.h26 * data of it's tty port to the tty port this module sits. This
H A Dmips_ejtag_fdc.c29 #include <linux/tty.h>
421 struct tty_struct *tty; mips_ejtag_fdc_put_chan() local
466 /* If we've made more data available, wake up tty */ mips_ejtag_fdc_put_chan()
468 tty = tty_port_tty_get(&dport->port); mips_ejtag_fdc_put_chan()
469 if (tty) { mips_ejtag_fdc_put_chan()
470 tty_wakeup(tty); mips_ejtag_fdc_put_chan()
471 tty_kref_put(tty); mips_ejtag_fdc_put_chan()
575 /* Read out the FDC word, decode it, and pass to tty layer */ mips_ejtag_fdc_handle()
698 struct tty_struct *tty) mips_ejtag_fdc_tty_port_activate()
764 struct tty_struct *tty) mips_ejtag_fdc_tty_install()
768 tty->driver_data = &priv->ports[tty->index]; mips_ejtag_fdc_tty_install()
769 return tty_port_install(&priv->ports[tty->index].port, driver, tty); mips_ejtag_fdc_tty_install()
772 static int mips_ejtag_fdc_tty_open(struct tty_struct *tty, struct file *filp) mips_ejtag_fdc_tty_open() argument
774 return tty_port_open(tty->port, tty, filp); mips_ejtag_fdc_tty_open()
777 static void mips_ejtag_fdc_tty_close(struct tty_struct *tty, struct file *filp) mips_ejtag_fdc_tty_close() argument
779 return tty_port_close(tty->port, tty, filp); mips_ejtag_fdc_tty_close()
782 static void mips_ejtag_fdc_tty_hangup(struct tty_struct *tty) mips_ejtag_fdc_tty_hangup() argument
784 struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; mips_ejtag_fdc_tty_hangup()
798 tty_port_hangup(tty->port); mips_ejtag_fdc_tty_hangup()
801 static int mips_ejtag_fdc_tty_write(struct tty_struct *tty, mips_ejtag_fdc_tty_write() argument
805 struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; mips_ejtag_fdc_tty_write()
845 static int mips_ejtag_fdc_tty_write_room(struct tty_struct *tty) mips_ejtag_fdc_tty_write_room() argument
847 struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; mips_ejtag_fdc_tty_write_room()
859 static int mips_ejtag_fdc_tty_chars_in_buffer(struct tty_struct *tty) mips_ejtag_fdc_tty_chars_in_buffer() argument
861 struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; mips_ejtag_fdc_tty_chars_in_buffer()
1016 dev_err(priv->dev, "Couldn't install tty driver (%d)\n", ret); mips_ejtag_fdc_tty_probe()
697 mips_ejtag_fdc_tty_port_activate(struct tty_port *port, struct tty_struct *tty) mips_ejtag_fdc_tty_port_activate() argument
763 mips_ejtag_fdc_tty_install(struct tty_driver *driver, struct tty_struct *tty) mips_ejtag_fdc_tty_install() argument
H A Dsynclink.c37 * registers as a tty device AND a network device (if dosyncppp option
71 #include <linux/tty.h>
822 static int tiocmget(struct tty_struct *tty);
823 static int tiocmset(struct tty_struct *tty,
910 static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout);
956 static void ldisc_receive_buf(struct tty_struct *tty, ldisc_receive_buf() argument
960 if (!tty) ldisc_receive_buf()
962 ld = tty_ldisc_ref(tty); ldisc_receive_buf()
965 ld->ops->receive_buf(tty, data, flags, count); ldisc_receive_buf()
972 * Arguments: tty pointer to tty info structure
975 static void mgsl_stop(struct tty_struct *tty) mgsl_stop() argument
977 struct mgsl_struct *info = tty->driver_data; mgsl_stop()
980 if (mgsl_paranoia_check(info, tty->name, "mgsl_stop")) mgsl_stop()
995 * Arguments: tty pointer to tty info structure
998 static void mgsl_start(struct tty_struct *tty) mgsl_start() argument
1000 struct mgsl_struct *info = tty->driver_data; mgsl_start()
1003 if (mgsl_paranoia_check(info, tty->name, "mgsl_start")) mgsl_start()
1120 struct tty_struct *tty = info->port.tty; mgsl_bh_transmit() local
1127 if (tty) mgsl_bh_transmit()
1128 tty_wakeup(tty); mgsl_bh_transmit()
1262 if (info->port.tty->stopped || info->port.tty->hw_stopped) { mgsl_isr_transmit_status()
1353 if (info->port.tty) mgsl_isr_io_pin()
1354 tty_hangup(info->port.tty); mgsl_isr_io_pin()
1360 if (info->port.tty->hw_stopped) { mgsl_isr_io_pin()
1364 if (info->port.tty) mgsl_isr_io_pin()
1365 info->port.tty->hw_stopped = 0; mgsl_isr_io_pin()
1374 if (info->port.tty) mgsl_isr_io_pin()
1375 info->port.tty->hw_stopped = 1; mgsl_isr_io_pin()
1409 if (info->port.tty->stopped || info->port.tty->hw_stopped) { mgsl_isr_transmit_data()
1491 /* discard char if tty control flags say so */ mgsl_isr_receive_data()
1500 do_SAK(info->port.tty); mgsl_isr_receive_data()
1783 if (capable(CAP_SYS_ADMIN) && info->port.tty) startup()
1784 set_bit(TTY_IO_ERROR, &info->port.tty->flags); startup()
1792 if (info->port.tty) startup()
1793 clear_bit(TTY_IO_ERROR, &info->port.tty->flags); startup()
1849 if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { shutdown()
1858 if (info->port.tty) shutdown()
1859 set_bit(TTY_IO_ERROR, &info->port.tty->flags); shutdown()
1893 if (info->netcount || info->port.tty->termios.c_cflag & CREAD) mgsl_program_hw()
1906 if (!info->port.tty) mgsl_change_params()
1913 cflag = info->port.tty->termios.c_cflag; mgsl_change_params()
1957 * allow tty settings to override, otherwise keep the mgsl_change_params()
1961 info->params.data_rate = tty_get_baud_rate(info->port.tty); mgsl_change_params()
1979 /* process tty input control flags */ mgsl_change_params()
1982 if (I_INPCK(info->port.tty)) mgsl_change_params()
1984 if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty)) mgsl_change_params()
1987 if (I_IGNPAR(info->port.tty)) mgsl_change_params()
1989 if (I_IGNBRK(info->port.tty)) { mgsl_change_params()
1994 if (I_IGNPAR(info->port.tty)) mgsl_change_params()
2006 * Arguments: tty pointer to tty information structure
2011 static int mgsl_put_char(struct tty_struct *tty, unsigned char ch) mgsl_put_char() argument
2013 struct mgsl_struct *info = tty->driver_data; mgsl_put_char()
2022 if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char")) mgsl_put_char()
2048 * Arguments: tty pointer to tty information structure
2051 static void mgsl_flush_chars(struct tty_struct *tty) mgsl_flush_chars() argument
2053 struct mgsl_struct *info = tty->driver_data; mgsl_flush_chars()
2060 if (mgsl_paranoia_check(info, tty->name, "mgsl_flush_chars")) mgsl_flush_chars()
2063 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || mgsl_flush_chars()
2095 * tty pointer to tty information structure
2101 static int mgsl_write(struct tty_struct * tty, mgsl_write() argument
2105 struct mgsl_struct *info = tty->driver_data; mgsl_write()
2112 if (mgsl_paranoia_check(info, tty->name, "mgsl_write")) mgsl_write()
2203 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { mgsl_write()
2222 * Arguments: tty pointer to tty info structure
2225 static int mgsl_write_room(struct tty_struct *tty) mgsl_write_room() argument
2227 struct mgsl_struct *info = tty->driver_data; mgsl_write_room()
2230 if (mgsl_paranoia_check(info, tty->name, "mgsl_write_room")) mgsl_write_room()
2257 * Arguments: tty pointer to tty info structure
2260 static int mgsl_chars_in_buffer(struct tty_struct *tty) mgsl_chars_in_buffer() argument
2262 struct mgsl_struct *info = tty->driver_data; mgsl_chars_in_buffer()
2268 if (mgsl_paranoia_check(info, tty->name, "mgsl_chars_in_buffer")) mgsl_chars_in_buffer()
2291 * Arguments: tty pointer to tty info structure
2294 static void mgsl_flush_buffer(struct tty_struct *tty) mgsl_flush_buffer() argument
2296 struct mgsl_struct *info = tty->driver_data; mgsl_flush_buffer()
2303 if (mgsl_paranoia_check(info, tty->name, "mgsl_flush_buffer")) mgsl_flush_buffer()
2311 tty_wakeup(tty); mgsl_flush_buffer()
2318 * Arguments: tty pointer to tty info structure
2322 static void mgsl_send_xchar(struct tty_struct *tty, char ch) mgsl_send_xchar() argument
2324 struct mgsl_struct *info = tty->driver_data; mgsl_send_xchar()
2331 if (mgsl_paranoia_check(info, tty->name, "mgsl_send_xchar")) mgsl_send_xchar()
2348 * Arguments: tty pointer to tty info structure
2351 static void mgsl_throttle(struct tty_struct * tty) mgsl_throttle() argument
2353 struct mgsl_struct *info = tty->driver_data; mgsl_throttle()
2360 if (mgsl_paranoia_check(info, tty->name, "mgsl_throttle")) mgsl_throttle()
2363 if (I_IXOFF(tty)) mgsl_throttle()
2364 mgsl_send_xchar(tty, STOP_CHAR(tty)); mgsl_throttle()
2366 if (tty->termios.c_cflag & CRTSCTS) { mgsl_throttle()
2378 * Arguments: tty pointer to tty info structure
2381 static void mgsl_unthrottle(struct tty_struct * tty) mgsl_unthrottle() argument
2383 struct mgsl_struct *info = tty->driver_data; mgsl_unthrottle()
2390 if (mgsl_paranoia_check(info, tty->name, "mgsl_unthrottle")) mgsl_unthrottle()
2393 if (I_IXOFF(tty)) { mgsl_unthrottle()
2397 mgsl_send_xchar(tty, START_CHAR(tty)); mgsl_unthrottle()
2400 if (tty->termios.c_cflag & CRTSCTS) { mgsl_unthrottle()
2840 static int tiocmget(struct tty_struct *tty) tiocmget() argument
2842 struct mgsl_struct *info = tty->driver_data; tiocmget()
2865 static int tiocmset(struct tty_struct *tty, tiocmset() argument
2868 struct mgsl_struct *info = tty->driver_data; tiocmset()
2893 * Arguments: tty pointer to tty instance data
2897 static int mgsl_break(struct tty_struct *tty, int break_state) mgsl_break() argument
2899 struct mgsl_struct * info = tty->driver_data; mgsl_break()
2906 if (mgsl_paranoia_check(info, tty->name, "mgsl_break")) mgsl_break()
2925 static int msgl_get_icount(struct tty_struct *tty, msgl_get_icount() argument
2929 struct mgsl_struct * info = tty->driver_data; msgl_get_icount()
2955 * tty pointer to tty instance data
2961 static int mgsl_ioctl(struct tty_struct *tty, mgsl_ioctl() argument
2964 struct mgsl_struct * info = tty->driver_data; mgsl_ioctl()
2970 if (mgsl_paranoia_check(info, tty->name, "mgsl_ioctl")) mgsl_ioctl()
2975 if (tty->flags & (1 << TTY_IO_ERROR)) mgsl_ioctl()
3025 * tty pointer to tty structure
3030 static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termios) mgsl_set_termios() argument
3032 struct mgsl_struct *info = tty->driver_data; mgsl_set_termios()
3037 tty->driver->name ); mgsl_set_termios()
3043 !(tty->termios.c_cflag & CBAUD)) { mgsl_set_termios()
3052 tty->termios.c_cflag & CBAUD) { mgsl_set_termios()
3054 if (!(tty->termios.c_cflag & CRTSCTS) || mgsl_set_termios()
3055 !test_bit(TTY_THROTTLED, &tty->flags)) { mgsl_set_termios()
3065 !(tty->termios.c_cflag & CRTSCTS)) { mgsl_set_termios()
3066 tty->hw_stopped = 0; mgsl_set_termios()
3067 mgsl_start(tty); mgsl_set_termios()
3079 * tty pointer to open tty structure
3084 static void mgsl_close(struct tty_struct *tty, struct file * filp) mgsl_close() argument
3086 struct mgsl_struct * info = tty->driver_data; mgsl_close()
3088 if (mgsl_paranoia_check(info, tty->name, "mgsl_close")) mgsl_close()
3095 if (tty_port_close_start(&info->port, tty, filp) == 0) mgsl_close()
3100 mgsl_wait_until_sent(tty, info->timeout); mgsl_close()
3101 mgsl_flush_buffer(tty); mgsl_close()
3102 tty_ldisc_flush(tty); mgsl_close()
3106 tty_port_close_end(&info->port, tty); mgsl_close()
3107 info->port.tty = NULL; mgsl_close()
3111 tty->driver->name, info->port.count); mgsl_close()
3121 * tty pointer to tty info structure
3126 static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout) mgsl_wait_until_sent() argument
3128 struct mgsl_struct * info = tty->driver_data; mgsl_wait_until_sent()
3138 if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent")) mgsl_wait_until_sent()
3194 * Arguments: tty pointer to associated tty object
3197 static void mgsl_hangup(struct tty_struct *tty) mgsl_hangup() argument
3199 struct mgsl_struct * info = tty->driver_data; mgsl_hangup()
3205 if (mgsl_paranoia_check(info, tty->name, "mgsl_hangup")) mgsl_hangup()
3208 mgsl_flush_buffer(tty); mgsl_hangup()
3213 info->port.tty = NULL; mgsl_hangup()
3258 * tty pointer to tty info structure
3264 static int block_til_ready(struct tty_struct *tty, struct file * filp, block_til_ready() argument
3276 __FILE__,__LINE__, tty->driver->name ); block_til_ready()
3278 if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ block_til_ready()
3284 if (tty->termios.c_cflag & CLOCAL) block_til_ready()
3299 __FILE__,__LINE__, tty->driver->name, port->count ); block_til_ready()
3307 if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) block_til_ready()
3330 __FILE__,__LINE__, tty->driver->name, port->count ); block_til_ready()
3332 tty_unlock(tty); block_til_ready()
3334 tty_lock(tty); block_til_ready()
3347 __FILE__,__LINE__, tty->driver->name, port->count ); block_til_ready()
3356 static int mgsl_install(struct tty_driver *driver, struct tty_struct *tty) mgsl_install() argument
3359 int line = tty->index; mgsl_install()
3372 if (mgsl_paranoia_check(info, tty->name, "mgsl_open")) mgsl_install()
3374 tty->driver_data = info; mgsl_install()
3376 return tty_port_install(&info->port, driver, tty); mgsl_install()
3382 * Perform serial-specific initialization for the tty structure.
3384 * Arguments: tty pointer to tty info structure
3389 static int mgsl_open(struct tty_struct *tty, struct file * filp) mgsl_open() argument
3391 struct mgsl_struct *info = tty->driver_data; mgsl_open()
3395 info->port.tty = tty; mgsl_open()
3399 __FILE__,__LINE__,tty->driver->name, info->port.count); mgsl_open()
3403 wait_event_interruptible_tty(tty, info->port.close_wait, mgsl_open()
3428 retval = block_til_ready(tty, filp, info); mgsl_open()
3443 if (tty->count == 1) mgsl_open()
3444 info->port.tty = NULL; /* tty layer will release tty struct */ mgsl_open()
4332 * perform tty device initialization
4363 printk("%s %s, tty major#%d\n", mgsl_init_tty()
4414 printk("%s(%d) failed to unregister tty driver err=%d\n", synclink_cleanup()
6529 struct tty_struct *tty = info->port.tty; mgsl_get_rx_frame() local
6672 ldisc_receive_buf(tty, info->intermediate_rxbuffer, info->flag_buf, framesize); mgsl_get_rx_frame()
6727 struct tty_struct *tty = info->port.tty; mgsl_get_raw_rx_frame() local
6844 ldisc_receive_buf(tty, info->intermediate_rxbuffer, info->flag_buf, framesize); mgsl_get_raw_rx_frame()
7757 /* arbitrate between network and tty opens */ hdlcdev_open()
H A Dehv_bytechan.c22 * 3) A tty driver, which is used to handle user-space input and output. The
23 * byte channel used for the console is designated as the default tty.
39 #include <linux/tty.h>
85 * 1. The tty layer makes two back-to-back calls to ehv_bc_tty_write()
296 * stdout/stdin, even though that information is used by the tty and character
369 /* Pass the received data to the tty layer. */ ehv_bc_tty_rx_isr()
384 /* Tell the tty layer that we're done. */ ehv_bc_tty_rx_isr()
448 * This function is called when the tty layer has data for us send. We store
453 * all the data. The purpose of ehv_bc_tty_write_room() is to tell the tty
455 * ehv_bc_tty_write_room() will never lie, so the tty layer will never send us
493 * The tty layer will still call this function even if the device was not
509 * Amazingly, if ehv_bc_tty_open() returns an error code, the tty layer will
510 * still call this function to close the tty device. So we can't assume that
511 * the tty port has been initialized.
524 * This is actually a contract between the driver and the tty layer outlining
542 * Stop sending data to the tty layer
544 * This function is called when the tty layer's input buffers are getting full,
561 * Resume sending data to the tty layer
564 * tty layer's input buffers now have more room, so the driver can resume
702 dev_err(&pdev->dev, "could not register tty (ret=%i)\n", ret); ehv_bc_tty_probe()
769 /* The array index of an element in bcs[] is the same as the tty index ehv_bc_init()
772 * tty index. ehv_bc_init()
794 pr_err("ehv-bc: could not register tty driver (ret=%i)\n", ret); ehv_bc_init()
/linux-4.1.27/net/irda/ircomm/
H A DMakefile5 obj-$(CONFIG_IRCOMM) += ircomm.o ircomm-tty.o
8 ircomm-tty-y := ircomm_tty.o ircomm_tty_attach.o ircomm_tty_ioctl.o ircomm_param.o
H A Dircomm_tty.c38 #include <linux/tty.h>
54 struct tty_struct *tty);
55 static int ircomm_tty_open(struct tty_struct *tty, struct file *filp);
56 static void ircomm_tty_close(struct tty_struct * tty, struct file *filp);
57 static int ircomm_tty_write(struct tty_struct * tty,
59 static int ircomm_tty_write_room(struct tty_struct *tty);
60 static void ircomm_tty_throttle(struct tty_struct *tty);
61 static void ircomm_tty_unthrottle(struct tty_struct *tty);
62 static int ircomm_tty_chars_in_buffer(struct tty_struct *tty);
63 static void ircomm_tty_flush_buffer(struct tty_struct *tty);
64 static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch);
65 static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout);
66 static void ircomm_tty_hangup(struct tty_struct *tty);
69 static void ircomm_tty_stop(struct tty_struct *tty);
271 struct tty_struct *tty, struct file *filp) ircomm_tty_block_til_ready()
283 if (test_bit(TTY_IO_ERROR, &tty->flags)) { ircomm_tty_block_til_ready()
290 if (tty->termios.c_cflag & CBAUD) ircomm_tty_block_til_ready()
297 if (tty->termios.c_cflag & CLOCAL) { ircomm_tty_block_til_ready()
313 __FILE__, __LINE__, tty->driver->name, port->count); ircomm_tty_block_til_ready()
321 if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) ircomm_tty_block_til_ready()
351 __FILE__, __LINE__, tty->driver->name, port->count); ircomm_tty_block_til_ready()
366 __FILE__, __LINE__, tty->driver->name, port->count); ircomm_tty_block_til_ready()
375 static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty) ircomm_tty_install() argument
378 unsigned int line = tty->index; ircomm_tty_install()
409 tty->termios.c_iflag = 0; ircomm_tty_install()
410 tty->termios.c_oflag = 0; ircomm_tty_install()
416 tty->driver_data = self; ircomm_tty_install()
418 return tty_port_install(&self->port, driver, tty); ircomm_tty_install()
422 * Function ircomm_tty_open (tty, filp)
424 * This routine is called when a particular tty device is opened. This
428 static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) ircomm_tty_open() argument
430 struct ircomm_tty_cb *self = tty->driver_data; ircomm_tty_open()
438 tty_port_tty_set(&self->port, tty); ircomm_tty_open()
440 pr_debug("%s(), %s%d, count = %d\n", __func__ , tty->driver->name, ircomm_tty_open()
491 ret = ircomm_tty_block_til_ready(self, tty, filp); ircomm_tty_open()
502 * Function ircomm_tty_close (tty, filp)
504 * This routine is called when a particular tty device is closed.
507 static void ircomm_tty_close(struct tty_struct *tty, struct file *filp) ircomm_tty_close() argument
509 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_close()
515 if (tty_port_close_start(port, tty, filp) == 0) ircomm_tty_close()
520 tty_driver_flush_buffer(tty); ircomm_tty_close()
522 tty_port_close_end(port, tty); ircomm_tty_close()
527 * Function ircomm_tty_flush_buffer (tty)
532 static void ircomm_tty_flush_buffer(struct tty_struct *tty) ircomm_tty_flush_buffer() argument
534 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_flush_buffer()
557 struct tty_struct *tty; ircomm_tty_do_softint() local
564 tty = tty_port_tty_get(&self->port); ircomm_tty_do_softint()
565 if (!tty) ircomm_tty_do_softint()
584 if (tty->hw_stopped) ircomm_tty_do_softint()
603 tty_wakeup(tty); ircomm_tty_do_softint()
605 tty_kref_put(tty); ircomm_tty_do_softint()
609 * Function ircomm_tty_write (tty, buf, count)
612 * to the tty device. The characters may come from user space or kernel
616 static int ircomm_tty_write(struct tty_struct *tty, ircomm_tty_write() argument
619 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_write()
627 tty->hw_stopped); ircomm_tty_write()
743 * Function ircomm_tty_write_room (tty)
745 * This routine returns the numbers of characters the tty driver will
749 static int ircomm_tty_write_room(struct tty_struct *tty) ircomm_tty_write_room() argument
751 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_write_room()
768 if (tty->hw_stopped) ircomm_tty_write_room()
784 * Function ircomm_tty_wait_until_sent (tty, timeout)
789 static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout) ircomm_tty_wait_until_sent() argument
791 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_wait_until_sent()
820 * Function ircomm_tty_throttle (tty)
822 * This routine notifies the tty driver that input buffers for the line
824 * more characters should be sent to the tty.
826 static void ircomm_tty_throttle(struct tty_struct *tty) ircomm_tty_throttle() argument
828 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_throttle()
834 if (I_IXOFF(tty)) ircomm_tty_throttle()
835 ircomm_tty_send_xchar(tty, STOP_CHAR(tty)); ircomm_tty_throttle()
838 if (tty->termios.c_cflag & CRTSCTS) { ircomm_tty_throttle()
849 * Function ircomm_tty_unthrottle (tty)
851 * This routine notifies the tty drivers that it should signals that
852 * characters can now be sent to the tty without fear of overrunning the
855 static void ircomm_tty_unthrottle(struct tty_struct *tty) ircomm_tty_unthrottle() argument
857 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_unthrottle()
863 if (I_IXOFF(tty)) { ircomm_tty_unthrottle()
864 ircomm_tty_send_xchar(tty, START_CHAR(tty)); ircomm_tty_unthrottle()
868 if (tty->termios.c_cflag & CRTSCTS) { ircomm_tty_unthrottle()
878 * Function ircomm_tty_chars_in_buffer (tty)
883 static int ircomm_tty_chars_in_buffer(struct tty_struct *tty) ircomm_tty_chars_in_buffer() argument
885 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_chars_in_buffer()
939 * Function ircomm_tty_hangup (tty)
941 * This routine notifies the tty driver that it should hangup the tty
945 static void ircomm_tty_hangup(struct tty_struct *tty) ircomm_tty_hangup() argument
947 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_hangup()
954 /* ircomm_tty_flush_buffer(tty); */ ircomm_tty_hangup()
959 if (port->tty) { ircomm_tty_hangup()
960 set_bit(TTY_IO_ERROR, &port->tty->flags); ircomm_tty_hangup()
961 tty_kref_put(port->tty); ircomm_tty_hangup()
963 port->tty = NULL; ircomm_tty_hangup()
971 * Function ircomm_tty_send_xchar (tty, ch)
976 static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch) ircomm_tty_send_xchar() argument
982 * Function ircomm_tty_start (tty)
984 * This routine notifies the tty driver that it resume sending
985 * characters to the tty device.
987 void ircomm_tty_start(struct tty_struct *tty) ircomm_tty_start() argument
989 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_start()
995 * Function ircomm_tty_stop (tty)
997 * This routine notifies the tty driver that it should stop outputting
998 * characters to the tty device.
1000 static void ircomm_tty_stop(struct tty_struct *tty) ircomm_tty_stop() argument
1002 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_stop()
1019 struct tty_struct *tty; ircomm_tty_check_modem_status() local
1025 tty = tty_port_tty_get(&self->port); ircomm_tty_check_modem_status()
1040 if (tty) ircomm_tty_check_modem_status()
1041 tty_hangup(tty); ircomm_tty_check_modem_status()
1043 /* Hangup will remote the tty, so better break out */ ircomm_tty_check_modem_status()
1047 if (tty && tty_port_cts_enabled(&self->port)) { ircomm_tty_check_modem_status()
1048 if (tty->hw_stopped) { ircomm_tty_check_modem_status()
1051 tty->hw_stopped = 0; ircomm_tty_check_modem_status()
1062 tty->hw_stopped = 1; ircomm_tty_check_modem_status()
1067 tty_kref_put(tty); ircomm_tty_check_modem_status()
1080 struct tty_struct *tty; ircomm_tty_data_indication() local
1086 tty = tty_port_tty_get(&self->port); ircomm_tty_data_indication()
1087 if (!tty) { ircomm_tty_data_indication()
1088 pr_debug("%s(), no tty!\n", __func__); ircomm_tty_data_indication()
1098 if (tty->hw_stopped && (self->flow == FLOW_START)) { ircomm_tty_data_indication()
1106 tty_kref_put(tty); ircomm_tty_data_indication()
1157 struct tty_struct *tty; ircomm_tty_flow_indication() local
1162 tty = tty_port_tty_get(&self->port); ircomm_tty_flow_indication()
1167 if (tty) ircomm_tty_flow_indication()
1168 tty->hw_stopped = 0; ircomm_tty_flow_indication()
1176 if (tty) ircomm_tty_flow_indication()
1177 tty->hw_stopped = 1; ircomm_tty_flow_indication()
1181 tty_kref_put(tty); ircomm_tty_flow_indication()
1188 struct tty_struct *tty; ircomm_tty_line_info() local
1315 tty = tty_port_tty_get(&self->port); ircomm_tty_line_info()
1316 if (tty) { ircomm_tty_line_info()
1318 tty->hw_stopped ? "Stopped" : "Running"); ircomm_tty_line_info()
1319 tty_kref_put(tty); ircomm_tty_line_info()
270 ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, struct tty_struct *tty, struct file *filp) ircomm_tty_block_til_ready() argument
H A Dircomm_tty_ioctl.c32 #include <linux/tty.h>
54 struct tty_struct *tty) ircomm_tty_change_speed()
62 cflag = tty->termios.c_cflag; ircomm_tty_change_speed()
81 baud = tty_get_baud_rate(tty); ircomm_tty_change_speed()
109 if (I_INPCK(self->tty)) ircomm_tty_change_speed()
111 if (I_BRKINT(driver->tty) || I_PARMRK(driver->tty)) ircomm_tty_change_speed()
118 if (I_IGNPAR(driver->tty)) ircomm_tty_change_speed()
121 if (I_IGNBRK(self->tty)) { ircomm_tty_change_speed()
127 if (I_IGNPAR(self->tty)) ircomm_tty_change_speed()
138 * Function ircomm_tty_set_termios (tty, old_termios)
140 * This routine allows the tty driver to be notified when device's
141 * termios settings have changed. Note that a well-designed tty driver
145 void ircomm_tty_set_termios(struct tty_struct *tty, ircomm_tty_set_termios() argument
148 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_set_termios()
149 unsigned int cflag = tty->termios.c_cflag; ircomm_tty_set_termios()
152 (RELEVANT_IFLAG(tty->termios.c_iflag) == ircomm_tty_set_termios()
158 ircomm_tty_change_speed(self, tty); ircomm_tty_set_termios()
171 if (!(tty->termios.c_cflag & CRTSCTS) || ircomm_tty_set_termios()
172 !test_bit(TTY_THROTTLED, &tty->flags)) { ircomm_tty_set_termios()
180 !(tty->termios.c_cflag & CRTSCTS)) ircomm_tty_set_termios()
182 tty->hw_stopped = 0; ircomm_tty_set_termios()
183 ircomm_tty_start(tty); ircomm_tty_set_termios()
188 * Function ircomm_tty_tiocmget (tty)
193 int ircomm_tty_tiocmget(struct tty_struct *tty) ircomm_tty_tiocmget() argument
195 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_tiocmget()
198 if (tty->flags & (1 << TTY_IO_ERROR)) ircomm_tty_tiocmget()
211 * Function ircomm_tty_tiocmset (tty, set, clear)
216 int ircomm_tty_tiocmset(struct tty_struct *tty, ircomm_tty_tiocmset() argument
219 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_tiocmset()
221 if (tty->flags & (1 << TTY_IO_ERROR)) ircomm_tty_tiocmset()
332 self->tty->low_latency = (self->flags & ASYNC_LOW_LATENCY) ? 1 : 0; ircomm_tty_set_serial_info()
341 driver->tty->alt_speed = 57600; ircomm_tty_set_serial_info()
343 driver->tty->alt_speed = 115200; ircomm_tty_set_serial_info()
345 driver->tty->alt_speed = 230400; ircomm_tty_set_serial_info()
347 driver->tty->alt_speed = 460800; ircomm_tty_set_serial_info()
356 * Function ircomm_tty_ioctl (tty, cmd, arg)
361 int ircomm_tty_ioctl(struct tty_struct *tty, ircomm_tty_ioctl() argument
364 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; ircomm_tty_ioctl()
370 if (tty->flags & (1 << TTY_IO_ERROR)) ircomm_tty_ioctl()
53 ircomm_tty_change_speed(struct ircomm_tty_cb *self, struct tty_struct *tty) ircomm_tty_change_speed() argument
H A Dircomm_tty_attach.c129 struct tty_struct *tty; ircomm_tty_attach_cable() local
141 tty = tty_port_tty_get(&self->port); ircomm_tty_attach_cable()
142 if (tty) { ircomm_tty_attach_cable()
143 tty->hw_stopped = 1; ircomm_tty_attach_cable()
144 tty_kref_put(tty); ircomm_tty_attach_cable()
395 struct tty_struct *tty; ircomm_tty_disconnect_indication() local
400 tty = tty_port_tty_get(&self->port); ircomm_tty_disconnect_indication()
401 if (!tty) ircomm_tty_disconnect_indication()
408 tty->hw_stopped = 1; ircomm_tty_disconnect_indication()
412 tty_kref_put(tty); ircomm_tty_disconnect_indication()
542 struct tty_struct *tty; ircomm_tty_link_established() local
547 tty = tty_port_tty_get(&self->port); ircomm_tty_link_established()
548 if (!tty) ircomm_tty_link_established()
566 tty->hw_stopped = 0; ircomm_tty_link_established()
574 tty_kref_put(tty); ircomm_tty_link_established()
/linux-4.1.27/include/linux/
H A Dtty.h12 #include <uapi/linux/tty.h>
18 * Lock subclasses for tty locks
24 * tty locks which use nested locking:
26 * legacy_mutex - Nested tty locks are necessary for releasing pty pairs.
104 #define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])
105 #define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])
106 #define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])
107 #define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])
108 #define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])
109 #define TIME_CHAR(tty) ((tty)->termios.c_cc[VTIME])
110 #define MIN_CHAR(tty) ((tty)->termios.c_cc[VMIN])
111 #define SWTC_CHAR(tty) ((tty)->termios.c_cc[VSWTC])
112 #define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])
113 #define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])
114 #define SUSP_CHAR(tty) ((tty)->termios.c_cc[VSUSP])
115 #define EOL_CHAR(tty) ((tty)->termios.c_cc[VEOL])
116 #define REPRINT_CHAR(tty) ((tty)->termios.c_cc[VREPRINT])
117 #define DISCARD_CHAR(tty) ((tty)->termios.c_cc[VDISCARD])
118 #define WERASE_CHAR(tty) ((tty)->termios.c_cc[VWERASE])
119 #define LNEXT_CHAR(tty) ((tty)->termios.c_cc[VLNEXT])
120 #define EOL2_CHAR(tty) ((tty)->termios.c_cc[VEOL2])
122 #define _I_FLAG(tty, f) ((tty)->termios.c_iflag & (f))
123 #define _O_FLAG(tty, f) ((tty)->termios.c_oflag & (f))
124 #define _C_FLAG(tty, f) ((tty)->termios.c_cflag & (f))
125 #define _L_FLAG(tty, f) ((tty)->termios.c_lflag & (f))
127 #define I_IGNBRK(tty) _I_FLAG((tty), IGNBRK)
128 #define I_BRKINT(tty) _I_FLAG((tty), BRKINT)
129 #define I_IGNPAR(tty) _I_FLAG((tty), IGNPAR)
130 #define I_PARMRK(tty) _I_FLAG((tty), PARMRK)
131 #define I_INPCK(tty) _I_FLAG((tty), INPCK)
132 #define I_ISTRIP(tty) _I_FLAG((tty), ISTRIP)
133 #define I_INLCR(tty) _I_FLAG((tty), INLCR)
134 #define I_IGNCR(tty) _I_FLAG((tty), IGNCR)
135 #define I_ICRNL(tty) _I_FLAG((tty), ICRNL)
136 #define I_IUCLC(tty) _I_FLAG((tty), IUCLC)
137 #define I_IXON(tty) _I_FLAG((tty), IXON)
138 #define I_IXANY(tty) _I_FLAG((tty), IXANY)
139 #define I_IXOFF(tty) _I_FLAG((tty), IXOFF)
140 #define I_IMAXBEL(tty) _I_FLAG((tty), IMAXBEL)
141 #define I_IUTF8(tty) _I_FLAG((tty), IUTF8)
143 #define O_OPOST(tty) _O_FLAG((tty), OPOST)
144 #define O_OLCUC(tty) _O_FLAG((tty), OLCUC)
145 #define O_ONLCR(tty) _O_FLAG((tty), ONLCR)
146 #define O_OCRNL(tty) _O_FLAG((tty), OCRNL)
147 #define O_ONOCR(tty) _O_FLAG((tty), ONOCR)
148 #define O_ONLRET(tty) _O_FLAG((tty), ONLRET)
149 #define O_OFILL(tty) _O_FLAG((tty), OFILL)
150 #define O_OFDEL(tty) _O_FLAG((tty), OFDEL)
151 #define O_NLDLY(tty) _O_FLAG((tty), NLDLY)
152 #define O_CRDLY(tty) _O_FLAG((tty), CRDLY)
153 #define O_TABDLY(tty) _O_FLAG((tty), TABDLY)
154 #define O_BSDLY(tty) _O_FLAG((tty), BSDLY)
155 #define O_VTDLY(tty) _O_FLAG((tty), VTDLY)
156 #define O_FFDLY(tty) _O_FLAG((tty), FFDLY)
158 #define C_BAUD(tty) _C_FLAG((tty), CBAUD)
159 #define C_CSIZE(tty) _C_FLAG((tty), CSIZE)
160 #define C_CSTOPB(tty) _C_FLAG((tty), CSTOPB)
161 #define C_CREAD(tty) _C_FLAG((tty), CREAD)
162 #define C_PARENB(tty) _C_FLAG((tty), PARENB)
163 #define C_PARODD(tty) _C_FLAG((tty), PARODD)
164 #define C_HUPCL(tty) _C_FLAG((tty), HUPCL)
165 #define C_CLOCAL(tty) _C_FLAG((tty), CLOCAL)
166 #define C_CIBAUD(tty) _C_FLAG((tty), CIBAUD)
167 #define C_CRTSCTS(tty) _C_FLAG((tty), CRTSCTS)
168 #define C_CMSPAR(tty) _C_FLAG((tty), CMSPAR)
170 #define L_ISIG(tty) _L_FLAG((tty), ISIG)
171 #define L_ICANON(tty) _L_FLAG((tty), ICANON)
172 #define L_XCASE(tty) _L_FLAG((tty), XCASE)
173 #define L_ECHO(tty) _L_FLAG((tty), ECHO)
174 #define L_ECHOE(tty) _L_FLAG((tty), ECHOE)
175 #define L_ECHOK(tty) _L_FLAG((tty), ECHOK)
176 #define L_ECHONL(tty) _L_FLAG((tty), ECHONL)
177 #define L_NOFLSH(tty) _L_FLAG((tty), NOFLSH)
178 #define L_TOSTOP(tty) _L_FLAG((tty), TOSTOP)
179 #define L_ECHOCTL(tty) _L_FLAG((tty), ECHOCTL)
180 #define L_ECHOPRT(tty) _L_FLAG((tty), ECHOPRT)
181 #define L_ECHOKE(tty) _L_FLAG((tty), ECHOKE)
182 #define L_FLUSHO(tty) _L_FLAG((tty), FLUSHO)
183 #define L_PENDIN(tty) _L_FLAG((tty), PENDIN)
184 #define L_IEXTEN(tty) _L_FLAG((tty), IEXTEN)
185 #define L_EXTPROC(tty) _L_FLAG((tty), EXTPROC)
195 * The tty port has a different lifetime to the tty so must be kept apart.
196 * In addition be careful as tty -> port mappings are valid for the life
197 * of the tty object but in many cases port -> tty mappings are valid only
214 /* FIXME: long term getting the tty argument *out* of this would be
216 int (*activate)(struct tty_port *port, struct tty_struct *tty);
223 struct tty_struct *tty; /* Back pointer */ member in struct:tty_port
226 spinlock_t lock; /* Lock protecting tty field */
247 * Where all of the state associated with a tty is kept while the tty
248 * is open. Since the termios state should be kept even if the tty
268 /* Protects ldisc changes: Lock tty not pty */
313 /* If the tty has a pending do_SAK, queue it here - akpm */
318 /* Each of a tty's open files has private_data pointing to tty_file_private */
320 struct tty_struct *tty; member in struct:tty_file_private
325 /* tty magic number */
329 * These bits are used in the flags field of the tty structure.
333 * tty->write. Thus, you must use the inline functions set_bit() and
348 #define TTY_WRITE_FLUSH(tty) tty_write_flush((tty))
350 /* Values for tty->flow_change */
354 static inline void __tty_set_flow_change(struct tty_struct *tty, int val) __tty_set_flow_change() argument
356 tty->flow_change = val; __tty_set_flow_change()
359 static inline void tty_set_flow_change(struct tty_struct *tty, int val) tty_set_flow_change() argument
361 tty->flow_change = val; tty_set_flow_change()
367 extern void tty_kref_put(struct tty_struct *tty);
368 extern struct pid *tty_get_pgrp(struct tty_struct *tty);
371 extern dev_t tty_devnum(struct tty_struct *tty);
379 static inline void tty_kref_put(struct tty_struct *tty) tty_kref_put() argument
381 static inline struct pid *tty_get_pgrp(struct tty_struct *tty) tty_get_pgrp() argument
387 static inline dev_t tty_devnum(struct tty_struct *tty) tty_devnum() argument
407 * tty_kref_get - get a tty reference
408 * @tty: tty device
410 * Return a new reference to a tty object. The caller must hold
415 static inline struct tty_struct *tty_kref_get(struct tty_struct *tty) tty_kref_get() argument
417 if (tty) tty_kref_get()
418 kref_get(&tty->kref); tty_kref_get()
419 return tty; tty_kref_get()
422 extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
424 extern char *tty_name(struct tty_struct *tty, char *buf);
425 extern void tty_wait_until_sent(struct tty_struct *tty, long timeout);
426 extern int tty_check_change(struct tty_struct *tty);
427 extern void __stop_tty(struct tty_struct *tty);
428 extern void stop_tty(struct tty_struct *tty);
429 extern void __start_tty(struct tty_struct *tty);
430 extern void start_tty(struct tty_struct *tty);
440 extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
442 extern void tty_write_message(struct tty_struct *tty, char *msg);
443 extern int tty_send_xchar(struct tty_struct *tty, char ch);
444 extern int tty_put_char(struct tty_struct *tty, unsigned char c);
445 extern int tty_chars_in_buffer(struct tty_struct *tty);
446 extern int tty_write_room(struct tty_struct *tty);
447 extern void tty_driver_flush_buffer(struct tty_struct *tty);
448 extern void tty_throttle(struct tty_struct *tty);
449 extern void tty_unthrottle(struct tty_struct *tty);
450 extern int tty_throttle_safe(struct tty_struct *tty);
451 extern int tty_unthrottle_safe(struct tty_struct *tty);
452 extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws);
454 struct tty_struct *tty);
455 extern void tty_free_termios(struct tty_struct *tty);
458 extern int tty_signal(int sig, struct tty_struct *tty);
459 extern void tty_hangup(struct tty_struct *tty);
460 extern void tty_vhangup(struct tty_struct *tty);
462 extern void do_SAK(struct tty_struct *tty);
463 extern void __do_SAK(struct tty_struct *tty);
466 extern void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld);
474 extern void tty_encode_baud_rate(struct tty_struct *tty,
478 * tty_get_baud_rate - get tty bit rates
479 * @tty: tty to query
487 static inline speed_t tty_get_baud_rate(struct tty_struct *tty) tty_get_baud_rate() argument
489 return tty_termios_baud_rate(&tty->termios); tty_get_baud_rate()
494 extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);
499 extern void tty_ldisc_hangup(struct tty_struct *tty);
502 extern void tty_wakeup(struct tty_struct *tty);
503 extern void tty_ldisc_flush(struct tty_struct *tty);
506 extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
508 extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
512 extern void tty_add_file(struct tty_struct *tty, struct file *file);
514 extern void free_tty_struct(struct tty_struct *tty);
515 extern void deinitialize_tty_struct(struct tty_struct *tty);
518 extern int tty_init_termios(struct tty_struct *tty);
520 struct tty_struct *tty);
525 #define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock))
556 extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
564 struct tty_struct *tty, struct file *filp);
566 struct tty_struct *tty, struct file *filp);
567 extern void tty_port_close_end(struct tty_port *port, struct tty_struct *tty);
569 struct tty_struct *tty, struct file *filp);
571 struct tty_struct *tty);
573 struct tty_struct *tty, struct file *filp); tty_port_users()
581 extern int tty_set_ldisc(struct tty_struct *tty, int ldisc);
582 extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
583 extern void tty_ldisc_release(struct tty_struct *tty);
584 extern void tty_ldisc_init(struct tty_struct *tty);
585 extern void tty_ldisc_deinit(struct tty_struct *tty);
592 count = ld->ops->receive_buf2(ld->tty, p, f, count); tty_ldisc_receive_buf()
594 count = min_t(int, count, ld->tty->receive_room); tty_ldisc_receive_buf()
596 ld->ops->receive_buf(ld->tty, p, f, count); tty_ldisc_receive_buf()
608 extern void tty_audit_add_data(struct tty_struct *tty, const void *data,
612 extern void tty_audit_tiocsti(struct tty_struct *tty, char ch);
613 extern void tty_audit_push(struct tty_struct *tty);
616 static inline void tty_audit_add_data(struct tty_struct *tty, const void *data, tty_audit_add_data() argument
620 static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch) tty_audit_tiocsti() argument
629 static inline void tty_audit_push(struct tty_struct *tty) tty_audit_push() argument
639 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
641 extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
646 extern int vt_ioctl(struct tty_struct *tty,
649 extern long vt_compat_ioctl(struct tty_struct *tty,
654 extern void __lockfunc tty_lock(struct tty_struct *tty);
655 extern void __lockfunc tty_unlock(struct tty_struct *tty);
656 extern void __lockfunc tty_lock_slave(struct tty_struct *tty);
657 extern void __lockfunc tty_unlock_slave(struct tty_struct *tty);
658 extern void tty_set_lock_subclass(struct tty_struct *tty);
669 static inline void tty_wait_until_sent_from_close(struct tty_struct *tty, tty_wait_until_sent_from_close() argument
672 tty_unlock(tty); /* tty->ops->close holds the BTM, drop it while waiting */ tty_wait_until_sent_from_close()
673 tty_wait_until_sent(tty, timeout); tty_wait_until_sent_from_close()
674 tty_lock(tty); tty_wait_until_sent_from_close()
678 * wait_event_interruptible_tty -- wait for a condition with the tty lock held
689 #define wait_event_interruptible_tty(tty, wq, condition) \
693 __ret = __wait_event_interruptible_tty(tty, wq, \
698 #define __wait_event_interruptible_tty(tty, wq, condition) \
700 tty_unlock(tty); \
702 tty_lock(tty))
H A Dtty_driver.h5 * This structure defines the interface between the low-level tty
6 * driver and the tty routines. The following routines can be
12 * Return the tty device corresponding to idx, NULL if there is not
18 * int (*install)(struct tty_driver *self, struct tty_struct *tty)
20 * Install a new tty into the tty driver internal tables. Used in
25 * void (*remove)(struct tty_driver *self, struct tty_struct *tty)
27 * Remove a closed tty from the tty driver internal tables. Used in
32 * int (*open)(struct tty_struct * tty, struct file * filp);
34 * This routine is called when a particular tty device is opened.
38 * Required method. Called with tty lock held.
40 * void (*close)(struct tty_struct * tty, struct file * filp);
42 * This routine is called when a particular tty device is closed.
45 * Required method. Called with tty lock held.
47 * void (*shutdown)(struct tty_struct * tty);
49 * This routine is called under the tty lock when a particular tty device
50 * is closed for the last time. It executes before the tty resources
51 * are freed so may execute while another function holds a tty kref.
53 * void (*cleanup)(struct tty_struct * tty);
55 * This routine is called asynchronously when a particular tty device
60 * int (*write)(struct tty_struct * tty,
64 * characters to the tty device. The characters may come from
70 * int (*put_char)(struct tty_struct *tty, unsigned char ch);
73 * character to the tty device. If the kernel uses this routine,
82 * void (*flush_chars)(struct tty_struct *tty);
85 * series of characters to the tty device using put_char().
91 * int (*write_room)(struct tty_struct *tty);
93 * This routine returns the numbers of characters the tty driver
102 * int (*ioctl)(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
104 * This routine allows the tty driver to implement
110 * long (*compat_ioctl)(struct tty_struct *tty,,
117 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
119 * This routine allows the tty driver to be notified when
125 * void (*set_ldisc)(struct tty_struct *tty);
127 * This routine allows the tty driver to be notified when the
132 * void (*throttle)(struct tty_struct * tty);
134 * This routine notifies the tty driver that input buffers for
136 * signal that no more characters should be sent to the tty.
141 * void (*unthrottle)(struct tty_struct * tty);
143 * This routine notifies the tty drivers that it should signals
144 * that characters can now be sent to the tty without fear of
150 * void (*stop)(struct tty_struct *tty);
152 * This routine notifies the tty driver that it should stop
153 * outputting characters to the tty device.
161 * void (*start)(struct tty_struct *tty);
163 * This routine notifies the tty driver that it resume sending
164 * characters to the tty device.
172 * void (*hangup)(struct tty_struct *tty);
174 * This routine notifies the tty driver that it should hang up the
175 * tty device.
179 * Called with tty lock held.
181 * int (*break_ctl)(struct tty_struct *tty, int state);
183 * This optional routine requests the tty driver to turn on or
188 * If this routine is implemented, the high-level tty driver will
198 * void (*wait_until_sent)(struct tty_struct *tty, int timeout);
207 * void (*send_xchar)(struct tty_struct *tty, char ch);
215 * int (*resize)(struct tty_struct *tty, struct winsize *ws)
226 * void (*set_termiox)(struct tty_struct *tty, struct termiox *new);
230 * unless the tty also has a valid tty->termiox pointer.
234 * int (*get_icount)(struct tty_struct *tty, struct serial_icounter *icount);
254 int (*install)(struct tty_driver *driver, struct tty_struct *tty);
255 void (*remove)(struct tty_driver *driver, struct tty_struct *tty);
256 int (*open)(struct tty_struct * tty, struct file * filp);
257 void (*close)(struct tty_struct * tty, struct file * filp);
258 void (*shutdown)(struct tty_struct *tty);
259 void (*cleanup)(struct tty_struct *tty);
260 int (*write)(struct tty_struct * tty,
262 int (*put_char)(struct tty_struct *tty, unsigned char ch);
263 void (*flush_chars)(struct tty_struct *tty);
264 int (*write_room)(struct tty_struct *tty);
265 int (*chars_in_buffer)(struct tty_struct *tty);
266 int (*ioctl)(struct tty_struct *tty,
268 long (*compat_ioctl)(struct tty_struct *tty,
270 void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
271 void (*throttle)(struct tty_struct * tty);
272 void (*unthrottle)(struct tty_struct * tty);
273 void (*stop)(struct tty_struct *tty);
274 void (*start)(struct tty_struct *tty);
275 void (*hangup)(struct tty_struct *tty);
276 int (*break_ctl)(struct tty_struct *tty, int state);
277 void (*flush_buffer)(struct tty_struct *tty);
278 void (*set_ldisc)(struct tty_struct *tty);
279 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
280 void (*send_xchar)(struct tty_struct *tty, char ch);
281 int (*tiocmget)(struct tty_struct *tty);
282 int (*tiocmset)(struct tty_struct *tty,
284 int (*resize)(struct tty_struct *tty, struct winsize *ws);
285 int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew);
286 int (*get_icount)(struct tty_struct *tty,
307 short type; /* type of tty driver */
308 short subtype; /* subtype of tty driver */
310 unsigned long flags; /* tty driver flags */
315 * Pointer to the tty data structures
363 /* tty driver magic number */
367 * tty driver flags
369 * TTY_DRIVER_RESET_TERMIOS --- requests the tty layer to reset the
383 * TTY_DRIVER_DYNAMIC_DEV --- if set, the individual tty devices need
388 * created by the tty core in sysfs when tty_register_driver() is
389 * called. This is to be used by drivers that have tty devices
390 * that can appear and disappear while the main tty driver is
391 * registered with the tty core.
407 * Applicable only when a driver for a single tty device is
419 /* tty driver types */
H A Dtty_ldisc.h5 * This structure defines the interface between the tty line discipline
6 * implementation and the tty routines. The following routines can be
13 * with the tty. The line discipline can use this as an
19 * shutdown, either because the tty is being closed or because
20 * the tty is being changed to use a new line discipline
22 * void (*flush_buffer)(struct tty_struct *tty);
28 * ssize_t (*chars_in_buffer)(struct tty_struct *tty);
34 * ssize_t (*read)(struct tty_struct * tty, struct file * file,
38 * the tty. The line discipline will return whatever characters
42 * ssize_t (*write)(struct tty_struct * tty, struct file * file,
46 * tty. The line discipline will deliver the characters to the
47 * low-level tty device for transmission, optionally performing
51 * int (*ioctl)(struct tty_struct * tty, struct file * file,
55 * is not handled by the tty layer or the low-level tty driver.
57 * operation. Note that the search order for ioctls is (1) tty
58 * layer, (2) tty low-level driver, (3) line discpline. So a
62 * long (*compat_ioctl)(struct tty_struct * tty, struct file * file,
67 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
72 * int (*poll)(struct tty_struct * tty, struct file * file,
76 * tty device. It is solely the responsibility of the line
82 * This function is called by the low-level tty driver to send
92 * This function is called by the low-level tty driver to signal
103 * cease I/O to the tty driver. Can sleep. The driver should
112 * void (*dcd_change)(struct tty_struct *tty, unsigned int status)
120 * This function is called by the low-level tty driver to send
190 void (*flush_buffer)(struct tty_struct *tty);
191 ssize_t (*chars_in_buffer)(struct tty_struct *tty);
192 ssize_t (*read)(struct tty_struct *tty, struct file *file,
194 ssize_t (*write)(struct tty_struct *tty, struct file *file,
196 int (*ioctl)(struct tty_struct *tty, struct file *file,
198 long (*compat_ioctl)(struct tty_struct *tty, struct file *file,
200 void (*set_termios)(struct tty_struct *tty, struct ktermios *old);
203 int (*hangup)(struct tty_struct *tty);
212 void (*fasync)(struct tty_struct *tty, int on);
223 struct tty_struct *tty; member in struct:tty_ldisc
231 MODULE_ALIAS("tty-ldisc-" __stringify(ldisc))
H A Dselection.h19 extern int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty);
20 extern int paste_selection(struct tty_struct *tty);
23 extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry);
H A Dti_wilink_st.h115 * @tty: tty provided by the TTY core for line disciplines.
116 * @tx_skb: If for some reason the tty's write returns lesser bytes written
124 * @rx_state: states to be maintained inside st's tty receive
125 * @rx_count: count to be maintained inside st's tty receieve
127 * since tty might not call receive when a complete event packet
161 struct tty_struct *tty; member in struct:st_data_s
165 * wrapper around tty->ops->write_room to check
171 * point this to tty->driver->write or tty->ops->write
255 * @core_data: ST core's data, which mainly is the tty's disc_data
H A Dsysrq.h41 * ASCII code of the key, pointer to registers and kbd/tty structs (if they
H A Disdn.h26 #include <linux/tty.h>
108 #define ISDN_TIMER_RINGING 5 /* tty RINGs = ISDN_TIMER_1SEC * this factor */
267 /*======================= Start of ISDN-tty stuff ===========================*/
361 /* Description of one ISDN-tty */
364 struct tty_driver *tty_modem; /* tty-device */
371 /*======================= End of ISDN-tty stuff ============================*/
439 int modempoll; /* Flag: tty-read active */
449 int usage[ISDN_MAX_CHANNELS]; /* Used by tty/ip/voice */
457 isdn_modem_t mdm; /* tty-driver-data */
/linux-4.1.27/drivers/tty/ipwireless/
H A Dtty.c27 #include <linux/tty.h>
32 #include "tty.h"
90 struct ipw_tty *tty = get_tty(linux_tty->index); ipw_open() local
92 if (!tty) ipw_open()
95 mutex_lock(&tty->ipw_tty_mutex); ipw_open()
96 if (tty->port.count == 0) ipw_open()
97 tty->tx_bytes_queued = 0; ipw_open()
99 tty->port.count++; ipw_open()
101 tty->port.tty = linux_tty; ipw_open()
102 linux_tty->driver_data = tty; ipw_open()
103 tty->port.low_latency = 1; ipw_open()
105 if (tty->tty_type == TTYTYPE_MODEM) ipw_open()
106 ipwireless_ppp_open(tty->network); ipw_open()
108 mutex_unlock(&tty->ipw_tty_mutex); ipw_open()
113 static void do_ipw_close(struct ipw_tty *tty) do_ipw_close() argument
115 tty->port.count--; do_ipw_close()
117 if (tty->port.count == 0) { do_ipw_close()
118 struct tty_struct *linux_tty = tty->port.tty; do_ipw_close()
121 tty->port.tty = NULL; do_ipw_close()
124 if (tty->tty_type == TTYTYPE_MODEM) do_ipw_close()
125 ipwireless_ppp_close(tty->network); do_ipw_close()
132 struct ipw_tty *tty = linux_tty->driver_data; ipw_hangup() local
134 if (!tty) ipw_hangup()
137 mutex_lock(&tty->ipw_tty_mutex); ipw_hangup()
138 if (tty->port.count == 0) { ipw_hangup()
139 mutex_unlock(&tty->ipw_tty_mutex); ipw_hangup()
143 do_ipw_close(tty); ipw_hangup()
145 mutex_unlock(&tty->ipw_tty_mutex); ipw_hangup()
153 /* Take data received from hardware, and send it out the tty */ ipwireless_tty_received()
154 void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data, ipwireless_tty_received() argument
159 mutex_lock(&tty->ipw_tty_mutex); ipwireless_tty_received()
161 if (!tty->port.count) { ipwireless_tty_received()
162 mutex_unlock(&tty->ipw_tty_mutex); ipwireless_tty_received()
165 mutex_unlock(&tty->ipw_tty_mutex); ipwireless_tty_received()
167 work = tty_insert_flip_string(&tty->port, data, length); ipwireless_tty_received()
175 tty_flip_buffer_push(&tty->port); ipwireless_tty_received()
181 struct ipw_tty *tty = callback_data; ipw_write_packet_sent_callback() local
187 tty->tx_bytes_queued -= packet_length; ipw_write_packet_sent_callback()
193 struct ipw_tty *tty = linux_tty->driver_data; ipw_write() local
196 if (!tty) ipw_write()
199 mutex_lock(&tty->ipw_tty_mutex); ipw_write()
200 if (!tty->port.count) { ipw_write()
201 mutex_unlock(&tty->ipw_tty_mutex); ipw_write()
205 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued; ipw_write()
213 mutex_unlock(&tty->ipw_tty_mutex); ipw_write()
217 ret = ipwireless_send_packet(tty->hardware, IPW_CHANNEL_RAS, ipw_write()
219 ipw_write_packet_sent_callback, tty); ipw_write()
221 mutex_unlock(&tty->ipw_tty_mutex); ipw_write()
225 tty->tx_bytes_queued += count; ipw_write()
226 mutex_unlock(&tty->ipw_tty_mutex); ipw_write()
233 struct ipw_tty *tty = linux_tty->driver_data; ipw_write_room() local
236 /* FIXME: Exactly how is the tty object locked here .. */ ipw_write_room()
237 if (!tty) ipw_write_room()
240 if (!tty->port.count) ipw_write_room()
243 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued; ipw_write_room()
250 static int ipwireless_get_serial_info(struct ipw_tty *tty, ipwireless_get_serial_info() argument
260 tmp.line = tty->index; ipwireless_get_serial_info()
277 struct ipw_tty *tty = linux_tty->driver_data; ipw_chars_in_buffer() local
279 if (!tty) ipw_chars_in_buffer()
282 if (!tty->port.count) ipw_chars_in_buffer()
285 return tty->tx_bytes_queued; ipw_chars_in_buffer()
288 static int get_control_lines(struct ipw_tty *tty) get_control_lines() argument
290 unsigned int my = tty->control_lines; get_control_lines()
307 static int set_control_lines(struct ipw_tty *tty, unsigned int set, set_control_lines() argument
313 ret = ipwireless_set_RTS(tty->hardware, tty->channel_idx, 1); set_control_lines()
316 if (tty->secondary_channel_idx != -1) { set_control_lines()
317 ret = ipwireless_set_RTS(tty->hardware, set_control_lines()
318 tty->secondary_channel_idx, 1); set_control_lines()
324 ret = ipwireless_set_DTR(tty->hardware, tty->channel_idx, 1); set_control_lines()
327 if (tty->secondary_channel_idx != -1) { set_control_lines()
328 ret = ipwireless_set_DTR(tty->hardware, set_control_lines()
329 tty->secondary_channel_idx, 1); set_control_lines()
335 ret = ipwireless_set_RTS(tty->hardware, tty->channel_idx, 0); set_control_lines()
336 if (tty->secondary_channel_idx != -1) { set_control_lines()
337 ret = ipwireless_set_RTS(tty->hardware, set_control_lines()
338 tty->secondary_channel_idx, 0); set_control_lines()
344 ret = ipwireless_set_DTR(tty->hardware, tty->channel_idx, 0); set_control_lines()
345 if (tty->secondary_channel_idx != -1) { set_control_lines()
346 ret = ipwireless_set_DTR(tty->hardware, set_control_lines()
347 tty->secondary_channel_idx, 0); set_control_lines()
357 struct ipw_tty *tty = linux_tty->driver_data; ipw_tiocmget() local
358 /* FIXME: Exactly how is the tty object locked here .. */ ipw_tiocmget()
360 if (!tty) ipw_tiocmget()
363 if (!tty->port.count) ipw_tiocmget()
366 return get_control_lines(tty); ipw_tiocmget()
373 struct ipw_tty *tty = linux_tty->driver_data; ipw_tiocmset() local
374 /* FIXME: Exactly how is the tty object locked here .. */ ipw_tiocmset()
376 if (!tty) ipw_tiocmset()
379 if (!tty->port.count) ipw_tiocmset()
382 return set_control_lines(tty, set, clear); ipw_tiocmset()
388 struct ipw_tty *tty = linux_tty->driver_data; ipw_ioctl() local
390 if (!tty) ipw_ioctl()
393 if (!tty->port.count) ipw_ioctl()
396 /* FIXME: Exactly how is the tty object locked here .. */ ipw_ioctl()
400 return ipwireless_get_serial_info(tty, (void __user *) arg); ipw_ioctl()
406 if (tty->tty_type == TTYTYPE_MODEM) { ipw_ioctl()
411 tty->network); ipw_ioctl()
423 tty->network); ipw_ioctl()
524 void ipwireless_tty_free(struct ipw_tty *tty) ipwireless_tty_free() argument
527 struct ipw_network *network = ttys[tty->index]->network; ipwireless_tty_free()
529 for (j = tty->index; j < IPWIRELESS_PCMCIA_MINORS; ipwireless_tty_free()
540 if (ttyj->port.tty != NULL) { ipwireless_tty_free()
542 tty_vhangup(ttyj->port.tty); ipwireless_tty_free()
543 /* FIXME: Exactly how is the tty object locked here ipwireless_tty_free()
598 ": failed to register tty driver\n"); ipwireless_tty_init()
617 int ipwireless_tty_is_modem(struct ipw_tty *tty) ipwireless_tty_is_modem() argument
619 return tty->tty_type == TTYTYPE_MODEM; ipwireless_tty_is_modem()
623 ipwireless_tty_notify_control_line_change(struct ipw_tty *tty, ipwireless_tty_notify_control_line_change() argument
628 unsigned int old_control_lines = tty->control_lines; ipwireless_tty_notify_control_line_change()
630 tty->control_lines = (tty->control_lines & ~changed_mask) ipwireless_tty_notify_control_line_change()
634 * If DCD is de-asserted, we close the tty so pppd can tell that we ipwireless_tty_notify_control_line_change()
638 && !(tty->control_lines & IPW_CONTROL_LINE_DCD) ipwireless_tty_notify_control_line_change()
639 && tty->port.tty) { ipwireless_tty_notify_control_line_change()
640 tty_hangup(tty->port.tty); ipwireless_tty_notify_control_line_change()
H A DMakefile7 ipwireless-y := hardware.o main.o network.o tty.o
H A Dtty.h36 void ipwireless_tty_free(struct ipw_tty *tty);
37 void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
39 int ipwireless_tty_is_modem(struct ipw_tty *tty);
40 void ipwireless_tty_notify_control_line_change(struct ipw_tty *tty,
H A Dnetwork.c31 #include "tty.h"
42 /* tty context connected with IPW console */
322 struct ipw_tty *tty = ipwireless_network_notify_control_line_change() local
326 * If it's associated with a tty (other than the RAS channel ipwireless_network_notify_control_line_change()
327 * when we're online), then send the data to that tty. The RAS ipwireless_network_notify_control_line_change()
331 if (tty) ipwireless_network_notify_control_line_change()
332 ipwireless_tty_notify_control_line_change(tty, ipwireless_network_notify_control_line_change()
372 struct ipw_tty *tty = network->associated_ttys[channel_idx][i]; ipwireless_network_packet_received() local
374 if (!tty) ipwireless_network_packet_received()
378 * If it's associated with a tty (other than the RAS channel ipwireless_network_packet_received()
379 * when we're online), then send the data to that tty. The RAS ipwireless_network_packet_received()
386 && ipwireless_tty_is_modem(tty)) { ipwireless_network_packet_received()
388 * If data came in on the RAS channel and this tty is ipwireless_network_packet_received()
389 * the modem tty, and we are online, then we send it to ipwireless_network_packet_received()
409 /* Otherwise we send it out the tty. */ ipwireless_network_packet_received()
411 ipwireless_tty_received(tty, data, length); ipwireless_network_packet_received()
452 struct ipw_tty *tty) ipwireless_associate_network_tty()
458 network->associated_ttys[channel_idx][i] = tty; ipwireless_associate_network_tty()
450 ipwireless_associate_network_tty(struct ipw_network *network, unsigned int channel_idx, struct ipw_tty *tty) ipwireless_associate_network_tty() argument
H A Dmain.h59 struct ipw_tty *tty; member in struct:ipw_dev
H A Dnetwork.h42 unsigned int channel_idx, struct ipw_tty *tty);
H A Dmain.c21 #include "tty.h"
199 ipw->tty = ipwireless_tty_create(ipw->hardware, ipw->network); config_ipwireless()
200 if (!ipw->tty) config_ipwireless()
297 if (ipw->tty != NULL) ipwireless_detach()
298 ipwireless_tty_free(ipw->tty); ipwireless_detach()
/linux-4.1.27/net/bluetooth/rfcomm/
H A DMakefile8 rfcomm-$(CONFIG_BT_RFCOMM_TTY) += tty.o
H A Dtty.c30 #include <linux/tty.h>
111 static int rfcomm_dev_activate(struct tty_port *port, struct tty_struct *tty) rfcomm_dev_activate() argument
118 set_bit(TTY_IO_ERROR, &tty->flags); rfcomm_dev_activate()
320 struct device *tty; rfcomm_dev_add() local
330 tty = tty_port_register_device(&dev->port, rfcomm_tty_driver, rfcomm_dev_add()
332 if (IS_ERR(tty)) { rfcomm_dev_add()
334 return PTR_ERR(tty); rfcomm_dev_add()
337 dev->tty_dev = tty; rfcomm_dev_add()
442 struct tty_struct *tty; __rfcomm_release_dev() local
468 tty = tty_port_tty_get(&dev->port); __rfcomm_release_dev()
469 if (tty) { __rfcomm_release_dev()
470 tty_vhangup(tty); __rfcomm_release_dev()
471 tty_kref_put(tty); __rfcomm_release_dev()
683 /* do the reverse of install, clearing the tty fields and releasing the
686 static void rfcomm_tty_cleanup(struct tty_struct *tty) rfcomm_tty_cleanup() argument
688 struct rfcomm_dev *dev = tty->driver_data; rfcomm_tty_cleanup()
693 tty->driver_data = NULL; rfcomm_tty_cleanup()
705 /* we acquire the tty_port reference since it's here the tty is first used
707 * the tty port
709 static int rfcomm_tty_install(struct tty_driver *driver, struct tty_struct *tty) rfcomm_tty_install() argument
715 dev = rfcomm_dev_get(tty->index); rfcomm_tty_install()
723 tty->driver_data = dev; rfcomm_tty_install()
728 err = tty_port_install(&dev->port, driver, tty); rfcomm_tty_install()
730 rfcomm_tty_cleanup(tty); rfcomm_tty_install()
736 * when the last process closes the tty. The behaviour is expected by rfcomm_tty_install()
747 static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) rfcomm_tty_open() argument
749 struct rfcomm_dev *dev = tty->driver_data; rfcomm_tty_open()
752 BT_DBG("tty %p id %d", tty, tty->index); rfcomm_tty_open()
757 err = tty_port_open(&dev->port, tty, filp); rfcomm_tty_open()
773 static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp) rfcomm_tty_close() argument
775 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_close()
777 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, rfcomm_tty_close()
780 tty_port_close(&dev->port, tty, filp); rfcomm_tty_close()
783 static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) rfcomm_tty_write() argument
785 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_write()
790 BT_DBG("tty %p count %d", tty, count); rfcomm_tty_write()
812 static int rfcomm_tty_write_room(struct tty_struct *tty) rfcomm_tty_write_room() argument
814 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_write_room()
820 BT_DBG("tty %p room %d", tty, room); rfcomm_tty_write_room()
825 static int rfcomm_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) rfcomm_tty_ioctl() argument
827 BT_DBG("tty %p cmd 0x%02x", tty, cmd); rfcomm_tty_ioctl()
870 static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old) rfcomm_tty_set_termios() argument
872 struct ktermios *new = &tty->termios; rfcomm_tty_set_termios()
879 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_set_termios()
881 BT_DBG("tty %p termios %p", tty, old); rfcomm_tty_set_termios()
1009 static void rfcomm_tty_throttle(struct tty_struct *tty) rfcomm_tty_throttle() argument
1011 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_throttle()
1013 BT_DBG("tty %p dev %p", tty, dev); rfcomm_tty_throttle()
1018 static void rfcomm_tty_unthrottle(struct tty_struct *tty) rfcomm_tty_unthrottle() argument
1020 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_unthrottle()
1022 BT_DBG("tty %p dev %p", tty, dev); rfcomm_tty_unthrottle()
1027 static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty) rfcomm_tty_chars_in_buffer() argument
1029 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_chars_in_buffer()
1031 BT_DBG("tty %p dev %p", tty, dev); rfcomm_tty_chars_in_buffer()
1042 static void rfcomm_tty_flush_buffer(struct tty_struct *tty) rfcomm_tty_flush_buffer() argument
1044 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_flush_buffer()
1046 BT_DBG("tty %p dev %p", tty, dev); rfcomm_tty_flush_buffer()
1052 tty_wakeup(tty); rfcomm_tty_flush_buffer()
1055 static void rfcomm_tty_send_xchar(struct tty_struct *tty, char ch) rfcomm_tty_send_xchar() argument
1057 BT_DBG("tty %p ch %c", tty, ch); rfcomm_tty_send_xchar()
1060 static void rfcomm_tty_wait_until_sent(struct tty_struct *tty, int timeout) rfcomm_tty_wait_until_sent() argument
1062 BT_DBG("tty %p timeout %d", tty, timeout); rfcomm_tty_wait_until_sent()
1065 static void rfcomm_tty_hangup(struct tty_struct *tty) rfcomm_tty_hangup() argument
1067 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_hangup()
1069 BT_DBG("tty %p dev %p", tty, dev); rfcomm_tty_hangup()
1074 static int rfcomm_tty_tiocmget(struct tty_struct *tty) rfcomm_tty_tiocmget() argument
1076 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_tiocmget()
1078 BT_DBG("tty %p dev %p", tty, dev); rfcomm_tty_tiocmget()
1083 static int rfcomm_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) rfcomm_tty_tiocmset() argument
1085 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; rfcomm_tty_tiocmset()
1089 BT_DBG("tty %p dev %p set 0x%02x clear 0x%02x", tty, dev, set, clear); rfcomm_tty_tiocmset()
/linux-4.1.27/drivers/net/irda/
H A Dirtty-sir.c32 #include <linux/tty.h>
67 return tty_chars_in_buffer(priv->tty); irtty_chars_in_buffer()
74 * If the tty sits on top of a 16550A-like uart, there are typically
90 struct tty_struct *tty; irtty_wait_until_sent() local
95 tty = priv->tty; irtty_wait_until_sent()
96 if (tty->ops->wait_until_sent) { irtty_wait_until_sent()
97 tty->ops->wait_until_sent(tty, msecs_to_jiffies(100)); irtty_wait_until_sent()
117 struct tty_struct *tty; irtty_change_speed() local
124 tty = priv->tty; irtty_change_speed()
126 down_write(&tty->termios_rwsem); irtty_change_speed()
127 old_termios = tty->termios; irtty_change_speed()
128 cflag = tty->termios.c_cflag; irtty_change_speed()
129 tty_encode_baud_rate(tty, speed, speed); irtty_change_speed()
130 if (tty->ops->set_termios) irtty_change_speed()
131 tty->ops->set_termios(tty, &old_termios); irtty_change_speed()
133 up_write(&tty->termios_rwsem); irtty_change_speed()
166 * This function is not yet defined for all tty driver, so irtty_set_dtr_rts()
169 IRDA_ASSERT(priv->tty->ops->tiocmset != NULL, return -1;); irtty_set_dtr_rts()
170 priv->tty->ops->tiocmset(priv->tty, set, clear); irtty_set_dtr_rts()
185 struct tty_struct *tty; irtty_do_write() local
191 tty = priv->tty; irtty_do_write()
192 if (!tty->ops->write) irtty_do_write()
194 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); irtty_do_write()
195 writelen = tty_write_room(tty); irtty_do_write()
198 return tty->ops->write(tty, ptr, writelen); irtty_do_write()
206 * Function irtty_receive_buf( tty, cp, count)
213 * calling context depends on underlying driver and tty->port->low_latency!
219 static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp, irtty_receive_buf() argument
223 struct sirtty_cb *priv = tty->disc_data; irtty_receive_buf()
253 * Function irtty_write_wakeup (tty)
259 static void irtty_write_wakeup(struct tty_struct *tty) irtty_write_wakeup() argument
261 struct sirtty_cb *priv = tty->disc_data; irtty_write_wakeup()
266 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); irtty_write_wakeup()
274 * Function irtty_stop_receiver (tty, stop)
278 static inline void irtty_stop_receiver(struct tty_struct *tty, int stop) irtty_stop_receiver() argument
283 down_write(&tty->termios_rwsem); irtty_stop_receiver()
284 old_termios = tty->termios; irtty_stop_receiver()
285 cflag = tty->termios.c_cflag; irtty_stop_receiver()
292 tty->termios.c_cflag = cflag; irtty_stop_receiver()
293 if (tty->ops->set_termios) irtty_stop_receiver()
294 tty->ops->set_termios(tty, &old_termios); irtty_stop_receiver()
295 up_write(&tty->termios_rwsem); irtty_stop_receiver()
308 struct tty_struct *tty; irtty_start_dev() local
319 tty = priv->tty; irtty_start_dev()
321 if (tty->ops->start) irtty_start_dev()
322 tty->ops->start(tty); irtty_start_dev()
324 irtty_stop_receiver(tty, FALSE); irtty_start_dev()
335 struct tty_struct *tty; irtty_stop_dev() local
346 tty = priv->tty; irtty_stop_dev()
349 irtty_stop_receiver(tty, TRUE); irtty_stop_dev()
350 if (tty->ops->stop) irtty_stop_dev()
351 tty->ops->stop(tty); irtty_stop_dev()
375 * Function irtty_ioctl (tty, file, cmd, arg)
380 static int irtty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) irtty_ioctl() argument
384 struct sirtty_cb *priv = tty->disc_data; irtty_ioctl()
411 err = tty_mode_ioctl(tty, file, cmd, arg); irtty_ioctl()
419 * Function irtty_open(tty)
422 * discipline is called for. Because we are sure the tty line exists,
425 static int irtty_open(struct tty_struct *tty) irtty_open() argument
434 irtty_stop_receiver(tty, TRUE); irtty_open()
435 if (tty->ops->stop) irtty_open()
436 tty->ops->stop(tty); irtty_open()
438 tty_driver_flush_buffer(tty); irtty_open()
444 dev = sirdev_get_instance(&sir_tty_drv, tty->name); irtty_open()
458 priv->tty = tty; irtty_open()
465 tty->disc_data = priv; irtty_open()
466 tty->receive_room = 65536; irtty_open()
470 pr_debug("%s - %s: irda line discipline opened\n", __func__, tty->name); irtty_open()
481 * Function irtty_close (tty)
487 static void irtty_close(struct tty_struct *tty) irtty_close() argument
489 struct sirtty_cb *priv = tty->disc_data; irtty_close()
496 * some tty write and/or termios or ioctl operations. irtty_close()
501 * For now let's assume we are granted to issue tty driver calls irtty_close()
506 * priv->tty = NULL?; irtty_close()
510 tty->disc_data = NULL; irtty_close()
514 /* Stop tty */ irtty_close()
515 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); irtty_close()
516 if (tty->ops->stop) irtty_close()
517 tty->ops->stop(tty); irtty_close()
521 pr_debug("%s - %s: irda line discipline closed\n", __func__, tty->name); irtty_close()
H A Dirtty-sir.h29 struct tty_struct *tty; member in struct:sirtty_cb
/linux-4.1.27/drivers/s390/char/
H A Dtty3270.h9 #include <linux/tty.h>
H A Dctrlchar.h9 #include <linux/tty.h>
12 ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty);
H A Dctrlchar.c34 * @param tty The tty struct for this console.
41 ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty) ctrlchar_handle() argument
65 return INTR_CHAR(tty) | CTRLCHAR_CTRL; ctrlchar_handle()
67 return EOF_CHAR(tty) | CTRLCHAR_CTRL; ctrlchar_handle()
69 return SUSP_CHAR(tty) | CTRLCHAR_CTRL; ctrlchar_handle()
H A Dtty3270.c2 * IBM/3270 Driver - tty functions.
13 #include <linux/tty.h>
56 * The main tty view data structure.
79 /* Current tty screen. */
93 int throttle, attn; /* tty throttle/unthrottle. */
223 * Set output offsets to 3270 datastream fragment of a tty string.
474 * Deactivate tty view.
529 * Pass input line to tty.
542 * has to be emitted to the tty and for 0x6d the screen tty3270_read_tasklet()
548 /* Enter: write input to tty. */ tty3270_read_tasklet()
592 /* Schedule tasklet to pass input to tty. */ tty3270_read_callback()
625 * Switch to the tty view.
804 struct tty_struct *tty; tty3270_resize_work() local
830 /* Informat tty layer about new size */ tty3270_resize_work()
831 tty = tty_port_tty_get(&tp->port); tty3270_resize_work()
832 if (!tty) tty3270_resize_work()
836 tty_do_resize(tty, &ws); tty3270_resize_work()
851 * Unlink tty3270 data structure from tty.
857 struct tty_struct *tty = tty_port_tty_get(&tp->port); tty3270_release() local
859 if (tty) { tty3270_release()
860 tty->driver_data = NULL; tty3270_release()
862 tty_hangup(tty); tty3270_release()
864 tty_kref_put(tty); tty3270_release()
906 * This routine is called whenever a 3270 tty is opened first time.
908 static int tty3270_install(struct tty_driver *driver, struct tty_struct *tty) tty3270_install() argument
915 view = raw3270_find_view(&tty3270_fn, tty->index + RAW3270_FIRSTMINOR); tty3270_install()
918 tty->driver_data = tp; tty3270_install()
919 tty->winsize.ws_row = tp->view.rows - 2; tty3270_install()
920 tty->winsize.ws_col = tp->view.cols; tty3270_install()
923 tty_port_tty_set(&tp->port, tty); tty3270_install()
925 return tty_port_install(&tp->port, driver, tty); tty3270_install()
927 if (tty3270_max_index < tty->index + 1) tty3270_install()
928 tty3270_max_index = tty->index + 1; tty3270_install()
936 tty->index + RAW3270_FIRSTMINOR); tty3270_install()
951 tty_port_tty_set(&tp->port, tty); tty3270_install()
953 tty->winsize.ws_row = tp->view.rows - 2; tty3270_install()
954 tty->winsize.ws_col = tp->view.cols; tty3270_install()
960 /* Create blank line for every line in the tty output area. */ tty3270_install()
973 rc = tty_port_install(&tp->port, driver, tty); tty3270_install()
979 tty->driver_data = tp; tty3270_install()
985 * This routine is called whenever a 3270 tty is opened.
988 tty3270_open(struct tty_struct *tty, struct file *filp) tty3270_open() argument
990 struct tty3270 *tp = tty->driver_data; tty3270_open()
994 tty_port_tty_set(port, tty); tty3270_open()
999 * This routine is called when the 3270 tty is closed. We wait
1003 tty3270_close(struct tty_struct *tty, struct file * filp) tty3270_close() argument
1005 struct tty3270 *tp = tty->driver_data; tty3270_close()
1007 if (tty->count > 1) tty3270_close()
1010 tty->driver_data = NULL; tty3270_close()
1015 static void tty3270_cleanup(struct tty_struct *tty) tty3270_cleanup() argument
1017 struct tty3270 *tp = tty->driver_data; tty3270_cleanup()
1027 tty3270_write_room(struct tty_struct *tty) tty3270_write_room() argument
1589 tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty, tty3270_do_write() argument
1595 for (i_msg = 0; !tty->stopped && i_msg < count; i_msg++) { tty3270_do_write()
1663 tty3270_write(struct tty_struct * tty, tty3270_write() argument
1668 tp = tty->driver_data; tty3270_write()
1672 tty3270_do_write(tp, tty, tp->char_buf, tp->char_count); tty3270_write()
1675 tty3270_do_write(tp, tty, buf, count); tty3270_write()
1682 static int tty3270_put_char(struct tty_struct *tty, unsigned char ch) tty3270_put_char() argument
1686 tp = tty->driver_data; tty3270_put_char()
1698 tty3270_flush_chars(struct tty_struct *tty) tty3270_flush_chars() argument
1702 tp = tty->driver_data; tty3270_flush_chars()
1706 tty3270_do_write(tp, tty, tp->char_buf, tp->char_count); tty3270_flush_chars()
1717 tty3270_chars_in_buffer(struct tty_struct *tty) tty3270_chars_in_buffer() argument
1723 tty3270_flush_buffer(struct tty_struct *tty) tty3270_flush_buffer() argument
1731 tty3270_set_termios(struct tty_struct *tty, struct ktermios *old) tty3270_set_termios() argument
1736 tp = tty->driver_data; tty3270_set_termios()
1740 if (L_ICANON(tty)) { tty3270_set_termios()
1741 new = L_ECHO(tty) ? TF_INPUT: TF_INPUTN; tty3270_set_termios()
1752 * Disable reading from a 3270 tty
1755 tty3270_throttle(struct tty_struct * tty) tty3270_throttle() argument
1759 tp = tty->driver_data; tty3270_throttle()
1766 * Enable reading from a 3270 tty
1769 tty3270_unthrottle(struct tty_struct * tty) tty3270_unthrottle() argument
1773 tp = tty->driver_data; tty3270_unthrottle()
1782 * Hang up the tty device.
1785 tty3270_hangup(struct tty_struct *tty) tty3270_hangup() argument
1791 tty3270_wait_until_sent(struct tty_struct *tty, int timeout) tty3270_wait_until_sent() argument
1795 static int tty3270_ioctl(struct tty_struct *tty, unsigned int cmd, tty3270_ioctl() argument
1800 tp = tty->driver_data; tty3270_ioctl()
1803 if (tty->flags & (1 << TTY_IO_ERROR)) tty3270_ioctl()
1809 static long tty3270_compat_ioctl(struct tty_struct *tty, tty3270_compat_ioctl() argument
1814 tp = tty->driver_data; tty3270_compat_ioctl()
1817 if (tty->flags & (1 << TTY_IO_ERROR)) tty3270_compat_ioctl()
1862 * 3270 tty registration code called from tty_init().
1883 driver->name = "3270/tty"; tty3270_init()
H A Dcon3215.c15 #include <linux/tty.h>
78 struct ccw_device *cdev; /* device for tty driver */
341 struct tty_struct *tty; raw3215_wakeup() local
343 tty = tty_port_tty_get(&raw->port); raw3215_wakeup()
344 if (tty) { raw3215_wakeup()
345 tty_wakeup(tty); raw3215_wakeup()
346 tty_kref_put(tty); raw3215_wakeup()
351 * Try to start the next IO and wake up processes waiting on the tty.
353 static void raw3215_next_io(struct raw3215_info *raw, struct tty_struct *tty) raw3215_next_io() argument
357 if (tty && RAW3215_BUFFER_SIZE - raw->count >= RAW3215_MIN_SPACE) raw3215_next_io()
369 struct tty_struct *tty; raw3215_irq() local
375 tty = tty_port_tty_get(&raw->port); raw3215_irq()
379 raw3215_next_io(raw, tty); raw3215_irq()
389 raw3215_next_io(raw, tty); raw3215_irq()
406 if (req->type == RAW3215_READ && tty != NULL) { raw3215_irq()
411 cchar = ctrlchar_handle(raw->inbuf, count, tty); raw3215_irq()
448 raw3215_next_io(raw, tty); raw3215_irq()
460 raw3215_next_io(raw, tty); raw3215_irq()
463 tty_kref_put(tty); raw3215_irq()
960 static int tty3215_install(struct tty_driver *driver, struct tty_struct *tty) tty3215_install() argument
964 raw = raw3215[tty->index]; tty3215_install()
968 tty->driver_data = raw; tty3215_install()
970 return tty_port_install(&raw->port, driver, tty); tty3215_install()
976 * This routine is called whenever a 3215 tty is opened.
978 static int tty3215_open(struct tty_struct *tty, struct file * filp) tty3215_open() argument
980 struct raw3215_info *raw = tty->driver_data; tty3215_open()
983 tty_port_tty_set(&raw->port, tty); tty3215_open()
999 * This routine is called when the 3215 tty is closed. We wait
1002 static void tty3215_close(struct tty_struct *tty, struct file * filp) tty3215_close() argument
1006 raw = (struct raw3215_info *) tty->driver_data; tty3215_close()
1007 if (raw == NULL || tty->count > 1) tty3215_close()
1009 tty->closing = 1; tty3215_close()
1013 tty->closing = 0; tty3215_close()
1020 static int tty3215_write_room(struct tty_struct *tty) tty3215_write_room() argument
1024 raw = (struct raw3215_info *) tty->driver_data; tty3215_write_room()
1036 static int tty3215_write(struct tty_struct * tty, tty3215_write() argument
1042 if (!tty) tty3215_write()
1044 raw = (struct raw3215_info *) tty->driver_data; tty3215_write()
1065 static int tty3215_put_char(struct tty_struct *tty, unsigned char ch) tty3215_put_char() argument
1069 if (!tty) tty3215_put_char()
1071 raw = (struct raw3215_info *) tty->driver_data; tty3215_put_char()
1076 static void tty3215_flush_chars(struct tty_struct *tty) tty3215_flush_chars() argument
1083 static int tty3215_chars_in_buffer(struct tty_struct *tty) tty3215_chars_in_buffer() argument
1087 raw = (struct raw3215_info *) tty->driver_data; tty3215_chars_in_buffer()
1091 static void tty3215_flush_buffer(struct tty_struct *tty) tty3215_flush_buffer() argument
1095 raw = (struct raw3215_info *) tty->driver_data; tty3215_flush_buffer()
1097 tty_wakeup(tty); tty3215_flush_buffer()
1101 * Disable reading from a 3215 tty
1103 static void tty3215_throttle(struct tty_struct * tty) tty3215_throttle() argument
1107 raw = (struct raw3215_info *) tty->driver_data; tty3215_throttle()
1112 * Enable reading from a 3215 tty
1114 static void tty3215_unthrottle(struct tty_struct * tty) tty3215_unthrottle() argument
1119 raw = (struct raw3215_info *) tty->driver_data; tty3215_unthrottle()
1129 * Disable writing to a 3215 tty
1131 static void tty3215_stop(struct tty_struct *tty) tty3215_stop() argument
1135 raw = (struct raw3215_info *) tty->driver_data; tty3215_stop()
1140 * Enable writing to a 3215 tty
1142 static void tty3215_start(struct tty_struct *tty) tty3215_start() argument
1147 raw = (struct raw3215_info *) tty->driver_data; tty3215_start()
1173 * 3215 tty registration code called from tty_init().
H A Dsclp_tty.c12 #include <linux/tty.h>
64 sclp_tty_open(struct tty_struct *tty, struct file *filp) sclp_tty_open() argument
66 tty_port_tty_set(&sclp_port, tty); sclp_tty_open()
67 tty->driver_data = NULL; sclp_tty_open()
74 sclp_tty_close(struct tty_struct *tty, struct file *filp) sclp_tty_close() argument
76 if (tty->count > 1) sclp_tty_close()
82 * This routine returns the numbers of characters the tty driver
91 sclp_tty_write_room (struct tty_struct *tty) sclp_tty_write_room() argument
170 * Write a string to the sclp tty.
234 * tty device. The characters may come from user space or kernel space. This
238 sclp_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) sclp_tty_write() argument
248 * This routine is called by the kernel to write a single character to the tty
258 sclp_tty_put_char(struct tty_struct *tty, unsigned char ch) sclp_tty_put_char() argument
270 * characters to the tty device using put_char().
273 sclp_tty_flush_chars(struct tty_struct *tty) sclp_tty_flush_chars() argument
289 sclp_tty_chars_in_buffer(struct tty_struct *tty) sclp_tty_chars_in_buffer() argument
312 sclp_tty_flush_buffer(struct tty_struct *tty) sclp_tty_flush_buffer() argument
321 * push input to tty
326 struct tty_struct *tty = tty_port_tty_get(&sclp_port); sclp_tty_input() local
330 * If this tty driver is currently closed sclp_tty_input()
333 if (tty == NULL) sclp_tty_input()
335 cchar = ctrlchar_handle(buf, count, tty); sclp_tty_input()
356 tty_kref_put(tty); sclp_tty_input()
H A Dsclp_vt220.c15 #include <linux/tty.h>
55 /* Structures and data needed to register tty driver */
466 * characters to the tty device. The characters may come from
471 sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count) sclp_vt220_write() argument
507 * This routine is called when a particular tty device is opened.
510 sclp_vt220_open(struct tty_struct *tty, struct file *filp) sclp_vt220_open() argument
512 if (tty->count == 1) { sclp_vt220_open()
513 tty_port_tty_set(&sclp_vt220_port, tty); sclp_vt220_open()
515 if (!tty->winsize.ws_row && !tty->winsize.ws_col) { sclp_vt220_open()
516 tty->winsize.ws_row = 24; sclp_vt220_open()
517 tty->winsize.ws_col = 80; sclp_vt220_open()
524 * This routine is called when a particular tty device is closed.
527 sclp_vt220_close(struct tty_struct *tty, struct file *filp) sclp_vt220_close() argument
529 if (tty->count == 1) sclp_vt220_close()
535 * character to the tty device. If the kernel uses this routine,
540 sclp_vt220_put_char(struct tty_struct *tty, unsigned char ch) sclp_vt220_put_char() argument
547 * series of characters to the tty device using put_char().
550 sclp_vt220_flush_chars(struct tty_struct *tty) sclp_vt220_flush_chars() argument
559 * This routine returns the numbers of characters the tty driver
565 sclp_vt220_write_room(struct tty_struct *tty) sclp_vt220_write_room() argument
585 sclp_vt220_chars_in_buffer(struct tty_struct *tty) sclp_vt220_chars_in_buffer() argument
609 sclp_vt220_flush_buffer(struct tty_struct *tty) sclp_vt220_flush_buffer() argument
687 * Register driver with SCLP and Linux and initialize internal tty structures.
H A Dkeyboard.h8 #include <linux/tty.h>
H A Dkeyboard.c254 * Put utf8 character to tty flip buffer.
459 struct tty_struct *tty; kbd_ioctl() local
468 * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. kbd_ioctl()
470 tty = tty_port_tty_get(kbd->port); kbd_ioctl()
472 perm = current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG); kbd_ioctl()
473 tty_kref_put(tty); kbd_ioctl()
H A Dfs3270.c417 /* View to a 3270 device. Can be console, tty or fullscreen. */
441 struct tty_struct *tty = get_current_tty(); fs3270_open() local
442 if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) { fs3270_open()
443 tty_kref_put(tty); fs3270_open()
446 minor = tty->index; fs3270_open()
447 tty_kref_put(tty); fs3270_open()
496 * This routine is called when the 3270 tty is closed. We wait
/linux-4.1.27/drivers/tty/serial/
H A Dmsm_smd_tty.c23 #include <linux/tty.h>
57 struct tty_struct *tty; smd_tty_notify() local
62 tty = tty_port_tty_get(&info->port); smd_tty_notify()
63 if (!tty) smd_tty_notify()
67 if (test_bit(TTY_THROTTLED, &tty->flags)) smd_tty_notify()
87 tty_wakeup(tty); smd_tty_notify()
88 tty_kref_put(tty); smd_tty_notify()
91 static int smd_tty_port_activate(struct tty_port *tport, struct tty_struct *tty) smd_tty_port_activate() argument
99 if (smd_tty_channels[i].id == tty->index) { smd_tty_port_activate()
113 tty->driver_data = info; smd_tty_port_activate()
129 static int smd_tty_open(struct tty_struct *tty, struct file *f) smd_tty_open() argument
131 struct smd_tty_info *info = smd_tty + tty->index; smd_tty_open()
133 return tty_port_open(&info->port, tty, f); smd_tty_open()
136 static void smd_tty_close(struct tty_struct *tty, struct file *f) smd_tty_close() argument
138 struct smd_tty_info *info = tty->driver_data; smd_tty_close()
140 tty_port_close(&info->port, tty, f); smd_tty_close()
143 static int smd_tty_write(struct tty_struct *tty, smd_tty_write() argument
146 struct smd_tty_info *info = tty->driver_data; smd_tty_write()
160 static int smd_tty_write_room(struct tty_struct *tty) smd_tty_write_room() argument
162 struct smd_tty_info *info = tty->driver_data; smd_tty_write_room()
166 static int smd_tty_chars_in_buffer(struct tty_struct *tty) smd_tty_chars_in_buffer() argument
168 struct smd_tty_info *info = tty->driver_data; smd_tty_chars_in_buffer()
172 static void smd_tty_unthrottle(struct tty_struct *tty) smd_tty_unthrottle() argument
174 struct smd_tty_info *info = tty->driver_data; smd_tty_unthrottle()
H A D68328serial.c24 #include <linux/tty.h>
141 static void change_speed(struct m68k_serial *info, struct tty_struct *tty);
208 * This routines are called before setting or resetting tty->stopped.
212 static void rs_stop(struct tty_struct *tty) rs_stop() argument
214 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_stop()
218 if (serial_paranoia_check(info, tty->name, "rs_stop")) rs_stop()
244 static void rs_start(struct tty_struct *tty) rs_start() argument
246 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_start()
250 if (serial_paranoia_check(info, tty->name, "rs_start")) rs_start()
311 static void transmit_chars(struct m68k_serial *info, struct tty_struct *tty) transmit_chars() argument
322 if ((info->xmit_cnt <= 0) || !tty || tty->stopped) { transmit_chars()
350 struct tty_struct *tty = tty_port_tty_get(&info->tport); rs_interrupt() local
364 transmit_chars(info, tty); rs_interrupt()
368 tty_kref_put(tty); rs_interrupt()
373 static int startup(struct m68k_serial *info, struct tty_struct *tty) startup() argument
408 if (tty) startup()
409 clear_bit(TTY_IO_ERROR, &tty->flags); startup()
416 change_speed(info, tty); startup()
427 static void shutdown(struct m68k_serial *info, struct tty_struct *tty) shutdown() argument
443 if (tty) shutdown()
444 set_bit(TTY_IO_ERROR, &tty->flags); shutdown()
502 static void change_speed(struct m68k_serial *info, struct tty_struct *tty) change_speed() argument
510 cflag = tty->termios.c_cflag; change_speed()
605 static void rs_set_ldisc(struct tty_struct *tty) rs_set_ldisc() argument
607 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_set_ldisc()
609 if (serial_paranoia_check(info, tty->name, "rs_set_ldisc")) rs_set_ldisc()
612 info->is_cons = (tty->termios.c_line == N_TTY); rs_set_ldisc()
617 static void rs_flush_chars(struct tty_struct *tty) argument
619 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
623 if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
632 if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf) {
663 static int rs_write(struct tty_struct * tty, rs_write() argument
667 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_write()
671 if (serial_paranoia_check(info, tty->name, "rs_write")) rs_write()
674 if (!tty || !info->xmit_buf) rs_write()
698 if (info->xmit_cnt && !tty->stopped) { rs_write()
726 static int rs_write_room(struct tty_struct *tty) rs_write_room() argument
728 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_write_room()
731 if (serial_paranoia_check(info, tty->name, "rs_write_room")) rs_write_room()
739 static int rs_chars_in_buffer(struct tty_struct *tty) rs_chars_in_buffer() argument
741 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_chars_in_buffer()
743 if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) rs_chars_in_buffer()
748 static void rs_flush_buffer(struct tty_struct *tty) rs_flush_buffer() argument
750 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_flush_buffer()
753 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) rs_flush_buffer()
758 tty_wakeup(tty); rs_flush_buffer()
765 * This routine is called by the upper-layer tty layer to signal that
769 static void rs_throttle(struct tty_struct * tty) rs_throttle() argument
771 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_throttle()
773 if (serial_paranoia_check(info, tty->name, "rs_throttle")) rs_throttle()
776 if (I_IXOFF(tty)) rs_throttle()
777 info->x_char = STOP_CHAR(tty); rs_throttle()
782 static void rs_unthrottle(struct tty_struct * tty) rs_unthrottle() argument
784 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_unthrottle()
786 if (serial_paranoia_check(info, tty->name, "rs_unthrottle")) rs_unthrottle()
789 if (I_IXOFF(tty)) { rs_unthrottle()
793 info->x_char = START_CHAR(tty); rs_unthrottle()
828 static int set_serial_info(struct m68k_serial *info, struct tty_struct *tty, set_serial_info() argument
871 retval = startup(info, tty); set_serial_info()
921 static int rs_ioctl(struct tty_struct *tty, rs_ioctl() argument
924 struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; rs_ioctl()
927 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) rs_ioctl()
933 if (tty->flags & (1 << TTY_IO_ERROR)) rs_ioctl()
939 retval = tty_check_change(tty); rs_ioctl()
942 tty_wait_until_sent(tty, 0); rs_ioctl()
947 retval = tty_check_change(tty); rs_ioctl()
950 tty_wait_until_sent(tty, 0); rs_ioctl()
957 return set_serial_info(info, tty, rs_ioctl()
972 static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) rs_set_termios() argument
974 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; rs_set_termios()
976 change_speed(info, tty); rs_set_termios()
979 !(tty->termios.c_cflag & CRTSCTS)) rs_set_termios()
980 rs_start(tty); rs_set_termios()
994 static void rs_close(struct tty_struct *tty, struct file * filp) rs_close() argument
996 struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; rs_close()
1001 if (serial_paranoia_check(info, tty->name, "rs_close")) rs_close()
1011 if ((tty->count == 1) && (port->count != 1)) { rs_close()
1013 * Uh, oh. tty->count is 1, which means that the tty rs_close()
1019 printk("rs_close: bad serial port count; tty->count is 1, " rs_close()
1037 tty->closing = 1; rs_close()
1039 tty_wait_until_sent(tty, port->closing_wait); rs_close()
1050 shutdown(info, tty); rs_close()
1051 rs_flush_buffer(tty); rs_close()
1053 tty_ldisc_flush(tty); rs_close()
1054 tty->closing = 0; rs_close()
1058 if (tty->ldisc.num != ldiscs[N_TTY].num) { rs_close()
1059 if (tty->ldisc.close) rs_close()
1060 (tty->ldisc.close)(tty); rs_close()
1061 tty->ldisc = ldiscs[N_TTY]; rs_close()
1062 tty->termios.c_line = N_TTY; rs_close()
1063 if (tty->ldisc.open) rs_close()
1064 (tty->ldisc.open)(tty); rs_close()
1080 void rs_hangup(struct tty_struct *tty) rs_hangup() argument
1082 struct m68k_serial * info = (struct m68k_serial *)tty->driver_data; rs_hangup()
1084 if (serial_paranoia_check(info, tty->name, "rs_hangup")) rs_hangup()
1087 rs_flush_buffer(tty); rs_hangup()
1088 shutdown(info, tty); rs_hangup()
1099 * initialization for the tty structure.
1101 int rs_open(struct tty_struct *tty, struct file * filp) rs_open() argument
1106 info = &m68k_soft[tty->index]; rs_open()
1108 if (serial_paranoia_check(info, tty->name, "rs_open")) rs_open()
1112 tty->driver_data = info; rs_open()
1113 tty_port_tty_set(&info->tport, tty); rs_open()
1118 retval = startup(info, tty); rs_open()
1122 return tty_port_block_til_ready(&info->tport, tty, filp); rs_open()
H A Dkgdb_nmi.c22 #include <linux/tty.h>
109 * Can't use port->tty->driver_data as tty might be not there. Timer kgdb_tty_recv()
110 * will check for tty and will get the ref, but here we don't have to kgdb_tty_recv()
211 static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) kgdb_nmi_tty_activate() argument
237 static int kgdb_nmi_tty_install(struct tty_driver *drv, struct tty_struct *tty) kgdb_nmi_tty_install() argument
250 tty->driver_data = priv; kgdb_nmi_tty_install()
252 ret = tty_port_install(&priv->port, drv, tty); kgdb_nmi_tty_install()
254 pr_err("%s: can't install tty port: %d\n", __func__, ret); kgdb_nmi_tty_install()
264 static void kgdb_nmi_tty_cleanup(struct tty_struct *tty) kgdb_nmi_tty_cleanup() argument
266 struct kgdb_nmi_tty_priv *priv = tty->driver_data; kgdb_nmi_tty_cleanup()
268 tty->driver_data = NULL; kgdb_nmi_tty_cleanup()
273 static int kgdb_nmi_tty_open(struct tty_struct *tty, struct file *file) kgdb_nmi_tty_open() argument
275 struct kgdb_nmi_tty_priv *priv = tty->driver_data; kgdb_nmi_tty_open()
279 ret = tty_port_open(&priv->port, tty, file); kgdb_nmi_tty_open()
286 static void kgdb_nmi_tty_close(struct tty_struct *tty, struct file *file) kgdb_nmi_tty_close() argument
288 struct kgdb_nmi_tty_priv *priv = tty->driver_data; kgdb_nmi_tty_close()
294 tty_port_close(&priv->port, tty, file); kgdb_nmi_tty_close()
297 static void kgdb_nmi_tty_hangup(struct tty_struct *tty) kgdb_nmi_tty_hangup() argument
299 struct kgdb_nmi_tty_priv *priv = tty->driver_data; kgdb_nmi_tty_hangup()
304 static int kgdb_nmi_tty_write_room(struct tty_struct *tty) kgdb_nmi_tty_write_room() argument
310 static int kgdb_nmi_tty_write(struct tty_struct *tty, const unchar *buf, int c) kgdb_nmi_tty_write() argument
338 pr_err("%s: cannot allocate tty\n", __func__); kgdb_register_nmi_console()
354 pr_err("%s: can't register tty driver: %d\n", __func__, ret); kgdb_register_nmi_console()
H A Dserial_core.c24 #include <linux/tty.h>
54 static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
56 static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
79 tty_wakeup(state->port.tty); uart_write_wakeup()
82 static void uart_stop(struct tty_struct *tty) uart_stop() argument
84 struct uart_state *state = tty->driver_data; uart_stop()
93 static void __uart_start(struct tty_struct *tty) __uart_start() argument
95 struct uart_state *state = tty->driver_data; __uart_start()
102 static void uart_start(struct tty_struct *tty) uart_start() argument
104 struct uart_state *state = tty->driver_data; uart_start()
109 __uart_start(tty); uart_start()
134 static int uart_port_startup(struct tty_struct *tty, struct uart_state *state, uart_port_startup() argument
166 tty->termios.c_cflag = uport->cons->cflag; uart_port_startup()
172 uart_change_speed(tty, state, NULL); uart_port_startup()
179 if (tty->termios.c_cflag & CBAUD) uart_port_startup()
195 static int uart_startup(struct tty_struct *tty, struct uart_state *state, uart_startup() argument
208 set_bit(TTY_IO_ERROR, &tty->flags); uart_startup()
210 retval = uart_port_startup(tty, state, init_hw); uart_startup()
213 clear_bit(TTY_IO_ERROR, &tty->flags); uart_startup()
225 static void uart_shutdown(struct tty_struct *tty, struct uart_state *state) uart_shutdown() argument
233 if (tty) uart_shutdown()
234 set_bit(TTY_IO_ERROR, &tty->flags); uart_shutdown()
240 if (uart_console(uport) && tty) uart_shutdown()
241 uport->cons->cflag = tty->termios.c_cflag; uart_shutdown()
243 if (!tty || (tty->termios.c_cflag & HUPCL)) uart_shutdown()
432 static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, uart_change_speed() argument
440 * If we have no tty, termios, or the port does not exist, uart_change_speed()
443 if (!tty || uport->type == PORT_UNKNOWN) uart_change_speed()
446 termios = &tty->termios; uart_change_speed()
472 __uart_start(tty); uart_change_speed()
496 static int uart_put_char(struct tty_struct *tty, unsigned char ch) uart_put_char() argument
498 struct uart_state *state = tty->driver_data; uart_put_char()
503 static void uart_flush_chars(struct tty_struct *tty) uart_flush_chars() argument
505 uart_start(tty); uart_flush_chars()
508 static int uart_write(struct tty_struct *tty, uart_write() argument
511 struct uart_state *state = tty->driver_data; uart_write()
546 __uart_start(tty); uart_write()
552 static int uart_write_room(struct tty_struct *tty) uart_write_room() argument
554 struct uart_state *state = tty->driver_data; uart_write_room()
564 static int uart_chars_in_buffer(struct tty_struct *tty) uart_chars_in_buffer() argument
566 struct uart_state *state = tty->driver_data; uart_chars_in_buffer()
576 static void uart_flush_buffer(struct tty_struct *tty) uart_flush_buffer() argument
578 struct uart_state *state = tty->driver_data; uart_flush_buffer()
592 pr_debug("uart_flush_buffer(%d) called\n", tty->index); uart_flush_buffer()
599 tty_wakeup(tty); uart_flush_buffer()
606 static void uart_send_xchar(struct tty_struct *tty, char ch) uart_send_xchar() argument
608 struct uart_state *state = tty->driver_data; uart_send_xchar()
623 static void uart_throttle(struct tty_struct *tty) uart_throttle() argument
625 struct uart_state *state = tty->driver_data; uart_throttle()
629 if (I_IXOFF(tty)) uart_throttle()
631 if (tty->termios.c_cflag & CRTSCTS) uart_throttle()
640 uart_send_xchar(tty, STOP_CHAR(tty)); uart_throttle()
646 static void uart_unthrottle(struct tty_struct *tty) uart_unthrottle() argument
648 struct uart_state *state = tty->driver_data; uart_unthrottle()
652 if (I_IXOFF(tty)) uart_unthrottle()
654 if (tty->termios.c_cflag & CRTSCTS) uart_unthrottle()
663 uart_send_xchar(tty, START_CHAR(tty)); uart_unthrottle()
718 static int uart_set_info(struct tty_struct *tty, struct tty_port *port, uart_set_info() argument
802 uart_shutdown(tty, state); uart_set_info()
902 tty_name(port->tty, buf)); uart_set_info()
904 uart_change_speed(tty, state, NULL); uart_set_info()
907 retval = uart_startup(tty, state, 1); uart_set_info()
912 static int uart_set_info_user(struct tty_struct *tty, struct uart_state *state, uart_set_info_user() argument
930 retval = uart_set_info(tty, port, state, &new_serial); uart_set_info_user()
937 * @tty: tty associated with the UART
943 static int uart_get_lsr_info(struct tty_struct *tty, uart_get_lsr_info() argument
965 static int uart_tiocmget(struct tty_struct *tty) uart_tiocmget() argument
967 struct uart_state *state = tty->driver_data; uart_tiocmget()
973 if (!(tty->flags & (1 << TTY_IO_ERROR))) { uart_tiocmget()
985 uart_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) uart_tiocmset() argument
987 struct uart_state *state = tty->driver_data; uart_tiocmset()
993 if (!(tty->flags & (1 << TTY_IO_ERROR))) { uart_tiocmset()
1001 static int uart_break_ctl(struct tty_struct *tty, int break_state) uart_break_ctl() argument
1003 struct uart_state *state = tty->driver_data; uart_break_ctl()
1016 static int uart_do_autoconfig(struct tty_struct *tty,struct uart_state *state) uart_do_autoconfig() argument
1035 uart_shutdown(tty, state); uart_do_autoconfig()
1054 ret = uart_startup(tty, state, 1); uart_do_autoconfig()
1133 static int uart_get_icount(struct tty_struct *tty, uart_get_icount() argument
1136 struct uart_state *state = tty->driver_data; uart_get_icount()
1204 uart_ioctl(struct tty_struct *tty, unsigned int cmd, uart_ioctl() argument
1207 struct uart_state *state = tty->driver_data; uart_ioctl()
1222 down_write(&tty->termios_rwsem); uart_ioctl()
1223 ret = uart_set_info_user(tty, state, uarg); uart_ioctl()
1224 up_write(&tty->termios_rwsem); uart_ioctl()
1228 down_write(&tty->termios_rwsem); uart_ioctl()
1229 ret = uart_do_autoconfig(tty, state); uart_ioctl()
1230 up_write(&tty->termios_rwsem); uart_ioctl()
1242 if (tty->flags & (1 << TTY_IO_ERROR)) { uart_ioctl()
1261 if (tty->flags & (1 << TTY_IO_ERROR)) { uart_ioctl()
1268 * protected against the tty being hung up. uart_ioctl()
1273 ret = uart_get_lsr_info(tty, state, uarg); uart_ioctl()
1296 static void uart_set_ldisc(struct tty_struct *tty) uart_set_ldisc() argument
1298 struct uart_state *state = tty->driver_data; uart_set_ldisc()
1303 uport->ops->set_ldisc(uport, &tty->termios); uart_set_ldisc()
1308 static void uart_set_termios(struct tty_struct *tty, uart_set_termios() argument
1311 struct uart_state *state = tty->driver_data; uart_set_termios()
1313 unsigned int cflag = tty->termios.c_cflag; uart_set_termios()
1324 tty->termios.c_cc[VSTART] != old_termios->c_cc[VSTART] || uart_set_termios()
1325 tty->termios.c_cc[VSTOP] != old_termios->c_cc[VSTOP]; uart_set_termios()
1335 tty->termios.c_ospeed == old_termios->c_ospeed && uart_set_termios()
1336 tty->termios.c_ispeed == old_termios->c_ispeed && uart_set_termios()
1337 ((tty->termios.c_iflag ^ old_termios->c_iflag) & iflag_mask) == 0 && uart_set_termios()
1343 uart_change_speed(tty, state, old_termios); uart_set_termios()
1346 cflag = tty->termios.c_cflag; uart_set_termios()
1354 if (!(cflag & CRTSCTS) || !test_bit(TTY_THROTTLED, &tty->flags)) uart_set_termios()
1362 * drivers/tty/tty_io.c:tty_release()
1363 * drivers/tty/tty_io.c:do_tty_hangup()
1366 static void uart_close(struct tty_struct *tty, struct file *filp) uart_close() argument
1368 struct uart_state *state = tty->driver_data; uart_close()
1374 struct uart_driver *drv = tty->driver->driver_state; uart_close()
1376 state = drv->state + tty->index; uart_close()
1389 if (!port->count || tty_port_close_start(port, tty, filp) == 0) uart_close()
1406 uart_wait_until_sent(tty, uport->timeout); uart_close()
1410 uart_shutdown(tty, state); uart_close()
1437 tty_ldisc_flush(tty); uart_close()
1438 tty->closing = 0; uart_close()
1441 static void uart_wait_until_sent(struct tty_struct *tty, int timeout) uart_wait_until_sent() argument
1443 struct uart_state *state = tty->driver_data; uart_wait_until_sent()
1498 * drivers/tty/tty_io.c:do_tty_hangup()
1501 static void uart_hangup(struct tty_struct *tty) uart_hangup() argument
1503 struct uart_state *state = tty->driver_data; uart_hangup()
1511 uart_flush_buffer(tty); uart_hangup()
1512 uart_shutdown(tty, state); uart_hangup()
1526 static int uart_port_activate(struct tty_port *port, struct tty_struct *tty) uart_port_activate() argument
1583 * drivers/tty/tty_io.c:tty_open()
1591 static int uart_open(struct tty_struct *tty, struct file *filp) uart_open() argument
1593 struct uart_driver *drv = (struct uart_driver *)tty->driver->driver_state; uart_open()
1594 int retval, line = tty->index; uart_open()
1609 * state->port.tty will always contain something reasonable. uart_open()
1621 tty->driver_data = state; uart_open()
1625 tty_port_tty_set(port, tty); uart_open()
1630 retval = uart_startup(tty, state, 0); uart_open()
1637 retval = tty_port_block_til_ready(port, tty, filp); uart_open()
2016 return dev->devt == devt; /* Actually, only one tty per port */ serial_match_port()
2117 * If that's unset, use the tty termios setting. uart_resume_port()
2119 if (port->tty && termios.c_cflag == 0) uart_resume_port()
2120 termios = port->tty->termios; uart_resume_port()
2139 struct tty_struct *tty = port->tty; uart_resume_port() local
2142 if (tty) uart_resume_port()
2143 uart_change_speed(tty, state, NULL); uart_resume_port()
2155 uart_shutdown(tty, state); uart_resume_port()
2381 * with the tty layer, and initialise the core driver per-port state.
2383 * We have a proc file in /proc/tty/driver which is named after the
2724 dev_err(uport->dev, "Cannot register tty device on line %d\n", uart_add_one_port()
2753 struct tty_struct *tty; uart_remove_one_port() local
2778 * Remove the devices from the tty layer uart_remove_one_port()
2782 tty = tty_port_tty_get(port); uart_remove_one_port()
2783 if (tty) { uart_remove_one_port()
2784 tty_vhangup(port->tty); uart_remove_one_port()
2785 tty_kref_put(tty); uart_remove_one_port()
2848 struct tty_struct *tty = port->tty; uart_handle_dcd_change() local
2853 if (tty) { uart_handle_dcd_change()
2854 ld = tty_ldisc_ref(tty); uart_handle_dcd_change()
2857 ld->ops->dcd_change(tty, status); uart_handle_dcd_change()
2867 else if (tty) uart_handle_dcd_change()
2868 tty_hangup(tty); uart_handle_dcd_change()
H A Difx6x60.c42 #include <linux/tty.h>
276 * The SPI has timed out: hang up the tty. Users will then see a hangup
289 /* char/tty operations */
293 * @tty: our tty device
299 static int ifx_spi_tiocmget(struct tty_struct *tty) ifx_spi_tiocmget() argument
302 struct ifx_spi_device *ifx_dev = tty->driver_data; ifx_spi_tiocmget()
316 * @tty: the tty structure
325 static int ifx_spi_tiocmset(struct tty_struct *tty, ifx_spi_tiocmset() argument
328 struct ifx_spi_device *ifx_dev = tty->driver_data; ifx_spi_tiocmset()
344 * ifx_spi_open - called on tty open
345 * @tty: our tty device
346 * @filp: file handle being associated with the tty
348 * Open the tty interface. We let the tty_port layer do all the work
353 static int ifx_spi_open(struct tty_struct *tty, struct file *filp) ifx_spi_open() argument
355 return tty_port_open(&saved_ifx_dev->tty_port, tty, filp); ifx_spi_open()
359 * ifx_spi_close - called when our tty closes
360 * @tty: the tty being closed
363 * Perform the close of the tty. We use the tty_port layer to do all
366 static void ifx_spi_close(struct tty_struct *tty, struct file *filp) ifx_spi_close() argument
368 struct ifx_spi_device *ifx_dev = tty->driver_data; ifx_spi_close()
369 tty_port_close(&ifx_dev->tty_port, tty, filp); ifx_spi_close()
437 * FIXME: performance - should we wake the tty when the queue is half
491 * @tty: our tty device
499 static int ifx_spi_write(struct tty_struct *tty, const unsigned char *buf, ifx_spi_write() argument
502 struct ifx_spi_device *ifx_dev = tty->driver_data; ifx_spi_write()
520 * @tty: our tty device
525 static int ifx_spi_write_room(struct tty_struct *tty) ifx_spi_write_room() argument
527 struct ifx_spi_device *ifx_dev = tty->driver_data; ifx_spi_write_room()
533 * @tty: our tty device
538 static int ifx_spi_chars_in_buffer(struct tty_struct *tty) ifx_spi_chars_in_buffer() argument
540 struct ifx_spi_device *ifx_dev = tty->driver_data; ifx_spi_chars_in_buffer()
546 * @port: our tty port
548 * tty port hang up. Called when tty_hangup processing is invoked either
550 * activate/shutdown by the tty layer.
552 static void ifx_spi_hangup(struct tty_struct *tty) ifx_spi_hangup() argument
554 struct ifx_spi_device *ifx_dev = tty->driver_data; ifx_spi_hangup()
560 * @port: our tty port
562 * tty port activate method - called for first open. Serialized
563 * with hangup and shutdown by the tty layer.
565 static int ifx_port_activate(struct tty_port *port, struct tty_struct *tty) ifx_port_activate() argument
577 /* put port data into this tty */ ifx_port_activate()
578 tty->driver_data = ifx_dev; ifx_port_activate()
591 * @port: our tty port
593 * tty port shutdown method - called for last port close. Serialized
594 * with hangup and activate by the tty layer.
630 * Queue bytes to the tty assuming the tty side is currently open. If
805 * ifx_spi_free_port - free up the tty side
822 * Allocate and initialise the tty port that goes with this interface
823 * and add it to the tty layer so that it can be opened.
846 "%s: registering tty device failed", __func__); ifx_spi_create_port()
1086 /* create our tty port */ ifx_spi_spi_probe()
1089 dev_err(&spi->dev, "create default tty port failed"); ifx_spi_spi_probe()
1202 /* no outgoing tty open at this point, this just satisfies the ifx_spi_spi_probe()
1391 * Initialise the SPI and tty interfaces for the IFX SPI driver
1392 * We need to initialize upper-edge spi driver after the tty
H A Dcrisv10.c18 #include <linux/tty.h>
160 static void rs_throttle(struct tty_struct * tty);
161 static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
162 static int rs_write(struct tty_struct *tty,
165 static int e100_write_rs485(struct tty_struct *tty,
951 tcflag_t cflags = info->port.tty->termios.c_cflag; update_char_time()
1363 e100_enable_rs485(struct tty_struct *tty, struct serial_rs485 *r) e100_enable_rs485() argument
1365 struct e100_serial * info = (struct e100_serial *)tty->driver_data; e100_enable_rs485()
1397 e100_write_rs485(struct tty_struct *tty, e100_write_rs485() argument
1400 struct e100_serial * info = (struct e100_serial *)tty->driver_data; e100_write_rs485()
1410 count = rs_write(tty, buf, count); e100_write_rs485()
1436 * This routines are called before setting or resetting tty->stopped.
1442 rs_stop(struct tty_struct *tty) rs_stop() argument
1444 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_stop()
1455 STOP_CHAR(info->port.tty)); rs_stop()
1457 if (tty->termios.c_iflag & IXON ) { rs_stop()
1467 rs_start(struct tty_struct *tty) rs_start() argument
1469 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_start()
1478 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(tty)); rs_start()
1480 if (tty->termios.c_iflag & IXON ) { rs_start()
1791 if (info->port.tty->stopped) { handle_all_descr_data()
1810 struct tty_struct *tty; receive_chars_dma() local
1818 tty = info->port.tty; receive_chars_dma()
1819 if (!tty) /* Something wrong... */ receive_chars_dma()
2171 will set the flags so the tty will handle it,
2445 if (info->port.tty->stopped) handle_ser_tx_interrupt()
2446 rs_stop(info->port.tty); handle_ser_tx_interrupt()
2459 || info->port.tty->stopped) { handle_ser_tx_interrupt()
2461 info->port.tty->stopped)); handle_ser_tx_interrupt()
2619 struct tty_struct *tty; do_softint() local
2623 tty = info->port.tty; do_softint()
2624 if (!tty) do_softint()
2628 tty_wakeup(tty); do_softint()
2704 if (info->port.tty) startup()
2705 clear_bit(TTY_IO_ERROR, &info->port.tty->flags); startup()
2814 if (!info->port.tty || (info->port.tty->termios.c_cflag & HUPCL)) { shutdown()
2820 if (info->port.tty) shutdown()
2821 set_bit(TTY_IO_ERROR, &info->port.tty->flags); shutdown()
2838 if (!info->port.tty) change_speed()
2843 cflag = info->port.tty->termios.c_cflag; change_speed()
2966 xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty)); change_speed()
2968 if (info->port.tty->termios.c_iflag & IXON ) { change_speed()
2970 STOP_CHAR(info->port.tty))); change_speed()
2984 rs_flush_chars(struct tty_struct *tty) rs_flush_chars() argument
2986 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_flush_chars()
2991 tty->stopped || rs_flush_chars()
3006 static int rs_raw_write(struct tty_struct *tty, rs_raw_write() argument
3010 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_raw_write()
3026 DFLOW(DEBUG_LOG(info->line, "ldisc %i\n", tty->ldisc.chars_in_buffer(tty))); rs_raw_write()
3056 /* enable transmitter if not running, unless the tty is stopped rs_raw_write()
3063 !tty->stopped && rs_raw_write()
3072 rs_write(struct tty_struct *tty, rs_write() argument
3076 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_write()
3098 count = rs_raw_write(tty, buf, count); rs_write()
3112 tty_wait_until_sent(tty, 0); rs_write()
3138 rs_write_room(struct tty_struct *tty) rs_write_room() argument
3140 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_write_room()
3151 rs_chars_in_buffer(struct tty_struct *tty) rs_chars_in_buffer() argument
3153 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_chars_in_buffer()
3161 rs_flush_buffer(struct tty_struct *tty) rs_flush_buffer() argument
3163 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_flush_buffer()
3170 tty_wakeup(tty); rs_flush_buffer()
3182 static void rs_send_xchar(struct tty_struct *tty, char ch) rs_send_xchar() argument
3184 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_send_xchar()
3196 if (tty->stopped) rs_send_xchar()
3197 rs_start(tty); rs_send_xchar()
3210 * This routine is called by the upper-layer tty layer to signal that
3215 rs_throttle(struct tty_struct * tty) rs_throttle() argument
3217 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_throttle()
3221 printk("throttle %s: %lu....\n", tty_name(tty, buf), rs_throttle()
3222 (unsigned long)tty->ldisc.chars_in_buffer(tty)); rs_throttle()
3224 DFLOW(DEBUG_LOG(info->line,"rs_throttle %lu\n", tty->ldisc.chars_in_buffer(tty))); rs_throttle()
3227 if (tty->termios.c_cflag & CRTSCTS) { rs_throttle()
3231 if (I_IXOFF(tty)) rs_throttle()
3232 rs_send_xchar(tty, STOP_CHAR(tty)); rs_throttle()
3237 rs_unthrottle(struct tty_struct * tty) rs_unthrottle() argument
3239 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_unthrottle()
3243 printk("unthrottle %s: %lu....\n", tty_name(tty, buf), rs_unthrottle()
3244 (unsigned long)tty->ldisc.chars_in_buffer(tty)); rs_unthrottle()
3246 DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc %d\n", tty->ldisc.chars_in_buffer(tty))); rs_unthrottle()
3247 DFLOW(DEBUG_LOG(info->line,"rs_unthrottle flip.count: %i\n", tty->flip.count)); rs_unthrottle()
3249 if (tty->termios.c_cflag & CRTSCTS) { rs_unthrottle()
3254 if (I_IXOFF(tty)) { rs_unthrottle()
3258 rs_send_xchar(tty, START_CHAR(tty)); rs_unthrottle()
3414 rs_break(struct tty_struct *tty, int break_state) rs_break() argument
3416 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_break()
3437 rs_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) rs_tiocmset() argument
3439 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_tiocmset()
3469 rs_tiocmget(struct tty_struct *tty) rs_tiocmget() argument
3471 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_tiocmget()
3503 rs_ioctl(struct tty_struct *tty, rs_ioctl() argument
3506 struct e100_serial * info = (struct e100_serial *)tty->driver_data; rs_ioctl()
3511 if (tty->flags & (1 << TTY_IO_ERROR)) rs_ioctl()
3565 return e100_enable_rs485(tty, &rs485data); rs_ioctl()
3577 return e100_enable_rs485(tty, &rs485data); rs_ioctl()
3583 &(((struct e100_serial *)tty->driver_data)->rs485); rs_ioctl()
3599 return e100_write_rs485(tty, rs485wr.outc, rs485wr.outc_size); rs_ioctl()
3610 rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) rs_set_termios() argument
3612 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_set_termios()
3618 !(tty->termios.c_cflag & CRTSCTS)) rs_set_termios()
3619 rs_start(tty); rs_set_termios()
3634 rs_close(struct tty_struct *tty, struct file * filp) rs_close() argument
3636 struct e100_serial * info = (struct e100_serial *)tty->driver_data; rs_close()
3655 if ((tty->count == 1) && (info->port.count != 1)) { rs_close()
3657 * Uh, oh. tty->count is 1, which means that the tty rs_close()
3664 "rs_close: bad serial port count; tty->count is 1, " rs_close()
3682 tty->closing = 1; rs_close()
3684 tty_wait_until_sent(tty, info->port.closing_wait); rs_close()
3702 rs_wait_until_sent(tty, HZ); rs_close()
3706 rs_flush_buffer(tty); rs_close()
3707 tty_ldisc_flush(tty); rs_close()
3708 tty->closing = 0; rs_close()
3710 info->port.tty = NULL; rs_close()
3767 static void rs_wait_until_sent(struct tty_struct *tty, int timeout) rs_wait_until_sent() argument
3770 struct e100_serial *info = (struct e100_serial *)tty->driver_data; rs_wait_until_sent()
3803 rs_hangup(struct tty_struct *tty) rs_hangup() argument
3805 struct e100_serial * info = (struct e100_serial *)tty->driver_data; rs_hangup()
3807 rs_flush_buffer(tty); rs_hangup()
3812 info->port.tty = NULL; rs_hangup()
3822 block_til_ready(struct tty_struct *tty, struct file * filp, block_til_ready() argument
3835 wait_event_interruptible_tty(tty, info->port.close_wait, block_til_ready()
3852 (tty->flags & (1 << TTY_IO_ERROR))) { block_til_ready()
3857 if (tty->termios.c_cflag & CLOCAL) { block_til_ready()
3908 tty_unlock(tty); block_til_ready()
3910 tty_lock(tty); block_til_ready()
3942 * It performs the serial-specific initialization for the tty structure.
3945 rs_open(struct tty_struct *tty, struct file * filp) rs_open() argument
3951 info = rs_table + tty->index; rs_open()
3956 printk("[%d] rs_open %s, count = %d\n", current->pid, tty->name, rs_open()
3961 tty->driver_data = info; rs_open()
3962 info->port.tty = tty; rs_open()
3970 wait_event_interruptible_tty(tty, info->port.close_wait, rs_open()
4061 retval = block_til_ready(tty, filp, info); rs_open()
4117 if (info->port.tty) { seq_line_info()
4118 if (info->port.tty->stopped) seq_line_info()
4120 (int)info->port.tty->stopped); seq_line_info()
4311 info->port.tty = NULL; rs_init()
H A Dtilegx.c24 #include <linux/tty.h>
63 * Read UART rx fifo, and insert the chars into tty buffer.
66 struct tty_struct *tty) receive_chars()
72 struct tty_port *port = tty->port; receive_chars()
88 struct tty_struct *tty = tty_port_tty_get(port); handle_receive() local
91 if (!tty) handle_receive()
95 receive_chars(tile_uart, tty); handle_receive()
104 receive_chars(tile_uart, tty); handle_receive()
109 tty_kref_put(tty); handle_receive()
65 receive_chars(struct tile_uart_port *tile_uart, struct tty_struct *tty) receive_chars() argument
H A Dserial-tegra.c45 #include <linux/tty.h>
510 struct tty_port *tty) tegra_uart_handle_rx_pio()
525 if (!uart_handle_sysrq_char(&tup->uport, ch) && tty) tegra_uart_handle_rx_pio()
526 tty_insert_flip_char(tty, ch, flag); tegra_uart_handle_rx_pio()
533 struct tty_port *tty, int count) tegra_uart_copy_rx_to_tty()
538 if (!tty) { tegra_uart_copy_rx_to_tty()
539 dev_err(tup->uport.dev, "No tty port\n"); tegra_uart_copy_rx_to_tty()
544 copied = tty_insert_flip_string(tty, tegra_uart_copy_rx_to_tty()
548 dev_err(tup->uport.dev, "RxData copy to tty layer failed\n"); tegra_uart_copy_rx_to_tty()
559 struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); tegra_uart_rx_dma_complete() local
575 if (tty) { tegra_uart_rx_dma_complete()
579 tty_kref_put(tty); tegra_uart_rx_dma_complete()
594 struct tty_struct *tty = tty_port_tty_get(&tup->uport.state->port); tegra_uart_handle_rx_dma() local
613 if (tty) { tegra_uart_handle_rx_dma()
617 tty_kref_put(tty); tegra_uart_handle_rx_dma()
738 struct tty_struct *tty; tegra_uart_stop_rx() local
750 tty = tty_port_tty_get(&tup->uport.state->port); tegra_uart_stop_rx()
770 if (tty) { tegra_uart_stop_rx()
772 tty_kref_put(tty); tegra_uart_stop_rx()
509 tegra_uart_handle_rx_pio(struct tegra_uart_port *tup, struct tty_port *tty) tegra_uart_handle_rx_pio() argument
532 tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup, struct tty_port *tty, int count) tegra_uart_copy_rx_to_tty() argument
H A Darc_uart.c16 * -Is uart_tx_stopped() not done in tty write path as it has already been
36 #include <linux/tty.h>
157 * Driver internal routine, used by both tty(serial core) as well as tx-isr
159 * -also tty->stopped has already been checked
185 * If num chars in xmit buffer are too few, ask tty layer for more. arc_serial_tx_chars()
259 * OTOH, Userland output (via tty layer), uses interrupt based writes as there
265 * When tty has some data to send out, serial core calls driver's start_tx
267 * -checks-if-tty-buffer-has-char-to-send
274 * It then calls the exact routine used by tty layer write to send out any
275 * more char in tty buffer. In case of sending, it re-enables Tx-intr. In case
/linux-4.1.27/drivers/bluetooth/
H A Dhci_ldisc.c37 #include <linux/tty.h>
140 struct tty_struct *tty = hu->tty; hci_uart_write_work() local
154 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); hci_uart_write_work()
155 len = tty->ops->write(tty, skb->data, skb->len); hci_uart_write_work()
220 struct tty_struct *tty = hu->tty; hci_uart_flush() local
222 BT_DBG("hdev %p tty %p", hdev, tty); hci_uart_flush()
229 tty_ldisc_flush(tty); hci_uart_flush()
230 tty_driver_flush_buffer(tty); hci_uart_flush()
322 * tty pointer to tty info structure
326 static int hci_uart_tty_open(struct tty_struct *tty) hci_uart_tty_open() argument
330 BT_DBG("tty %p", tty); hci_uart_tty_open()
332 /* Error if the tty has no write op instead of leaving an exploitable hci_uart_tty_open()
334 if (tty->ops->write == NULL) hci_uart_tty_open()
343 tty->disc_data = hu; hci_uart_tty_open()
344 hu->tty = tty; hci_uart_tty_open()
345 tty->receive_room = 65536; hci_uart_tty_open()
357 if (tty->ldisc->ops->flush_buffer) hci_uart_tty_open()
358 tty->ldisc->ops->flush_buffer(tty); hci_uart_tty_open()
359 tty_driver_flush_buffer(tty); hci_uart_tty_open()
367 * else, the tty is closed, or the tty detects a hangup.
369 static void hci_uart_tty_close(struct tty_struct *tty) hci_uart_tty_close() argument
371 struct hci_uart *hu = tty->disc_data; hci_uart_tty_close()
374 BT_DBG("tty %p", tty); hci_uart_tty_close()
376 /* Detach from the tty */ hci_uart_tty_close()
377 tty->disc_data = NULL; hci_uart_tty_close()
405 * Arguments: tty pointer to associated tty instance data
408 static void hci_uart_tty_wakeup(struct tty_struct *tty) hci_uart_tty_wakeup() argument
410 struct hci_uart *hu = tty->disc_data; hci_uart_tty_wakeup()
417 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); hci_uart_tty_wakeup()
419 if (tty != hu->tty) hci_uart_tty_wakeup()
428 * Called by tty low level driver when receive data is
431 * Arguments: tty pointer to tty isntance data
438 static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, hci_uart_tty_receive() argument
441 struct hci_uart *hu = tty->disc_data; hci_uart_tty_receive()
443 if (!hu || tty != hu->tty) hci_uart_tty_receive()
457 tty_unthrottle(tty); hci_uart_tty_receive()
483 SET_HCIDEV_DEV(hdev, hu->tty->dev); hci_uart_register_dev()
556 * Process IOCTL system call for the tty device.
560 * tty pointer to tty instance data
567 static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file *file, hci_uart_tty_ioctl() argument
570 struct hci_uart *hu = tty->disc_data; hci_uart_tty_ioctl()
613 err = n_tty_ioctl_helper(tty, file, cmd, arg); hci_uart_tty_ioctl()
623 static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, hci_uart_tty_read() argument
629 static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, hci_uart_tty_write() argument
635 static unsigned int hci_uart_tty_poll(struct tty_struct *tty, hci_uart_tty_poll() argument
648 /* Register the tty discipline */ hci_uart_init()
714 /* Release tty registration of line discipline */ hci_uart_exit()
H A Dhci_ath.c34 #include <linux/tty.h>
53 static int ath_wakeup_ar3k(struct tty_struct *tty) ath_wakeup_ar3k() argument
55 int status = tty->driver->ops->tiocmget(tty); ath_wakeup_ar3k()
61 tty->driver->ops->tiocmget(tty); ath_wakeup_ar3k()
62 tty->driver->ops->tiocmset(tty, 0x00, TIOCM_RTS); ath_wakeup_ar3k()
66 tty->driver->ops->tiocmget(tty); ath_wakeup_ar3k()
67 tty->driver->ops->tiocmset(tty, TIOCM_RTS, 0x00); ath_wakeup_ar3k()
70 status = tty->driver->ops->tiocmget(tty); ath_wakeup_ar3k()
79 struct tty_struct *tty; ath_hci_uart_work() local
84 tty = hu->tty; ath_hci_uart_work()
88 status = ath_wakeup_ar3k(tty); ath_hci_uart_work()
/linux-4.1.27/arch/um/drivers/
H A Dline.h11 #include <linux/tty.h>
59 extern void line_close(struct tty_struct *tty, struct file * filp);
60 extern int line_open(struct tty_struct *tty, struct file *filp);
61 extern int line_install(struct tty_driver *driver, struct tty_struct *tty,
63 extern void line_cleanup(struct tty_struct *tty);
64 extern void line_hangup(struct tty_struct *tty);
67 extern int line_write(struct tty_struct *tty, const unsigned char *buf,
69 extern int line_put_char(struct tty_struct *tty, unsigned char ch);
70 extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
71 extern int line_chars_in_buffer(struct tty_struct *tty);
72 extern void line_flush_buffer(struct tty_struct *tty);
73 extern void line_flush_chars(struct tty_struct *tty);
74 extern int line_write_room(struct tty_struct *tty);
75 extern void line_throttle(struct tty_struct *tty);
76 extern void line_unthrottle(struct tty_struct *tty);
H A Dline.c49 int line_write_room(struct tty_struct *tty) line_write_room() argument
51 struct line *line = tty->driver_data; line_write_room()
62 int line_chars_in_buffer(struct tty_struct *tty) line_chars_in_buffer() argument
64 struct line *line = tty->driver_data; line_chars_in_buffer()
167 void line_flush_buffer(struct tty_struct *tty) line_flush_buffer() argument
169 struct line *line = tty->driver_data; line_flush_buffer()
181 void line_flush_chars(struct tty_struct *tty) line_flush_chars() argument
183 line_flush_buffer(tty); line_flush_chars()
186 int line_put_char(struct tty_struct *tty, unsigned char ch) line_put_char() argument
188 return line_write(tty, &ch, sizeof(ch)); line_put_char()
191 int line_write(struct tty_struct *tty, const unsigned char *buf, int len) line_write() argument
193 struct line *line = tty->driver_data; line_write()
218 void line_set_termios(struct tty_struct *tty, struct ktermios * old) line_set_termios() argument
223 void line_throttle(struct tty_struct *tty) line_throttle() argument
225 struct line *line = tty->driver_data; line_throttle()
231 void line_unthrottle(struct tty_struct *tty) line_unthrottle() argument
233 struct line *line = tty->driver_data; line_unthrottle()
292 static int line_activate(struct tty_port *port, struct tty_struct *tty) line_activate() argument
295 struct line *line = tty->driver_data; line_activate()
306 chan_window_size(line, &tty->winsize.ws_row, line_activate()
307 &tty->winsize.ws_col); line_activate()
312 static void unregister_winch(struct tty_struct *tty);
316 struct tty_struct *tty = tty_port_tty_get(port); line_destruct() local
317 struct line *line = tty->driver_data; line_destruct()
320 unregister_winch(tty); line_destruct()
330 int line_open(struct tty_struct *tty, struct file *filp) line_open() argument
332 struct line *line = tty->driver_data; line_open()
334 return tty_port_open(&line->port, tty, filp); line_open()
337 int line_install(struct tty_driver *driver, struct tty_struct *tty, line_install() argument
342 ret = tty_standard_install(driver, tty); line_install()
346 tty->driver_data = line; line_install()
351 void line_close(struct tty_struct *tty, struct file * filp) line_close() argument
353 struct line *line = tty->driver_data; line_close()
355 tty_port_close(&line->port, tty, filp); line_close()
358 void line_hangup(struct tty_struct *tty) line_hangup() argument
360 struct line *line = tty->driver_data; line_hangup()
512 struct tty_struct *tty = tty_port_tty_get(&line->port); line_get_config() local
513 if (tty == NULL) { line_get_config()
517 tty_kref_put(tty); line_get_config()
630 struct tty_struct *tty; winch_interrupt() local
655 tty = tty_port_tty_get(winch->port); winch_interrupt()
656 if (tty != NULL) { winch_interrupt()
657 line = tty->driver_data; winch_interrupt()
659 chan_window_size(line, &tty->winsize.ws_row, winch_interrupt()
660 &tty->winsize.ws_col); winch_interrupt()
661 pgrp = tty_get_pgrp(tty); winch_interrupt()
666 tty_kref_put(tty); winch_interrupt()
714 static void unregister_winch(struct tty_struct *tty) unregister_winch() argument
725 if (wtty == tty) { unregister_winch()
H A Dstdio_console.c7 #include <linux/tty.h>
51 .device_name = "tty",
95 static int con_install(struct tty_driver *driver, struct tty_struct *tty) con_install() argument
97 return line_install(driver, tty, &vts[tty->index]); con_install()
142 .name = "tty",
H A DMakefile57 obj-$(CONFIG_TTY_CHAN) += tty.o
64 USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o pcap_user.o vde_user.o
H A Dtty.c24 printk(UM_KERN_ERR "tty_init : channel type 'tty' must specify " tty_chan_init()
71 .type = "tty",
H A Dssl.c7 #include <linux/tty.h>
90 static int ssl_install(struct tty_driver *driver, struct tty_struct *tty) ssl_install() argument
92 return line_install(driver, tty, &serial_lines[tty->index]); ssl_install()
H A Dchan.h9 #include <linux/tty.h>
/linux-4.1.27/drivers/isdn/gigaset/
H A Dinterface.c116 static int if_open(struct tty_struct *tty, struct file *filp) if_open() argument
121 tty->driver->minor_start, tty->index, __func__); if_open()
123 cs = gigaset_get_cs_by_tty(tty); if_open()
131 tty->driver_data = cs; if_open()
136 tty_port_tty_set(&cs->port, tty); if_open()
144 static void if_close(struct tty_struct *tty, struct file *filp) if_close() argument
146 struct cardstate *cs = tty->driver_data; if_close()
169 static int if_ioctl(struct tty_struct *tty, if_ioctl() argument
172 struct cardstate *cs = tty->driver_data; if_ioctl()
236 static int if_tiocmget(struct tty_struct *tty) if_tiocmget() argument
238 struct cardstate *cs = tty->driver_data; if_tiocmget()
253 static int if_tiocmset(struct tty_struct *tty, if_tiocmset() argument
256 struct cardstate *cs = tty->driver_data; if_tiocmset()
280 static int if_write(struct tty_struct *tty, const unsigned char *buf, int count) if_write() argument
282 struct cardstate *cs = tty->driver_data; if_write()
325 static int if_write_room(struct tty_struct *tty) if_write_room() argument
327 struct cardstate *cs = tty->driver_data; if_write_room()
349 static int if_chars_in_buffer(struct tty_struct *tty) if_chars_in_buffer() argument
351 struct cardstate *cs = tty->driver_data; if_chars_in_buffer()
370 static void if_throttle(struct tty_struct *tty) if_throttle() argument
372 struct cardstate *cs = tty->driver_data; if_throttle()
386 static void if_unthrottle(struct tty_struct *tty) if_unthrottle() argument
388 struct cardstate *cs = tty->driver_data; if_unthrottle()
402 static void if_set_termios(struct tty_struct *tty, struct ktermios *old) if_set_termios() argument
404 struct cardstate *cs = tty->driver_data; if_set_termios()
419 iflag = tty->termios.c_iflag; if_set_termios()
420 cflag = tty->termios.c_cflag; if_set_termios()
507 cs->tty_dev = tty_port_register_device(&cs->port, drv->tty, gigaset_if_init()
513 pr_warning("could not register device to the tty subsystem\n"); gigaset_if_init()
530 tty_unregister_device(drv->tty, cs->minor_index); gigaset_if_free()
534 * gigaset_if_receive() - pass a received block of data to the tty device
551 * Initialize tty interface.
554 * procname Name of the driver (e.g. for /proc/tty/drivers)
561 struct tty_driver *tty; gigaset_if_initdriver() local
565 drv->tty = tty = alloc_tty_driver(drv->minors); gigaset_if_initdriver()
566 if (tty == NULL) gigaset_if_initdriver()
569 tty->type = TTY_DRIVER_TYPE_SERIAL; gigaset_if_initdriver()
570 tty->subtype = SERIAL_TYPE_NORMAL; gigaset_if_initdriver()
571 tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; gigaset_if_initdriver()
573 tty->driver_name = procname; gigaset_if_initdriver()
574 tty->name = devname; gigaset_if_initdriver()
575 tty->minor_start = drv->minor; gigaset_if_initdriver()
577 tty->init_termios = tty_std_termios; gigaset_if_initdriver()
578 tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; gigaset_if_initdriver()
579 tty_set_operations(tty, &if_ops); gigaset_if_initdriver()
581 ret = tty_register_driver(tty); gigaset_if_initdriver()
583 pr_err("error %d registering tty driver\n", ret); gigaset_if_initdriver()
586 gig_dbg(DEBUG_IF, "tty driver initialized"); gigaset_if_initdriver()
593 if (drv->tty) gigaset_if_initdriver()
594 put_tty_driver(drv->tty); gigaset_if_initdriver()
603 tty_unregister_driver(drv->tty); gigaset_if_freedriver()
604 put_tty_driver(drv->tty); gigaset_if_freedriver()
H A Dser-gigaset.c47 struct tty_struct *tty; member in struct:ser_cardstate
65 struct tty_struct *tty = cs->hw.ser->tty; write_modem() local
70 if (!tty || !tty->driver || !skb) write_modem()
79 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); write_modem()
80 if (tty->ops->write) write_modem()
81 sent = tty->ops->write(tty, skb->data, skb->len); write_modem()
107 struct tty_struct *tty = cs->hw.ser->tty; send_cb() local
112 if (!tty || !tty->driver) send_cb()
120 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); send_cb()
121 sent = tty->ops->write(tty, cb->buf + cb->offset, cb->len); send_cb()
432 struct tty_struct *tty = cs->hw.ser->tty; gigaset_set_modem_ctrl() local
435 if (!tty || !tty->driver || !tty->ops->tiocmset) gigaset_set_modem_ctrl()
442 return tty->ops->tiocmset(tty, set, clear); gigaset_set_modem_ctrl()
479 static struct cardstate *cs_get(struct tty_struct *tty) cs_get() argument
481 struct cardstate *cs = tty->disc_data; cs_get()
498 * Called by the tty driver when the line discipline is pushed onto the tty.
502 gigaset_tty_open(struct tty_struct *tty) gigaset_tty_open() argument
524 cs->hw.ser->tty = tty; gigaset_tty_open()
527 tty->disc_data = cs; gigaset_tty_open()
537 tty->receive_room = RBUFSIZE/2; gigaset_tty_open()
555 tty->disc_data = NULL; gigaset_tty_open()
561 * Called by the tty driver when the line discipline is removed.
565 gigaset_tty_close(struct tty_struct *tty) gigaset_tty_close() argument
567 struct cardstate *cs = tty->disc_data; gigaset_tty_close()
577 tty->disc_data = NULL; gigaset_tty_close()
598 * Called by the tty driver when the tty line is hung up.
603 static int gigaset_tty_hangup(struct tty_struct *tty) gigaset_tty_hangup() argument
605 gigaset_tty_close(tty); gigaset_tty_hangup()
610 * Read on the tty.
614 gigaset_tty_read(struct tty_struct *tty, struct file *file, gigaset_tty_read() argument
621 * Write on the tty.
625 gigaset_tty_write(struct tty_struct *tty, struct file *file, gigaset_tty_write() argument
632 * Ioctl on the tty.
637 gigaset_tty_ioctl(struct tty_struct *tty, struct file *file, gigaset_tty_ioctl() argument
640 struct cardstate *cs = cs_get(tty); gigaset_tty_ioctl()
670 rc = n_tty_ioctl_helper(tty, file, cmd, arg); gigaset_tty_ioctl()
678 * Called by the tty driver when a block of data has been received.
684 * tty tty structure
690 gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf, gigaset_tty_receive() argument
693 struct cardstate *cs = cs_get(tty); gigaset_tty_receive()
743 * Called by the tty driver when there's room for more data to send.
746 gigaset_tty_wakeup(struct tty_struct *tty) gigaset_tty_wakeup() argument
748 struct cardstate *cs = cs_get(tty); gigaset_tty_wakeup()
750 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); gigaset_tty_wakeup()
/linux-4.1.27/drivers/input/serio/
H A Dserport.c6 * This is a module that converts a tty line into a much simpler
23 #include <linux/tty.h>
36 struct tty_struct *tty; member in struct:serport
51 return -(serport->tty->ops->write(serport->tty, &data, 1) != 1); serport_serio_write()
82 * discipline on a tty. It prepares the serio struct.
85 static int serport_ldisc_open(struct tty_struct *tty) serport_ldisc_open() argument
96 serport->tty = tty; serport_ldisc_open()
100 tty->disc_data = serport; serport_ldisc_open()
101 tty->receive_room = 256; serport_ldisc_open()
102 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); serport_ldisc_open()
111 static void serport_ldisc_close(struct tty_struct *tty) serport_ldisc_close() argument
113 struct serport *serport = (struct serport *) tty->disc_data; serport_ldisc_close()
119 * serport_ldisc_receive() is called by the low level tty driver when characters
124 static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) serport_ldisc_receive() argument
126 struct serport *serport = (struct serport*) tty->disc_data; serport_ldisc_receive()
166 static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, unsigned char __user * buf, size_t nr) serport_ldisc_read() argument
168 struct serport *serport = (struct serport*) tty->disc_data; serport_ldisc_read()
180 snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", tty_name(tty, name)); serport_ldisc_read()
187 serio->dev.parent = tty->dev; serport_ldisc_read()
190 printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name)); serport_ldisc_read()
202 static void serport_set_type(struct tty_struct *tty, unsigned long type) serport_set_type() argument
204 struct serport *serport = tty->disc_data; serport_set_type()
215 static int serport_ldisc_ioctl(struct tty_struct *tty, struct file *file, serport_ldisc_ioctl() argument
224 serport_set_type(tty, type); serport_ldisc_ioctl()
233 static long serport_ldisc_compat_ioctl(struct tty_struct *tty, serport_ldisc_compat_ioctl() argument
244 serport_set_type(tty, compat_type); serport_ldisc_compat_ioctl()
252 static void serport_ldisc_write_wakeup(struct tty_struct * tty) serport_ldisc_write_wakeup() argument
254 struct serport *serport = (struct serport *) tty->disc_data; serport_ldisc_write_wakeup()
/linux-4.1.27/arch/ia64/hp/sim/
H A Dsimserial.c17 #include <linux/tty.h>
108 static int rs_put_char(struct tty_struct *tty, unsigned char ch) rs_put_char() argument
110 struct serial_state *info = tty->driver_data; rs_put_char()
127 static void transmit_chars(struct tty_struct *tty, struct serial_state *info, transmit_chars() argument
145 if (info->xmit.head == info->xmit.tail || tty->stopped) { transmit_chars()
148 info->xmit.head, info->xmit.tail, tty->stopped); transmit_chars()
178 static void rs_flush_chars(struct tty_struct *tty) rs_flush_chars() argument
180 struct serial_state *info = tty->driver_data; rs_flush_chars()
182 if (info->xmit.head == info->xmit.tail || tty->stopped || rs_flush_chars()
186 transmit_chars(tty, info, NULL); rs_flush_chars()
189 static int rs_write(struct tty_struct * tty, rs_write() argument
192 struct serial_state *info = tty->driver_data; rs_write()
219 !tty->stopped) rs_write()
220 transmit_chars(tty, info, NULL); rs_write()
225 static int rs_write_room(struct tty_struct *tty) rs_write_room() argument
227 struct serial_state *info = tty->driver_data; rs_write_room()
232 static int rs_chars_in_buffer(struct tty_struct *tty) rs_chars_in_buffer() argument
234 struct serial_state *info = tty->driver_data; rs_chars_in_buffer()
239 static void rs_flush_buffer(struct tty_struct *tty) rs_flush_buffer() argument
241 struct serial_state *info = tty->driver_data; rs_flush_buffer()
248 tty_wakeup(tty); rs_flush_buffer()
255 static void rs_send_xchar(struct tty_struct *tty, char ch) rs_send_xchar() argument
257 struct serial_state *info = tty->driver_data; rs_send_xchar()
265 transmit_chars(tty, info, NULL); rs_send_xchar()
273 * This routine is called by the upper-layer tty layer to signal that
277 static void rs_throttle(struct tty_struct * tty) rs_throttle() argument
279 if (I_IXOFF(tty)) rs_throttle()
280 rs_send_xchar(tty, STOP_CHAR(tty)); rs_throttle()
285 static void rs_unthrottle(struct tty_struct * tty) rs_unthrottle() argument
287 struct serial_state *info = tty->driver_data; rs_unthrottle()
289 if (I_IXOFF(tty)) { rs_unthrottle()
293 rs_send_xchar(tty, START_CHAR(tty)); rs_unthrottle()
298 static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) rs_ioctl() argument
303 if (tty->flags & (1 << TTY_IO_ERROR)) rs_ioctl()
348 static void rs_close(struct tty_struct *tty, struct file * filp) rs_close() argument
350 struct serial_state *info = tty->driver_data; rs_close()
352 tty_port_close(&info->port, tty, filp); rs_close()
355 static void rs_hangup(struct tty_struct *tty) rs_hangup() argument
357 struct serial_state *info = tty->driver_data; rs_hangup()
359 rs_flush_buffer(tty); rs_hangup()
363 static int activate(struct tty_port *port, struct tty_struct *tty) activate() argument
391 * Set up the tty->alt_speed kludge activate()
394 tty->alt_speed = 57600; activate()
396 tty->alt_speed = 115200; activate()
398 tty->alt_speed = 230400; activate()
400 tty->alt_speed = 460800; activate()
412 * initialization for the tty structure.
414 static int rs_open(struct tty_struct *tty, struct file * filp) rs_open() argument
416 struct serial_state *info = rs_table + tty->index; rs_open()
419 tty->driver_data = info; rs_open()
431 return tty_port_open(port, tty, filp); rs_open()
H A Dhpsim_console.c14 #include <linux/tty.h>
/linux-4.1.27/drivers/usb/serial/
H A Dusb-wwan.h9 extern int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port);
13 extern int usb_wwan_write_room(struct tty_struct *tty);
14 extern int usb_wwan_tiocmget(struct tty_struct *tty);
15 extern int usb_wwan_tiocmset(struct tty_struct *tty,
17 extern int usb_wwan_ioctl(struct tty_struct *tty,
19 extern int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
21 extern int usb_wwan_chars_in_buffer(struct tty_struct *tty);
H A Dconsole.c19 #include <linux/tty.h>
70 struct tty_struct *tty = NULL; usb_console_setup() local
133 * allocate a fake tty so the driver can initialize usb_console_setup()
137 tty = kzalloc(sizeof(*tty), GFP_KERNEL); usb_console_setup()
138 if (!tty) { usb_console_setup()
142 kref_init(&tty->kref); usb_console_setup()
143 tty->driver = usb_serial_tty_driver; usb_console_setup()
144 tty->index = co->index; usb_console_setup()
145 init_ldsem(&tty->ldisc_sem); usb_console_setup()
146 INIT_LIST_HEAD(&tty->tty_files); usb_console_setup()
147 kref_get(&tty->driver->kref); usb_console_setup()
148 __module_get(tty->driver->owner); usb_console_setup()
149 tty->ops = &usb_console_fake_tty_ops; usb_console_setup()
150 if (tty_init_termios(tty)) { usb_console_setup()
154 tty_port_tty_set(&port->port, tty); usb_console_setup()
166 tty->termios.c_cflag = cflag; usb_console_setup()
167 tty_termios_encode_baud_rate(&tty->termios, baud, baud); usb_console_setup()
169 serial->type->set_termios(tty, port, &dummy); usb_console_setup()
172 tty_kref_put(tty); usb_console_setup()
176 /* Now that any required fake tty operations are completed restore usb_console_setup()
177 * the tty port count */ usb_console_setup()
189 tty_kref_put(tty); usb_console_setup()
H A Dusb-serial.c26 #include <linux/tty.h>
162 * Driver tty interface functions
166 * serial_install - install tty
168 * @tty: the tty being created
170 * Create the termios objects for this tty. We use the default
174 * This is the first place a new tty gets used. Hence this is where we
179 static int serial_install(struct tty_driver *driver, struct tty_struct *tty) serial_install() argument
181 int idx = tty->index; serial_install()
198 retval = tty_port_install(&port->port, driver, tty); serial_install()
206 serial->type->init_termios(tty); serial_install()
208 tty->driver_data = port; serial_install()
222 static int serial_port_activate(struct tty_port *tport, struct tty_struct *tty) serial_port_activate() argument
233 retval = port->serial->type->open(tty, port); serial_port_activate()
242 static int serial_open(struct tty_struct *tty, struct file *filp) serial_open() argument
244 struct usb_serial_port *port = tty->driver_data; serial_open()
246 dev_dbg(tty->dev, "%s\n", __func__); serial_open()
248 return tty_port_open(&port->port, tty, filp); serial_open()
253 * @tport: tty port to shut down
259 * Not called if tty is console.
271 static void serial_hangup(struct tty_struct *tty) serial_hangup() argument
273 struct usb_serial_port *port = tty->driver_data; serial_hangup()
275 dev_dbg(tty->dev, "%s\n", __func__); serial_hangup()
280 static void serial_close(struct tty_struct *tty, struct file *filp) serial_close() argument
282 struct usb_serial_port *port = tty->driver_data; serial_close()
284 dev_dbg(tty->dev, "%s\n", __func__); serial_close()
286 tty_port_close(&port->port, tty, filp); serial_close()
296 * Called asynchronously after the last tty kref is dropped.
298 static void serial_cleanup(struct tty_struct *tty) serial_cleanup() argument
300 struct usb_serial_port *port = tty->driver_data; serial_cleanup()
304 dev_dbg(tty->dev, "%s\n", __func__); serial_cleanup()
312 tty->driver_data = NULL; serial_cleanup()
326 static int serial_write(struct tty_struct *tty, const unsigned char *buf, serial_write() argument
329 struct usb_serial_port *port = tty->driver_data; serial_write()
335 dev_dbg(tty->dev, "%s - %d byte(s)\n", __func__, count); serial_write()
337 retval = port->serial->type->write(tty, port, buf, count); serial_write()
344 static int serial_write_room(struct tty_struct *tty) serial_write_room() argument
346 struct usb_serial_port *port = tty->driver_data; serial_write_room()
348 dev_dbg(tty->dev, "%s\n", __func__); serial_write_room()
350 return port->serial->type->write_room(tty); serial_write_room()
353 static int serial_chars_in_buffer(struct tty_struct *tty) serial_chars_in_buffer() argument
355 struct usb_serial_port *port = tty->driver_data; serial_chars_in_buffer()
358 dev_dbg(tty->dev, "%s\n", __func__); serial_chars_in_buffer()
363 return serial->type->chars_in_buffer(tty); serial_chars_in_buffer()
366 static void serial_wait_until_sent(struct tty_struct *tty, int timeout) serial_wait_until_sent() argument
368 struct usb_serial_port *port = tty->driver_data; serial_wait_until_sent()
371 dev_dbg(tty->dev, "%s\n", __func__); serial_wait_until_sent()
378 port->serial->type->wait_until_sent(tty, timeout); serial_wait_until_sent()
382 static void serial_throttle(struct tty_struct *tty) serial_throttle() argument
384 struct usb_serial_port *port = tty->driver_data; serial_throttle()
386 dev_dbg(tty->dev, "%s\n", __func__); serial_throttle()
389 port->serial->type->throttle(tty); serial_throttle()
392 static void serial_unthrottle(struct tty_struct *tty) serial_unthrottle() argument
394 struct usb_serial_port *port = tty->driver_data; serial_unthrottle()
396 dev_dbg(tty->dev, "%s\n", __func__); serial_unthrottle()
399 port->serial->type->unthrottle(tty); serial_unthrottle()
402 static int serial_ioctl(struct tty_struct *tty, serial_ioctl() argument
405 struct usb_serial_port *port = tty->driver_data; serial_ioctl()
408 dev_dbg(tty->dev, "%s - cmd 0x%04x\n", __func__, cmd); serial_ioctl()
413 retval = port->serial->type->tiocmiwait(tty, arg); serial_ioctl()
417 retval = port->serial->type->ioctl(tty, cmd, arg); serial_ioctl()
423 static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) serial_set_termios() argument
425 struct usb_serial_port *port = tty->driver_data; serial_set_termios()
427 dev_dbg(tty->dev, "%s\n", __func__); serial_set_termios()
430 port->serial->type->set_termios(tty, port, old); serial_set_termios()
432 tty_termios_copy_hw(&tty->termios, old); serial_set_termios()
435 static int serial_break(struct tty_struct *tty, int break_state) serial_break() argument
437 struct usb_serial_port *port = tty->driver_data; serial_break()
439 dev_dbg(tty->dev, "%s\n", __func__); serial_break()
442 port->serial->type->break_ctl(tty, break_state); serial_break()
495 static int serial_tiocmget(struct tty_struct *tty) serial_tiocmget() argument
497 struct usb_serial_port *port = tty->driver_data; serial_tiocmget()
499 dev_dbg(tty->dev, "%s\n", __func__); serial_tiocmget()
502 return port->serial->type->tiocmget(tty); serial_tiocmget()
506 static int serial_tiocmset(struct tty_struct *tty, serial_tiocmset() argument
509 struct usb_serial_port *port = tty->driver_data; serial_tiocmset()
511 dev_dbg(tty->dev, "%s\n", __func__); serial_tiocmset()
514 return port->serial->type->tiocmset(tty, set, clear); serial_tiocmset()
518 static int serial_get_icount(struct tty_struct *tty, serial_get_icount() argument
521 struct usb_serial_port *port = tty->driver_data; serial_get_icount()
523 dev_dbg(tty->dev, "%s\n", __func__); serial_get_icount()
526 return port->serial->type->get_icount(tty, icount); serial_get_icount()
532 * disciplines have an annoying habit of calling tty->write from
1097 struct tty_struct *tty; usb_serial_disconnect() local
1108 tty = tty_port_tty_get(&port->port); usb_serial_disconnect()
1109 if (tty) { usb_serial_disconnect()
1110 tty_vhangup(tty); usb_serial_disconnect()
1111 tty_kref_put(tty); usb_serial_disconnect()
H A Dgeneric.c16 #include <linux/tty.h>
80 int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port) usb_serial_generic_open() argument
183 * @tty: tty for the port
191 int usb_serial_generic_write(struct tty_struct *tty, usb_serial_generic_write() argument
211 int usb_serial_generic_write_room(struct tty_struct *tty) usb_serial_generic_write_room() argument
213 struct usb_serial_port *port = tty->driver_data; usb_serial_generic_write_room()
228 int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) usb_serial_generic_chars_in_buffer() argument
230 struct usb_serial_port *port = tty->driver_data; usb_serial_generic_chars_in_buffer()
246 void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout) usb_serial_generic_wait_until_sent() argument
248 struct usb_serial_port *port = tty->driver_data; usb_serial_generic_wait_until_sent()
253 bps = tty_get_baud_rate(tty); usb_serial_generic_wait_until_sent()
386 /* Throttle the device if requested by tty */ usb_serial_generic_read_bulk_callback()
438 void usb_serial_generic_throttle(struct tty_struct *tty) usb_serial_generic_throttle() argument
440 struct usb_serial_port *port = tty->driver_data; usb_serial_generic_throttle()
449 void usb_serial_generic_unthrottle(struct tty_struct *tty) usb_serial_generic_unthrottle() argument
451 struct usb_serial_port *port = tty->driver_data; usb_serial_generic_unthrottle()
464 static bool usb_serial_generic_msr_changed(struct tty_struct *tty, usb_serial_generic_msr_changed() argument
467 struct usb_serial_port *port = tty->driver_data; usb_serial_generic_msr_changed()
473 * Use tty-port initialised flag to detect all hangups including the usb_serial_generic_msr_changed()
493 int usb_serial_generic_tiocmiwait(struct tty_struct *tty, unsigned long arg) usb_serial_generic_tiocmiwait() argument
495 struct usb_serial_port *port = tty->driver_data; usb_serial_generic_tiocmiwait()
505 usb_serial_generic_msr_changed(tty, arg, &cnow)); usb_serial_generic_tiocmiwait()
513 int usb_serial_generic_get_icount(struct tty_struct *tty, usb_serial_generic_get_icount() argument
516 struct usb_serial_port *port = tty->driver_data; usb_serial_generic_get_icount()
575 * @tty: tty for the port
579 struct tty_struct *tty, unsigned int status) usb_serial_handle_dcd_change()
585 if (tty) { usb_serial_handle_dcd_change()
586 struct tty_ldisc *ld = tty_ldisc_ref(tty); usb_serial_handle_dcd_change()
590 ld->ops->dcd_change(tty, status); usb_serial_handle_dcd_change()
597 else if (tty && !C_CLOCAL(tty)) usb_serial_handle_dcd_change()
598 tty_hangup(tty); usb_serial_handle_dcd_change()
578 usb_serial_handle_dcd_change(struct usb_serial_port *usb_port, struct tty_struct *tty, unsigned int status) usb_serial_handle_dcd_change() argument
H A Dti_usb_3410_5052.c25 #include <linux/tty.h>
93 static int ti_open(struct tty_struct *tty, struct usb_serial_port *port);
95 static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
97 static int ti_write_room(struct tty_struct *tty);
98 static int ti_chars_in_buffer(struct tty_struct *tty);
100 static void ti_throttle(struct tty_struct *tty);
101 static void ti_unthrottle(struct tty_struct *tty);
102 static int ti_ioctl(struct tty_struct *tty,
104 static void ti_set_termios(struct tty_struct *tty,
106 static int ti_tiocmget(struct tty_struct *tty);
107 static int ti_tiocmset(struct tty_struct *tty,
109 static void ti_break(struct tty_struct *tty, int break_state);
121 static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
125 static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty);
126 static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty);
393 static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) ti_open() argument
437 if (tty) ti_open()
438 ti_set_termios(tty, port, &tty->termios); ti_open()
479 if (tty) ti_open()
480 ti_set_termios(tty, port, &tty->termios); ti_open()
578 static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, ti_write() argument
599 static int ti_write_room(struct tty_struct *tty) ti_write_room() argument
601 struct usb_serial_port *port = tty->driver_data; ti_write_room()
618 static int ti_chars_in_buffer(struct tty_struct *tty) ti_chars_in_buffer() argument
620 struct usb_serial_port *port = tty->driver_data; ti_chars_in_buffer()
649 static void ti_throttle(struct tty_struct *tty) ti_throttle() argument
651 struct usb_serial_port *port = tty->driver_data; ti_throttle()
657 if (I_IXOFF(tty) || C_CRTSCTS(tty)) ti_throttle()
658 ti_stop_read(tport, tty); ti_throttle()
663 static void ti_unthrottle(struct tty_struct *tty) ti_unthrottle() argument
665 struct usb_serial_port *port = tty->driver_data; ti_unthrottle()
672 if (I_IXOFF(tty) || C_CRTSCTS(tty)) { ti_unthrottle()
673 status = ti_restart_read(tport, tty); ti_unthrottle()
680 static int ti_ioctl(struct tty_struct *tty, ti_ioctl() argument
683 struct usb_serial_port *port = tty->driver_data; ti_ioctl()
696 return ti_set_serial_info(tty, tport, ti_ioctl()
703 static void ti_set_termios(struct tty_struct *tty, ti_set_termios() argument
714 cflag = tty->termios.c_cflag; ti_set_termios()
715 iflag = tty->termios.c_iflag; ti_set_termios()
752 tty->termios.c_cflag &= ~CMSPAR; ti_set_termios()
778 ti_restart_read(tport, tty); ti_set_termios()
781 if (I_IXOFF(tty) || I_IXON(tty)) { ti_set_termios()
782 config->cXon = START_CHAR(tty); ti_set_termios()
783 config->cXoff = STOP_CHAR(tty); ti_set_termios()
785 if (I_IXOFF(tty)) ti_set_termios()
788 ti_restart_read(tport, tty); ti_set_termios()
790 if (I_IXON(tty)) ti_set_termios()
794 baud = tty_get_baud_rate(tty); ti_set_termios()
804 tty_encode_baud_rate(tty, baud, baud); ti_set_termios()
837 static int ti_tiocmget(struct tty_struct *tty) ti_tiocmget() argument
839 struct usb_serial_port *port = tty->driver_data; ti_tiocmget()
868 static int ti_tiocmset(struct tty_struct *tty, ti_tiocmset() argument
871 struct usb_serial_port *port = tty->driver_data; ti_tiocmset()
901 static void ti_break(struct tty_struct *tty, int break_state) ti_break() argument
903 struct usb_serial_port *port = tty->driver_data; ti_break()
1247 static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, ti_set_serial_info() argument
1270 struct tty_struct *tty; ti_handle_new_msr() local
1293 tty = tty_port_tty_get(&tport->tp_port->port); ti_handle_new_msr()
1294 if (tty && C_CRTSCTS(tty)) { ti_handle_new_msr()
1296 tty_wakeup(tty); ti_handle_new_msr()
1298 tty_kref_put(tty); ti_handle_new_msr()
1302 static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty) ti_stop_read() argument
1315 static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty) ti_restart_read() argument
H A Dkobil_sct.c29 #include <linux/tty.h>
56 static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
58 static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
60 static int kobil_write_room(struct tty_struct *tty);
61 static int kobil_ioctl(struct tty_struct *tty,
63 static int kobil_tiocmget(struct tty_struct *tty);
64 static int kobil_tiocmset(struct tty_struct *tty,
68 static void kobil_set_termios(struct tty_struct *tty,
70 static void kobil_init_termios(struct tty_struct *tty);
159 static void kobil_init_termios(struct tty_struct *tty) kobil_init_termios() argument
162 tty->termios.c_lflag = 0; kobil_init_termios()
163 tty->termios.c_iflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE); kobil_init_termios()
164 tty->termios.c_iflag |= IGNBRK | IGNPAR | IXOFF; kobil_init_termios()
166 tty->termios.c_oflag &= ~ONLCR; kobil_init_termios()
169 static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) kobil_open() argument
293 static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, kobil_write() argument
362 static int kobil_write_room(struct tty_struct *tty) kobil_write_room() argument
369 static int kobil_tiocmget(struct tty_struct *tty) kobil_tiocmget() argument
371 struct usb_serial_port *port = tty->driver_data; kobil_tiocmget()
409 static int kobil_tiocmset(struct tty_struct *tty, kobil_tiocmset() argument
412 struct usb_serial_port *port = tty->driver_data; kobil_tiocmset()
469 static void kobil_set_termios(struct tty_struct *tty, kobil_set_termios() argument
475 int c_cflag = tty->termios.c_cflag; kobil_set_termios()
482 tty_termios_copy_hw(&tty->termios, old); kobil_set_termios()
486 speed = tty_get_baud_rate(tty); kobil_set_termios()
506 tty->termios.c_cflag &= ~CMSPAR; kobil_set_termios()
507 tty_encode_baud_rate(tty, speed, speed); kobil_set_termios()
521 static int kobil_ioctl(struct tty_struct *tty, kobil_ioctl() argument
524 struct usb_serial_port *port = tty->driver_data; kobil_ioctl()
H A Dusb_debug.c13 #include <linux/tty.h>
40 static void usb_debug_break_ctl(struct tty_struct *tty, int break_state) usb_debug_break_ctl() argument
42 struct usb_serial_port *port = tty->driver_data; usb_debug_break_ctl()
45 usb_serial_generic_write(tty, port, USB_DEBUG_BRK, USB_DEBUG_BRK_SIZE); usb_debug_break_ctl()
H A Dcypress_m8.c31 #include <linux/tty.h>
126 static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port);
129 static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
132 static int cypress_write_room(struct tty_struct *tty);
133 static void cypress_set_termios(struct tty_struct *tty,
135 static int cypress_tiocmget(struct tty_struct *tty);
136 static int cypress_tiocmset(struct tty_struct *tty,
138 static int cypress_chars_in_buffer(struct tty_struct *tty);
139 static void cypress_throttle(struct tty_struct *tty);
140 static void cypress_unthrottle(struct tty_struct *tty);
295 static int cypress_serial_control(struct tty_struct *tty, cypress_serial_control() argument
373 tty_encode_baud_rate(tty, cypress_serial_control()
585 static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port) cypress_open() argument
610 if (tty) cypress_open()
611 cypress_set_termios(tty, port, &priv->tmp_termios); cypress_open()
664 static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, cypress_write() argument
800 static int cypress_write_room(struct tty_struct *tty) cypress_write_room() argument
802 struct usb_serial_port *port = tty->driver_data; cypress_write_room()
816 static int cypress_tiocmget(struct tty_struct *tty) cypress_tiocmget() argument
818 struct usb_serial_port *port = tty->driver_data; cypress_tiocmget()
842 static int cypress_tiocmset(struct tty_struct *tty, cypress_tiocmset() argument
845 struct usb_serial_port *port = tty->driver_data; cypress_tiocmset()
861 return cypress_write(tty, port, NULL, 0); cypress_tiocmset()
864 static void cypress_set_termios(struct tty_struct *tty, cypress_set_termios() argument
880 tty->termios = tty_std_termios; cypress_set_termios()
881 tty->termios.c_cflag = B4800 | CS8 | CREAD | HUPCL | cypress_set_termios()
883 tty->termios.c_ispeed = 4800; cypress_set_termios()
884 tty->termios.c_ospeed = 4800; cypress_set_termios()
886 tty->termios = tty_std_termios; cypress_set_termios()
887 tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | cypress_set_termios()
889 tty->termios.c_ispeed = 9600; cypress_set_termios()
890 tty->termios.c_ospeed = 9600; cypress_set_termios()
892 tty->termios = tty_std_termios; cypress_set_termios()
893 tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | cypress_set_termios()
895 tty->termios.c_ispeed = 9600; cypress_set_termios()
896 tty->termios.c_ospeed = 9600; cypress_set_termios()
903 tty->termios.c_cflag &= ~(CMSPAR|CRTSCTS); cypress_set_termios()
905 cflag = tty->termios.c_cflag; cypress_set_termios()
906 iflag = tty->termios.c_iflag; cypress_set_termios()
911 priv->tmp_termios = tty->termios; cypress_set_termios()
958 cypress_serial_control(tty, port, tty_get_baud_rate(tty), cypress_set_termios()
966 cypress_serial_control(tty, port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); cypress_set_termios()
968 /* Here we can define custom tty settings for devices; the main tty cypress_set_termios()
976 tty->termios.c_iflag /* input modes - */ cypress_set_termios()
986 tty->termios.c_oflag /* output modes */ cypress_set_termios()
989 tty->termios.c_lflag /* line discipline modes */ cypress_set_termios()
1005 cypress_write(tty, port, NULL, 0); cypress_set_termios()
1011 static int cypress_chars_in_buffer(struct tty_struct *tty) cypress_chars_in_buffer() argument
1013 struct usb_serial_port *port = tty->driver_data; cypress_chars_in_buffer()
1027 static void cypress_throttle(struct tty_struct *tty) cypress_throttle() argument
1029 struct usb_serial_port *port = tty->driver_data; cypress_throttle()
1038 static void cypress_unthrottle(struct tty_struct *tty) cypress_unthrottle() argument
1040 struct usb_serial_port *port = tty->driver_data; cypress_unthrottle()
1068 struct tty_struct *tty; cypress_read_int_callback() local
1106 tty = tty_port_tty_get(&port->port); cypress_read_int_callback()
1107 if (!tty) { cypress_read_int_callback()
1108 dev_dbg(dev, "%s - bad tty pointer - exiting\n", __func__); cypress_read_int_callback()
1167 if (tty && !(tty->termios.c_cflag & CLOCAL) && cypress_read_int_callback()
1170 tty_hangup(tty); cypress_read_int_callback()
1199 tty_kref_put(tty); cypress_read_int_callback()
H A Dempeg.c21 #include <linux/tty.h>
38 static void empeg_init_termios(struct tty_struct *tty);
81 static void empeg_init_termios(struct tty_struct *tty) empeg_init_termios() argument
83 struct ktermios *termios = &tty->termios; empeg_init_termios()
86 * The empeg-car player wants these particular tty settings. empeg_init_termios()
89 * no point in support for changes to the tty settings. empeg_init_termios()
122 tty_encode_baud_rate(tty, 115200, 115200); empeg_init_termios()
H A Df81232.c16 #include <linux/tty.h>
138 struct tty_struct *tty; f81232_read_msr() local
165 tty = tty_port_tty_get(&port->port); f81232_read_msr()
166 if (tty) { f81232_read_msr()
167 usb_serial_handle_dcd_change(port, tty, f81232_read_msr()
170 tty_kref_put(tty); f81232_read_msr()
338 static void f81232_break_ctl(struct tty_struct *tty, int break_state) f81232_break_ctl() argument
439 static void f81232_set_termios(struct tty_struct *tty, f81232_set_termios() argument
447 if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios)) f81232_set_termios()
450 if (C_BAUD(tty) == B0) f81232_set_termios()
455 baudrate = tty_get_baud_rate(tty); f81232_set_termios()
459 tty_encode_baud_rate(tty, baudrate, baudrate); f81232_set_termios()
464 if (C_PARENB(tty)) { f81232_set_termios()
467 if (!C_PARODD(tty)) f81232_set_termios()
470 if (C_CMSPAR(tty)) f81232_set_termios()
474 if (C_CSTOPB(tty)) f81232_set_termios()
477 switch (C_CSIZE(tty)) { f81232_set_termios()
500 static int f81232_tiocmget(struct tty_struct *tty) f81232_tiocmget() argument
503 struct usb_serial_port *port = tty->driver_data; f81232_tiocmget()
525 static int f81232_tiocmset(struct tty_struct *tty, f81232_tiocmset() argument
528 struct usb_serial_port *port = tty->driver_data; f81232_tiocmset()
533 static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port) f81232_open() argument
542 if (tty) f81232_open()
543 f81232_set_termios(tty, port, NULL); f81232_open()
552 result = usb_serial_generic_open(tty, port); f81232_open()
608 static int f81232_ioctl(struct tty_struct *tty, f81232_ioctl() argument
611 struct usb_serial_port *port = tty->driver_data; f81232_ioctl()
H A Dssu100.c10 #include <linux/tty.h>
200 static void ssu100_set_termios(struct tty_struct *tty, ssu100_set_termios() argument
205 struct ktermios *termios = &tty->termios; ssu100_set_termios()
234 baud = tty_get_baud_rate(tty); ssu100_set_termios()
261 if (I_IXOFF(tty) || I_IXON(tty)) { ssu100_set_termios()
262 u16 x = ((u16)(START_CHAR(tty) << 8) | (u16)(STOP_CHAR(tty))); ssu100_set_termios()
276 static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port) ssu100_open() argument
310 if (tty) ssu100_open()
311 ssu100_set_termios(tty, port, &tty->termios); ssu100_open()
313 return usb_serial_generic_open(tty, port); ssu100_open()
339 static int ssu100_ioctl(struct tty_struct *tty, ssu100_ioctl() argument
342 struct usb_serial_port *port = tty->driver_data; ssu100_ioctl()
385 static int ssu100_tiocmget(struct tty_struct *tty) ssu100_tiocmget() argument
387 struct usb_serial_port *port = tty->driver_data; ssu100_tiocmget()
416 static int ssu100_tiocmset(struct tty_struct *tty, ssu100_tiocmset() argument
419 struct usb_serial_port *port = tty->driver_data; ssu100_tiocmset()
H A Dspcp8x5.c20 #include <linux/tty.h>
280 static void spcp8x5_init_termios(struct tty_struct *tty) spcp8x5_init_termios() argument
282 tty->termios = tty_std_termios; spcp8x5_init_termios()
283 tty->termios.c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL; spcp8x5_init_termios()
284 tty->termios.c_ispeed = 115200; spcp8x5_init_termios()
285 tty->termios.c_ospeed = 115200; spcp8x5_init_termios()
288 static void spcp8x5_set_termios(struct tty_struct *tty, spcp8x5_set_termios() argument
294 unsigned int cflag = tty->termios.c_cflag; spcp8x5_set_termios()
302 if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios)) spcp8x5_set_termios()
322 baud = tty_get_baud_rate(tty); spcp8x5_set_termios()
392 static int spcp8x5_open(struct tty_struct *tty, struct usb_serial_port *port) spcp8x5_open() argument
409 if (tty) spcp8x5_open()
410 spcp8x5_set_termios(tty, port, NULL); spcp8x5_open()
412 return usb_serial_generic_open(tty, port); spcp8x5_open()
415 static int spcp8x5_tiocmset(struct tty_struct *tty, spcp8x5_tiocmset() argument
418 struct usb_serial_port *port = tty->driver_data; spcp8x5_tiocmset()
438 static int spcp8x5_tiocmget(struct tty_struct *tty) spcp8x5_tiocmget() argument
440 struct usb_serial_port *port = tty->driver_data; spcp8x5_tiocmget()
H A Dpl2303.c20 #include <linux/tty.h>
401 static void pl2303_encode_baud_rate(struct tty_struct *tty, pl2303_encode_baud_rate() argument
410 baud = tty_get_baud_rate(tty); pl2303_encode_baud_rate()
428 tty_encode_baud_rate(tty, baud, baud); pl2303_encode_baud_rate()
478 static void pl2303_set_termios(struct tty_struct *tty, pl2303_set_termios() argument
489 if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios)) pl2303_set_termios()
496 tty->termios = *old_termios; pl2303_set_termios()
502 switch (C_CSIZE(tty)) { pl2303_set_termios()
519 pl2303_encode_baud_rate(tty, port, &buf[0]); pl2303_set_termios()
524 if (C_CSTOPB(tty)) { pl2303_set_termios()
529 if (C_CSIZE(tty) == CS5) { pl2303_set_termios()
541 if (C_PARENB(tty)) { pl2303_set_termios()
547 if (C_PARODD(tty)) { pl2303_set_termios()
548 if (C_CMSPAR(tty)) { pl2303_set_termios()
556 if (C_CMSPAR(tty)) { pl2303_set_termios()
590 if (C_BAUD(tty) == B0) pl2303_set_termios()
602 if (C_CRTSCTS(tty)) { pl2303_set_termios()
638 static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) pl2303_open() argument
654 if (tty) pl2303_open()
655 pl2303_set_termios(tty, port, NULL); pl2303_open()
664 result = usb_serial_generic_open(tty, port); pl2303_open()
673 static int pl2303_tiocmset(struct tty_struct *tty, pl2303_tiocmset() argument
676 struct usb_serial_port *port = tty->driver_data; pl2303_tiocmset()
701 static int pl2303_tiocmget(struct tty_struct *tty) pl2303_tiocmget() argument
703 struct usb_serial_port *port = tty->driver_data; pl2303_tiocmget()
737 static int pl2303_ioctl(struct tty_struct *tty, pl2303_ioctl() argument
741 struct usb_serial_port *port = tty->driver_data; pl2303_ioctl()
783 static void pl2303_break_ctl(struct tty_struct *tty, int state) pl2303_break_ctl() argument
785 struct usb_serial_port *port = tty->driver_data; pl2303_break_ctl()
797 struct tty_struct *tty; pl2303_update_line_status() local
829 tty = tty_port_tty_get(&port->port); pl2303_update_line_status()
830 if (tty) { pl2303_update_line_status()
831 usb_serial_handle_dcd_change(port, tty, pl2303_update_line_status()
833 tty_kref_put(tty); pl2303_update_line_status()
H A Dmetro-usb.c10 #include <linux/tty.h>
126 /* Loop through the data copying each byte to the tty layer. */ metrousb_read_int_callback()
129 /* Force the data to the tty layer. */ metrousb_read_int_callback()
182 static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port) metrousb_open() argument
287 static void metrousb_throttle(struct tty_struct *tty) metrousb_throttle() argument
289 struct usb_serial_port *port = tty->driver_data; metrousb_throttle()
293 dev_dbg(tty->dev, "%s\n", __func__); metrousb_throttle()
301 static int metrousb_tiocmget(struct tty_struct *tty) metrousb_tiocmget() argument
304 struct usb_serial_port *port = tty->driver_data; metrousb_tiocmget()
308 dev_dbg(tty->dev, "%s\n", __func__); metrousb_tiocmget()
317 static int metrousb_tiocmset(struct tty_struct *tty, metrousb_tiocmset() argument
320 struct usb_serial_port *port = tty->driver_data; metrousb_tiocmset()
326 dev_dbg(tty->dev, "%s - set=%d, clear=%d\n", __func__, set, clear); metrousb_tiocmset()
346 static void metrousb_unthrottle(struct tty_struct *tty) metrousb_unthrottle() argument
348 struct usb_serial_port *port = tty->driver_data; metrousb_unthrottle()
353 dev_dbg(tty->dev, "%s\n", __func__); metrousb_unthrottle()
364 dev_err(tty->dev, metrousb_unthrottle()
H A Dkl5kusb105.c41 #include <linux/tty.h>
60 static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port);
62 static void klsi_105_set_termios(struct tty_struct *tty,
64 static int klsi_105_tiocmget(struct tty_struct *tty);
213 * Driver's tty interface functions
252 static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) klsi_105_open() argument
282 priv->termios.c_iflag = tty->termios.c_iflag; klsi_105_open()
283 priv->termios.c_oflag = tty->termios.c_oflag; klsi_105_open()
284 priv->termios.c_cflag = tty->termios.c_cflag; klsi_105_open()
285 priv->termios.c_lflag = tty->termios.c_lflag; klsi_105_open()
287 priv->termios.c_cc[i] = tty->termios.c_cc[i]; klsi_105_open()
296 rc = usb_serial_generic_open(tty, port); klsi_105_open()
397 static void klsi_105_set_termios(struct tty_struct *tty, klsi_105_set_termios() argument
403 unsigned int iflag = tty->termios.c_iflag; klsi_105_set_termios()
405 unsigned int cflag = tty->termios.c_cflag; klsi_105_set_termios()
421 baud = tty_get_baud_rate(tty); klsi_105_set_termios()
481 tty_encode_baud_rate(tty, baud, baud); klsi_105_set_termios()
513 tty->termios.c_cflag &= ~(PARENB|PARODD|CSTOPB); klsi_105_set_termios()
540 tty->termios.c_cflag &= ~CRTSCTS; klsi_105_set_termios()
561 static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
563 struct usb_serial_port *port = tty->driver_data;
579 static int klsi_105_tiocmget(struct tty_struct *tty) klsi_105_tiocmget() argument
581 struct usb_serial_port *port = tty->driver_data; klsi_105_tiocmget()
H A Dmct_u232.c27 #include <linux/tty.h>
47 static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port);
51 static void mct_u232_set_termios(struct tty_struct *tty,
53 static void mct_u232_break_ctl(struct tty_struct *tty, int break_state);
54 static int mct_u232_tiocmget(struct tty_struct *tty);
55 static int mct_u232_tiocmset(struct tty_struct *tty,
57 static void mct_u232_throttle(struct tty_struct *tty);
58 static void mct_u232_unthrottle(struct tty_struct *tty);
178 static int mct_u232_set_baud_rate(struct tty_struct *tty, mct_u232_set_baud_rate() argument
202 tty_encode_baud_rate(tty, speed, speed); mct_u232_set_baud_rate()
233 if (port && C_CRTSCTS(tty)) mct_u232_set_baud_rate()
374 * Driver's tty interface functions
413 static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port) mct_u232_open() argument
438 if (tty && (tty->termios.c_cflag & CBAUD)) mct_u232_open()
570 tty = tty_port_tty_get(&port->port); mct_u232_read_int_callback()
583 tty_kref_put(tty); mct_u232_read_int_callback()
596 static void mct_u232_set_termios(struct tty_struct *tty, mct_u232_set_termios() argument
602 struct ktermios *termios = &tty->termios; mct_u232_set_termios()
629 mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty)); mct_u232_set_termios()
681 static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) mct_u232_break_ctl() argument
683 struct usb_serial_port *port = tty->driver_data; mct_u232_break_ctl()
699 static int mct_u232_tiocmget(struct tty_struct *tty) mct_u232_tiocmget() argument
701 struct usb_serial_port *port = tty->driver_data; mct_u232_tiocmget()
713 static int mct_u232_tiocmset(struct tty_struct *tty, mct_u232_tiocmset() argument
716 struct usb_serial_port *port = tty->driver_data; mct_u232_tiocmset()
738 static void mct_u232_throttle(struct tty_struct *tty) mct_u232_throttle() argument
740 struct usb_serial_port *port = tty->driver_data; mct_u232_throttle()
746 if (C_CRTSCTS(tty)) { mct_u232_throttle()
756 static void mct_u232_unthrottle(struct tty_struct *tty) mct_u232_unthrottle() argument
758 struct usb_serial_port *port = tty->driver_data; mct_u232_unthrottle()
763 if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) { mct_u232_unthrottle()
H A Dsymbolserial.c14 #include <linux/tty.h>
70 * This is real data to be sent to the tty layer symbol_int_callback()
72 * else to the tty layer. symbol_int_callback()
95 static int symbol_open(struct tty_struct *tty, struct usb_serial_port *port) symbol_open() argument
120 static void symbol_throttle(struct tty_struct *tty) symbol_throttle() argument
122 struct usb_serial_port *port = tty->driver_data; symbol_throttle()
130 static void symbol_unthrottle(struct tty_struct *tty) symbol_unthrottle() argument
132 struct usb_serial_port *port = tty->driver_data; symbol_unthrottle()
H A Dwhiteheat.c22 #include <linux/tty.h>
89 static int whiteheat_open(struct tty_struct *tty,
92 static int whiteheat_ioctl(struct tty_struct *tty,
94 static void whiteheat_set_termios(struct tty_struct *tty,
96 static int whiteheat_tiocmget(struct tty_struct *tty);
97 static int whiteheat_tiocmset(struct tty_struct *tty,
99 static void whiteheat_break_ctl(struct tty_struct *tty, int break_state);
166 static void firm_setup_port(struct tty_struct *tty);
390 static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port) whiteheat_open() argument
412 if (tty) whiteheat_open()
413 firm_setup_port(tty); whiteheat_open()
419 retval = usb_serial_generic_open(tty, port); whiteheat_open()
440 static int whiteheat_tiocmget(struct tty_struct *tty) whiteheat_tiocmget() argument
442 struct usb_serial_port *port = tty->driver_data; whiteheat_tiocmget()
455 static int whiteheat_tiocmset(struct tty_struct *tty, whiteheat_tiocmset() argument
458 struct usb_serial_port *port = tty->driver_data; whiteheat_tiocmset()
477 static int whiteheat_ioctl(struct tty_struct *tty, whiteheat_ioctl() argument
480 struct usb_serial_port *port = tty->driver_data; whiteheat_ioctl()
508 static void whiteheat_set_termios(struct tty_struct *tty, whiteheat_set_termios() argument
511 firm_setup_port(tty); whiteheat_set_termios()
514 static void whiteheat_break_ctl(struct tty_struct *tty, int break_state) whiteheat_break_ctl() argument
516 struct usb_serial_port *port = tty->driver_data; whiteheat_break_ctl()
674 static void firm_setup_port(struct tty_struct *tty) firm_setup_port() argument
676 struct usb_serial_port *port = tty->driver_data; firm_setup_port()
679 unsigned int cflag = tty->termios.c_cflag; firm_setup_port()
729 if (I_IXOFF(tty)) firm_setup_port()
735 port_settings.xon = START_CHAR(tty); firm_setup_port()
736 port_settings.xoff = STOP_CHAR(tty); firm_setup_port()
740 port_settings.baud = tty_get_baud_rate(tty); firm_setup_port()
744 tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); firm_setup_port()
745 /* handle any settings that aren't specified in the tty structure */ firm_setup_port()
H A Doti6858.c43 #include <linux/tty.h>
122 static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port);
124 static void oti6858_set_termios(struct tty_struct *tty,
126 static void oti6858_init_termios(struct tty_struct *tty);
130 static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
132 static int oti6858_write_room(struct tty_struct *tty);
133 static int oti6858_chars_in_buffer(struct tty_struct *tty);
134 static int oti6858_tiocmget(struct tty_struct *tty);
135 static int oti6858_tiocmset(struct tty_struct *tty,
357 static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, oti6858_write() argument
368 static int oti6858_write_room(struct tty_struct *tty) oti6858_write_room() argument
370 struct usb_serial_port *port = tty->driver_data; oti6858_write_room()
381 static int oti6858_chars_in_buffer(struct tty_struct *tty) oti6858_chars_in_buffer() argument
383 struct usb_serial_port *port = tty->driver_data; oti6858_chars_in_buffer()
394 static void oti6858_init_termios(struct tty_struct *tty) oti6858_init_termios() argument
396 tty->termios = tty_std_termios; oti6858_init_termios()
397 tty->termios.c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; oti6858_init_termios()
398 tty->termios.c_ispeed = 38400; oti6858_init_termios()
399 tty->termios.c_ospeed = 38400; oti6858_init_termios()
402 static void oti6858_set_termios(struct tty_struct *tty, oti6858_set_termios() argument
412 cflag = tty->termios.c_cflag; oti6858_set_termios()
442 br = tty_get_baud_rate(tty); oti6858_set_termios()
453 tty_encode_baud_rate(tty, real_br, real_br); oti6858_set_termios()
504 static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port) oti6858_open() argument
554 if (tty) oti6858_open()
555 oti6858_set_termios(tty, port, NULL); oti6858_open()
583 static int oti6858_tiocmset(struct tty_struct *tty, oti6858_tiocmset() argument
586 struct usb_serial_port *port = tty->driver_data; oti6858_tiocmset()
613 static int oti6858_tiocmget(struct tty_struct *tty) oti6858_tiocmget() argument
615 struct usb_serial_port *port = tty->driver_data; oti6858_tiocmget()
H A Dch341.c19 #include <linux/tty.h>
87 static void ch341_set_termios(struct tty_struct *tty,
310 static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port) ch341_open() argument
320 if (tty) ch341_open()
321 ch341_set_termios(tty, port, NULL); ch341_open()
331 r = usb_serial_generic_open(tty, port); ch341_open()
337 * tty->termios contains the new setting to be used.
339 static void ch341_set_termios(struct tty_struct *tty, ch341_set_termios() argument
346 baud_rate = tty_get_baud_rate(tty); ch341_set_termios()
370 static void ch341_break_ctl(struct tty_struct *tty, int break_state) ch341_break_ctl() argument
374 struct usb_serial_port *port = tty->driver_data; ch341_break_ctl()
413 static int ch341_tiocmset(struct tty_struct *tty, ch341_tiocmset() argument
416 struct usb_serial_port *port = tty->driver_data; ch341_tiocmset()
440 struct tty_struct *tty; ch341_update_line_status() local
469 tty = tty_port_tty_get(&port->port); ch341_update_line_status()
470 if (tty) { ch341_update_line_status()
471 usb_serial_handle_dcd_change(port, tty, ch341_update_line_status()
473 tty_kref_put(tty); ch341_update_line_status()
514 static int ch341_tiocmget(struct tty_struct *tty) ch341_tiocmget() argument
516 struct usb_serial_port *port = tty->driver_data; ch341_tiocmget()
H A Dopticon.c15 #include <linux/tty.h>
87 * This is real data to be sent to the tty layer opticon_process_read_urb()
128 static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port) opticon_open() argument
144 res = usb_serial_generic_open(tty, port); opticon_open()
180 static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, opticon_write() argument
263 static int opticon_write_room(struct tty_struct *tty) opticon_write_room() argument
265 struct usb_serial_port *port = tty->driver_data; opticon_write_room()
271 * but let's pick a nice big number to tell the tty opticon_write_room()
285 static int opticon_tiocmget(struct tty_struct *tty) opticon_tiocmget() argument
287 struct usb_serial_port *port = tty->driver_data; opticon_tiocmget()
303 static int opticon_tiocmset(struct tty_struct *tty, opticon_tiocmset() argument
306 struct usb_serial_port *port = tty->driver_data; opticon_tiocmset()
360 static int opticon_ioctl(struct tty_struct *tty, opticon_ioctl() argument
363 struct usb_serial_port *port = tty->driver_data; opticon_ioctl()
H A Dbelkin_sa.c29 #include <linux/tty.h>
45 static int belkin_sa_open(struct tty_struct *tty,
50 static void belkin_sa_set_termios(struct tty_struct *tty,
52 static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state);
53 static int belkin_sa_tiocmget(struct tty_struct *tty);
54 static int belkin_sa_tiocmset(struct tty_struct *tty,
151 static int belkin_sa_open(struct tty_struct *tty, belkin_sa_open() argument
162 retval = usb_serial_generic_open(tty, port); belkin_sa_open()
281 static void belkin_sa_set_termios(struct tty_struct *tty, belkin_sa_set_termios() argument
295 struct ktermios *termios = &tty->termios; belkin_sa_set_termios()
326 baud = tty_get_baud_rate(tty); belkin_sa_set_termios()
336 tty_encode_baud_rate(tty, baud, baud); belkin_sa_set_termios()
424 static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state) belkin_sa_break_ctl() argument
426 struct usb_serial_port *port = tty->driver_data; belkin_sa_break_ctl()
433 static int belkin_sa_tiocmget(struct tty_struct *tty) belkin_sa_tiocmget() argument
435 struct usb_serial_port *port = tty->driver_data; belkin_sa_tiocmget()
447 static int belkin_sa_tiocmset(struct tty_struct *tty, belkin_sa_tiocmset() argument
450 struct usb_serial_port *port = tty->driver_data; belkin_sa_tiocmset()
H A Domninet.c17 #include <linux/tty.h>
34 static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port);
37 static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
39 static int omninet_write_room(struct tty_struct *tty);
130 static int omninet_open(struct tty_struct *tty, struct usb_serial_port *port) omninet_open() argument
136 tty_port_tty_set(&wport->port, tty); omninet_open()
138 return usb_serial_generic_open(tty, port); omninet_open()
162 static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, omninet_write() argument
213 static int omninet_write_room(struct tty_struct *tty) omninet_write_room() argument
215 struct usb_serial_port *port = tty->driver_data; omninet_write_room()
H A Ddigi_acceleport.c21 #include <linux/tty.h>
48 /* timeout while waiting for tty output to drain in close */
220 static void digi_rx_throttle(struct tty_struct *tty);
221 static void digi_rx_unthrottle(struct tty_struct *tty);
222 static void digi_set_termios(struct tty_struct *tty,
224 static void digi_break_ctl(struct tty_struct *tty, int break_state);
225 static int digi_tiocmget(struct tty_struct *tty);
226 static int digi_tiocmset(struct tty_struct *tty, unsigned int set,
228 static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
231 static int digi_write_room(struct tty_struct *tty);
232 static int digi_chars_in_buffer(struct tty_struct *tty);
233 static int digi_open(struct tty_struct *tty, struct usb_serial_port *port);
362 * Wake up port, line discipline, and tty processes sleeping
633 static void digi_rx_throttle(struct tty_struct *tty) digi_rx_throttle() argument
636 struct usb_serial_port *port = tty->driver_data; digi_rx_throttle()
647 static void digi_rx_unthrottle(struct tty_struct *tty) digi_rx_unthrottle() argument
651 struct usb_serial_port *port = tty->driver_data; digi_rx_unthrottle()
673 static void digi_set_termios(struct tty_struct *tty, digi_set_termios() argument
678 unsigned int iflag = tty->termios.c_iflag; digi_set_termios()
679 unsigned int cflag = tty->termios.c_cflag; digi_set_termios()
693 baud = tty_get_baud_rate(tty); digi_set_termios()
702 if (!(tty->termios.c_cflag & CRTSCTS) || digi_set_termios()
703 !test_bit(TTY_THROTTLED, &tty->flags)) digi_set_termios()
741 tty->termios.c_cflag &= ~CMSPAR; digi_set_termios()
860 tty_encode_baud_rate(tty, baud, baud); digi_set_termios()
864 static void digi_break_ctl(struct tty_struct *tty, int break_state) digi_break_ctl() argument
866 struct usb_serial_port *port = tty->driver_data; digi_break_ctl()
877 static int digi_tiocmget(struct tty_struct *tty) digi_tiocmget() argument
879 struct usb_serial_port *port = tty->driver_data; digi_tiocmget()
891 static int digi_tiocmset(struct tty_struct *tty, digi_tiocmset() argument
894 struct usb_serial_port *port = tty->driver_data; digi_tiocmset()
906 static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, digi_write() argument
1045 static int digi_write_room(struct tty_struct *tty) digi_write_room() argument
1047 struct usb_serial_port *port = tty->driver_data; digi_write_room()
1065 static int digi_chars_in_buffer(struct tty_struct *tty) digi_chars_in_buffer() argument
1067 struct usb_serial_port *port = tty->driver_data; digi_chars_in_buffer()
1089 static int digi_open(struct tty_struct *tty, struct usb_serial_port *port) digi_open() argument
1117 if (tty) { digi_open()
1118 not_termios.c_cflag = ~tty->termios.c_cflag; digi_open()
1119 not_termios.c_iflag = ~tty->termios.c_iflag; digi_open()
1120 digi_set_termios(tty, port, &not_termios); digi_open()
1392 * the data on to the tty subsystem. When called we know port and
1484 struct tty_struct *tty; digi_read_oob_callback() local
1509 tty = tty_port_tty_get(&port->port); digi_read_oob_callback()
1512 if (tty) digi_read_oob_callback()
1513 rts = tty->termios.c_cflag & CRTSCTS; digi_read_oob_callback()
1515 if (tty && opcode == DIGI_CMD_READ_INPUT_SIGNALS) { digi_read_oob_callback()
1520 /* port must be open to use tty struct */ digi_read_oob_callback()
1525 /* port must be open to use tty struct */ digi_read_oob_callback()
1549 tty_kref_put(tty); digi_read_oob_callback()
H A Dnavman.c17 #include <linux/tty.h>
69 static int navman_open(struct tty_struct *tty, struct usb_serial_port *port) navman_open() argument
90 static int navman_write(struct tty_struct *tty, struct usb_serial_port *port, navman_write() argument
H A Dwishbone-serial.c14 #include <linux/tty.h>
49 static int wishbone_serial_open(struct tty_struct *tty, wishbone_serial_open() argument
62 retval = usb_serial_generic_open(tty, port); wishbone_serial_open()
H A Dmxuport.c26 #include <linux/tty.h>
289 * This function is called by the tty driver when it wants to stop the
295 static void mxuport_throttle(struct tty_struct *tty) mxuport_throttle() argument
297 struct usb_serial_port *port = tty->driver_data; mxuport_throttle()
309 * This function is called by the tty driver when it wants to resume
313 static void mxuport_unthrottle(struct tty_struct *tty) mxuport_unthrottle() argument
316 struct usb_serial_port *port = tty->driver_data; mxuport_unthrottle()
709 static int mxuport_tiocmset(struct tty_struct *tty, unsigned int set, mxuport_tiocmset() argument
712 struct usb_serial_port *port = tty->driver_data; mxuport_tiocmset()
741 static int mxuport_tiocmget(struct tty_struct *tty) mxuport_tiocmget() argument
744 struct usb_serial_port *port = tty->driver_data; mxuport_tiocmget()
773 static int mxuport_set_termios_flow(struct tty_struct *tty, mxuport_set_termios_flow() argument
778 u8 xon = START_CHAR(tty); mxuport_set_termios_flow()
779 u8 xoff = STOP_CHAR(tty); mxuport_set_termios_flow()
790 if (I_IXOFF(tty) || I_IXON(tty)) { mxuport_set_termios_flow()
816 C_CRTSCTS(tty) != (old_termios->c_cflag & CRTSCTS)) { mxuport_set_termios_flow()
817 if (C_CRTSCTS(tty)) mxuport_set_termios_flow()
823 if (C_BAUD(tty)) { mxuport_set_termios_flow()
826 if (C_CRTSCTS(tty)) mxuport_set_termios_flow()
846 static void mxuport_set_termios(struct tty_struct *tty, mxuport_set_termios() argument
859 !tty_termios_hw_change(&tty->termios, old_termios) && mxuport_set_termios()
860 tty->termios.c_iflag == old_termios->c_iflag) { mxuport_set_termios()
870 switch (C_CSIZE(tty)) { mxuport_set_termios()
887 if (C_PARENB(tty)) { mxuport_set_termios()
888 if (C_CMSPAR(tty)) { mxuport_set_termios()
889 if (C_PARODD(tty)) mxuport_set_termios()
894 if (C_PARODD(tty)) mxuport_set_termios()
904 if (C_CSTOPB(tty)) mxuport_set_termios()
919 err = mxuport_set_termios_flow(tty, old_termios, port, serial); mxuport_set_termios()
923 baud = tty_get_baud_rate(tty); mxuport_set_termios()
1275 static int mxuport_open(struct tty_struct *tty, struct usb_serial_port *port) mxuport_open() argument
1296 if (tty) mxuport_open()
1297 mxuport_set_termios(tty, port, NULL); mxuport_open()
1320 static void mxuport_break_ctl(struct tty_struct *tty, int break_state) mxuport_break_ctl() argument
1322 struct usb_serial_port *port = tty->driver_data; mxuport_break_ctl()
H A Dquatech2.c19 #include <linux/tty.h>
266 static void qt2_set_termios(struct tty_struct *tty, qt2_set_termios() argument
272 struct ktermios *termios = &tty->termios; qt2_set_termios()
303 baud = tty_get_baud_rate(tty); qt2_set_termios()
324 if (I_IXOFF(tty) || I_IXON(tty)) { qt2_set_termios()
325 u16 x = ((u16) (START_CHAR(tty) << 8) | (u16) (STOP_CHAR(tty))); qt2_set_termios()
339 static int qt2_open(struct tty_struct *tty, struct usb_serial_port *port) qt2_open() argument
400 if (tty) qt2_open()
401 qt2_set_termios(tty, port, &tty->termios); qt2_open()
484 static int qt2_ioctl(struct tty_struct *tty, qt2_ioctl() argument
487 struct usb_serial_port *port = tty->driver_data; qt2_ioctl()
791 static int qt2_tiocmget(struct tty_struct *tty) qt2_tiocmget() argument
793 struct usb_serial_port *port = tty->driver_data; qt2_tiocmget()
823 static int qt2_tiocmset(struct tty_struct *tty, qt2_tiocmset() argument
828 port_priv = usb_get_serial_port_data(tty->driver_data); qt2_tiocmset()
832 static void qt2_break_ctl(struct tty_struct *tty, int break_state) qt2_break_ctl() argument
834 struct usb_serial_port *port = tty->driver_data; qt2_break_ctl()
933 static int qt2_write_room(struct tty_struct *tty) qt2_write_room() argument
935 struct usb_serial_port *port = tty->driver_data; qt2_write_room()
954 static int qt2_write(struct tty_struct *tty, qt2_write() argument
H A Dkeyspan_pda.c21 #include <linux/tty.h>
200 static void keyspan_pda_rx_throttle(struct tty_struct *tty) keyspan_pda_rx_throttle() argument
208 struct usb_serial_port *port = tty->driver_data; keyspan_pda_rx_throttle()
214 static void keyspan_pda_rx_unthrottle(struct tty_struct *tty) keyspan_pda_rx_unthrottle() argument
216 struct usb_serial_port *port = tty->driver_data; keyspan_pda_rx_unthrottle()
283 static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state) keyspan_pda_break_ctl() argument
285 struct usb_serial_port *port = tty->driver_data; keyspan_pda_break_ctl()
308 static void keyspan_pda_set_termios(struct tty_struct *tty, keyspan_pda_set_termios() argument
329 HW flow control is dictated by the tty->termios.c_cflags & CRTSCTS keyspan_pda_set_termios()
334 speed = tty_get_baud_rate(tty); keyspan_pda_set_termios()
344 tty_termios_copy_hw(&tty->termios, old_termios); keyspan_pda_set_termios()
345 tty_encode_baud_rate(tty, speed, speed); keyspan_pda_set_termios()
386 static int keyspan_pda_tiocmget(struct tty_struct *tty) keyspan_pda_tiocmget() argument
388 struct usb_serial_port *port = tty->driver_data; keyspan_pda_tiocmget()
407 static int keyspan_pda_tiocmset(struct tty_struct *tty, keyspan_pda_tiocmset() argument
410 struct usb_serial_port *port = tty->driver_data; keyspan_pda_tiocmset()
432 static int keyspan_pda_write(struct tty_struct *tty, keyspan_pda_write() argument
562 static int keyspan_pda_write_room(struct tty_struct *tty) keyspan_pda_write_room() argument
564 struct usb_serial_port *port = tty->driver_data; keyspan_pda_write_room()
574 static int keyspan_pda_chars_in_buffer(struct tty_struct *tty) keyspan_pda_chars_in_buffer() argument
576 struct usb_serial_port *port = tty->driver_data; keyspan_pda_chars_in_buffer()
605 static int keyspan_pda_open(struct tty_struct *tty, keyspan_pda_open() argument
H A Dio_ti.c24 #include <linux/tty.h>
204 static void edge_set_termios(struct tty_struct *tty,
206 static void edge_send(struct usb_serial_port *port, struct tty_struct *tty);
1433 struct tty_struct *tty; handle_new_msr() local
1456 tty = tty_port_tty_get(&edge_port->port->port); handle_new_msr()
1458 if (tty && C_CRTSCTS(tty)) { handle_new_msr()
1460 tty_wakeup(tty); handle_new_msr()
1462 tty_kref_put(tty); handle_new_msr()
1680 struct tty_struct *tty; edge_bulk_out_callback() local
1701 tty = tty_port_tty_get(&port->port); edge_bulk_out_callback()
1702 edge_send(port, tty); edge_bulk_out_callback()
1703 tty_kref_put(tty); edge_bulk_out_callback()
1706 static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) edge_open() argument
1734 if (tty) edge_open()
1735 edge_set_termios(tty, port, &tty->termios); edge_open()
1895 static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, edge_write() argument
1912 edge_send(port, tty); edge_write()
1917 static void edge_send(struct usb_serial_port *port, struct tty_struct *tty) edge_send() argument
1961 if (tty) edge_send()
1962 tty_wakeup(tty); edge_send()
1965 static int edge_write_room(struct tty_struct *tty) edge_write_room() argument
1967 struct usb_serial_port *port = tty->driver_data; edge_write_room()
1985 static int edge_chars_in_buffer(struct tty_struct *tty) edge_chars_in_buffer() argument
1987 struct usb_serial_port *port = tty->driver_data; edge_chars_in_buffer()
2014 static void edge_throttle(struct tty_struct *tty) edge_throttle() argument
2016 struct usb_serial_port *port = tty->driver_data; edge_throttle()
2024 if (I_IXOFF(tty)) { edge_throttle()
2025 unsigned char stop_char = STOP_CHAR(tty); edge_throttle()
2026 status = edge_write(tty, port, &stop_char, 1); edge_throttle()
2034 if (C_CRTSCTS(tty)) edge_throttle()
2039 static void edge_unthrottle(struct tty_struct *tty) edge_unthrottle() argument
2041 struct usb_serial_port *port = tty->driver_data; edge_unthrottle()
2049 if (I_IXOFF(tty)) { edge_unthrottle()
2050 unsigned char start_char = START_CHAR(tty); edge_unthrottle()
2051 status = edge_write(tty, port, &start_char, 1); edge_unthrottle()
2058 if (C_CRTSCTS(tty)) { edge_unthrottle()
2101 static void change_port_settings(struct tty_struct *tty, change_port_settings() argument
2113 tty->termios = *old_termios; change_port_settings()
2117 cflag = tty->termios.c_cflag; change_port_settings()
2181 config->cXon = START_CHAR(tty); change_port_settings()
2182 config->cXoff = STOP_CHAR(tty); change_port_settings()
2185 if (I_IXOFF(tty)) { change_port_settings()
2193 if (I_IXON(tty)) { change_port_settings()
2200 tty->termios.c_cflag &= ~CMSPAR; change_port_settings()
2203 baud = tty_get_baud_rate(tty); change_port_settings()
2208 tty_encode_baud_rate(tty, baud, baud); change_port_settings()
2239 static void edge_set_termios(struct tty_struct *tty, edge_set_termios() argument
2245 cflag = tty->termios.c_cflag; edge_set_termios()
2248 tty->termios.c_cflag, tty->termios.c_iflag); edge_set_termios()
2255 change_port_settings(tty, edge_port, old_termios); edge_set_termios()
2258 static int edge_tiocmset(struct tty_struct *tty, edge_tiocmset() argument
2261 struct usb_serial_port *port = tty->driver_data; edge_tiocmset()
2289 static int edge_tiocmget(struct tty_struct *tty) edge_tiocmget() argument
2291 struct usb_serial_port *port = tty->driver_data; edge_tiocmget()
2346 static int edge_ioctl(struct tty_struct *tty, edge_ioctl() argument
2349 struct usb_serial_port *port = tty->driver_data; edge_ioctl()
2361 static void edge_break(struct tty_struct *tty, int break_state) edge_break() argument
2363 struct usb_serial_port *port = tty->driver_data; edge_break()
H A Dusb_wwan.c29 #include <linux/tty.h>
58 int usb_wwan_tiocmget(struct tty_struct *tty) usb_wwan_tiocmget() argument
60 struct usb_serial_port *port = tty->driver_data; usb_wwan_tiocmget()
77 int usb_wwan_tiocmset(struct tty_struct *tty, usb_wwan_tiocmset() argument
80 struct usb_serial_port *port = tty->driver_data; usb_wwan_tiocmset()
115 tmp.baud_base = tty_get_baud_rate(port->port.tty); get_serial_info()
157 int usb_wwan_ioctl(struct tty_struct *tty, usb_wwan_ioctl() argument
160 struct usb_serial_port *port = tty->driver_data; usb_wwan_ioctl()
181 int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port, usb_wwan_write() argument
322 int usb_wwan_write_room(struct tty_struct *tty) usb_wwan_write_room() argument
324 struct usb_serial_port *port = tty->driver_data; usb_wwan_write_room()
343 int usb_wwan_chars_in_buffer(struct tty_struct *tty) usb_wwan_chars_in_buffer() argument
345 struct usb_serial_port *port = tty->driver_data; usb_wwan_chars_in_buffer()
365 int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port) usb_wwan_open() argument
H A Dark3116.c27 #include <linux/tty.h>
207 static void ark3116_init_termios(struct tty_struct *tty) ark3116_init_termios() argument
209 struct ktermios *termios = &tty->termios; ark3116_init_termios()
217 static void ark3116_set_termios(struct tty_struct *tty, ark3116_set_termios() argument
223 struct ktermios *termios = &tty->termios; ark3116_set_termios()
225 int bps = tty_get_baud_rate(tty); ark3116_set_termios()
327 if (I_IXOFF(tty) || I_IXON(tty)) { ark3116_set_termios()
353 static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) ark3116_open() argument
364 result = usb_serial_generic_open(tty, port); ark3116_open()
395 if (tty) ark3116_open()
396 ark3116_set_termios(tty, port, NULL); ark3116_open()
403 static int ark3116_ioctl(struct tty_struct *tty, ark3116_ioctl() argument
406 struct usb_serial_port *port = tty->driver_data; ark3116_ioctl()
433 static int ark3116_tiocmget(struct tty_struct *tty) ark3116_tiocmget() argument
435 struct usb_serial_port *port = tty->driver_data; ark3116_tiocmget()
459 static int ark3116_tiocmset(struct tty_struct *tty, ark3116_tiocmset() argument
462 struct usb_serial_port *port = tty->driver_data; ark3116_tiocmset()
495 static void ark3116_break_ctl(struct tty_struct *tty, int break_state) ark3116_break_ctl() argument
497 struct usb_serial_port *port = tty->driver_data; ark3116_break_ctl()
H A Dio_edgeport.c36 #include <linux/tty.h>
197 static int edge_open(struct tty_struct *tty, struct usb_serial_port *port);
199 static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
201 static int edge_write_room(struct tty_struct *tty);
202 static int edge_chars_in_buffer(struct tty_struct *tty);
203 static void edge_throttle(struct tty_struct *tty);
204 static void edge_unthrottle(struct tty_struct *tty);
205 static void edge_set_termios(struct tty_struct *tty,
208 static int edge_ioctl(struct tty_struct *tty,
210 static void edge_break(struct tty_struct *tty, int break_state);
211 static int edge_tiocmget(struct tty_struct *tty);
212 static int edge_tiocmset(struct tty_struct *tty,
238 static void change_port_settings(struct tty_struct *tty,
637 /* tell the tty driver that something edge_interrupt_callback()
776 /* tell the tty driver that something has changed */ edge_bulk_out_cmd_callback()
787 * Driver tty interface functions
792 * this function is called by the tty driver when a port is opened
796 static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) edge_open() argument
1031 * this function is called by the tty driver when a port is closed
1092 * this function is called by the tty driver when data should be written
1097 static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, edge_write() argument
1123 /* catch writes of 0 bytes which the tty driver likes to give us, edge_write()
1305 * this function is called by the tty driver when it wants to know how
1310 static int edge_write_room(struct tty_struct *tty) edge_write_room() argument
1312 struct usb_serial_port *port = tty->driver_data; edge_write_room()
1339 * this function is called by the tty driver when it wants to know how
1346 static int edge_chars_in_buffer(struct tty_struct *tty) edge_chars_in_buffer() argument
1348 struct usb_serial_port *port = tty->driver_data; edge_chars_in_buffer()
1377 * this function is called by the tty driver when it wants to stop the data
1380 static void edge_throttle(struct tty_struct *tty) edge_throttle() argument
1382 struct usb_serial_port *port = tty->driver_data; edge_throttle()
1395 if (I_IXOFF(tty)) { edge_throttle()
1396 unsigned char stop_char = STOP_CHAR(tty); edge_throttle()
1397 status = edge_write(tty, port, &stop_char, 1); edge_throttle()
1403 if (tty->termios.c_cflag & CRTSCTS) { edge_throttle()
1415 * this function is called by the tty driver when it wants to resume the
1418 static void edge_unthrottle(struct tty_struct *tty) edge_unthrottle() argument
1420 struct usb_serial_port *port = tty->driver_data; edge_unthrottle()
1433 if (I_IXOFF(tty)) { edge_unthrottle()
1434 unsigned char start_char = START_CHAR(tty); edge_unthrottle()
1435 status = edge_write(tty, port, &start_char, 1); edge_unthrottle()
1440 if (tty->termios.c_cflag & CRTSCTS) { edge_unthrottle()
1450 * this function is called by the tty driver when it wants to change
1453 static void edge_set_termios(struct tty_struct *tty, edge_set_termios() argument
1459 cflag = tty->termios.c_cflag; edge_set_termios()
1460 dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__, tty->termios.c_cflag, tty->termios.c_iflag); edge_set_termios()
1472 change_port_settings(tty, edge_port, old_termios); edge_set_termios()
1505 static int edge_tiocmset(struct tty_struct *tty, edge_tiocmset() argument
1508 struct usb_serial_port *port = tty->driver_data; edge_tiocmset()
1534 static int edge_tiocmget(struct tty_struct *tty) edge_tiocmget() argument
1536 struct usb_serial_port *port = tty->driver_data; edge_tiocmget()
1584 static int edge_ioctl(struct tty_struct *tty, edge_ioctl() argument
1587 struct usb_serial_port *port = tty->driver_data; edge_ioctl()
1608 static void edge_break(struct tty_struct *tty, int break_state) edge_break() argument
1610 struct usb_serial_port *port = tty->driver_data; edge_break()
1760 /* spit this data back into the tty driver if this process_rcvd_data()
1805 struct tty_struct *tty; process_rcvd_status() local
1857 tty = tty_port_tty_get(&edge_port->port->port); process_rcvd_status()
1858 if (tty) { process_rcvd_status()
1859 change_port_settings(tty, process_rcvd_status()
1860 edge_port, &tty->termios); process_rcvd_status()
1861 tty_kref_put(tty); process_rcvd_status()
1919 * this function passes data on to the tty flip buffer
2379 static void change_port_settings(struct tty_struct *tty, change_port_settings() argument
2401 cflag = tty->termios.c_cflag; change_port_settings()
2464 if (I_IXOFF(tty) || I_IXON(tty)) { change_port_settings()
2465 unsigned char stop_char = STOP_CHAR(tty); change_port_settings()
2466 unsigned char start_char = START_CHAR(tty); change_port_settings()
2478 if (I_IXOFF(tty)) { change_port_settings()
2487 if (I_IXON(tty)) { change_port_settings()
2529 baud = tty_get_baud_rate(tty); change_port_settings()
2540 tty_encode_baud_rate(tty, baud, baud); change_port_settings()
H A Dir-usb.c31 #include <linux/tty.h>
52 static int ir_open(struct tty_struct *tty, struct usb_serial_port *port);
56 static void ir_set_termios(struct tty_struct *tty,
255 static int ir_open(struct tty_struct *tty, struct usb_serial_port *port) ir_open() argument
263 return usb_serial_generic_open(tty, port); ir_open()
317 static void ir_set_termios(struct tty_struct *tty, ir_set_termios() argument
326 baud = tty_get_baud_rate(tty); ir_set_termios()
373 tty_termios_copy_hw(&tty->termios, old_termios); ir_set_termios()
374 tty_encode_baud_rate(tty, baud, baud); ir_set_termios()
H A Dmos7840.c28 #include <linux/tty.h>
840 * this function is called by the tty driver when a port is opened
845 static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) mos7840_open() argument
1116 * this function is called by the tty driver when it wants to know how many
1124 static int mos7840_chars_in_buffer(struct tty_struct *tty) mos7840_chars_in_buffer() argument
1126 struct usb_serial_port *port = tty->driver_data; mos7840_chars_in_buffer()
1154 * this function is called by the tty driver when a port is closed
1221 static void mos7840_break(struct tty_struct *tty, int break_state) mos7840_break() argument
1223 struct usb_serial_port *port = tty->driver_data; mos7840_break()
1254 * this function is called by the tty driver when it wants to know how many
1260 static int mos7840_write_room(struct tty_struct *tty) mos7840_write_room() argument
1262 struct usb_serial_port *port = tty->driver_data; mos7840_write_room()
1290 * this function is called by the tty driver when data should be written to
1296 static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, mos7840_write() argument
1397 * this function is called by the tty driver when it wants to stop the data
1401 static void mos7840_throttle(struct tty_struct *tty) mos7840_throttle() argument
1403 struct usb_serial_port *port = tty->driver_data; mos7840_throttle()
1421 if (I_IXOFF(tty)) { mos7840_throttle()
1422 unsigned char stop_char = STOP_CHAR(tty); mos7840_throttle()
1423 status = mos7840_write(tty, port, &stop_char, 1); mos7840_throttle()
1428 if (tty->termios.c_cflag & CRTSCTS) { mos7840_throttle()
1439 * this function is called by the tty driver when it wants to resume
1443 static void mos7840_unthrottle(struct tty_struct *tty) mos7840_unthrottle() argument
1445 struct usb_serial_port *port = tty->driver_data; mos7840_unthrottle()
1461 if (I_IXOFF(tty)) { mos7840_unthrottle()
1462 unsigned char start_char = START_CHAR(tty); mos7840_unthrottle()
1463 status = mos7840_write(tty, port, &start_char, 1); mos7840_unthrottle()
1469 if (tty->termios.c_cflag & CRTSCTS) { mos7840_unthrottle()
1478 static int mos7840_tiocmget(struct tty_struct *tty) mos7840_tiocmget() argument
1480 struct usb_serial_port *port = tty->driver_data; mos7840_tiocmget()
1510 static int mos7840_tiocmset(struct tty_struct *tty, mos7840_tiocmset() argument
1513 struct usb_serial_port *port = tty->driver_data; mos7840_tiocmset()
1702 static void mos7840_change_port_settings(struct tty_struct *tty, mos7840_change_port_settings() argument
1738 cflag = tty->termios.c_cflag; mos7840_change_port_settings()
1739 iflag = tty->termios.c_iflag; mos7840_change_port_settings()
1830 baud = tty_get_baud_rate(tty); mos7840_change_port_settings()
1860 * this function is called by the tty driver when it wants to change
1864 static void mos7840_set_termios(struct tty_struct *tty, mos7840_set_termios() argument
1893 cflag = tty->termios.c_cflag; mos7840_set_termios()
1896 tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); mos7840_set_termios()
1902 mos7840_change_port_settings(tty, mos7840_port, old_termios); mos7840_set_termios()
1931 static int mos7840_get_lsr_info(struct tty_struct *tty, mos7840_get_lsr_info() argument
1937 count = mos7840_chars_in_buffer(tty); mos7840_get_lsr_info()
1984 static int mos7840_ioctl(struct tty_struct *tty, mos7840_ioctl() argument
1987 struct usb_serial_port *port = tty->driver_data; mos7840_ioctl()
2004 return mos7840_get_lsr_info(tty, argp); mos7840_ioctl()
H A Dcp210x.c19 #include <linux/tty.h>
32 static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *);
464 static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) cp210x_open() argument
476 cp210x_get_termios(tty, port); cp210x_open()
479 if (tty) cp210x_open()
480 cp210x_change_speed(tty, port, NULL); cp210x_open()
482 return usb_serial_generic_open(tty, port); cp210x_open()
497 static void cp210x_get_termios(struct tty_struct *tty, cp210x_get_termios() argument
502 if (tty) { cp210x_get_termios()
503 cp210x_get_termios_port(tty->driver_data, cp210x_get_termios()
504 &tty->termios.c_cflag, &baud); cp210x_get_termios()
505 tty_encode_baud_rate(tty, baud, baud); cp210x_get_termios()
657 static void cp210x_change_speed(struct tty_struct *tty, cp210x_change_speed() argument
662 baud = tty->termios.c_ospeed; cp210x_change_speed()
681 tty_encode_baud_rate(tty, baud, baud); cp210x_change_speed()
684 static void cp210x_set_termios(struct tty_struct *tty, cp210x_set_termios() argument
692 cflag = tty->termios.c_cflag; cp210x_set_termios()
695 if (tty->termios.c_ospeed != old_termios->c_ospeed) cp210x_set_termios()
696 cp210x_change_speed(tty, port, old_termios); cp210x_set_termios()
799 static int cp210x_tiocmset(struct tty_struct *tty, cp210x_tiocmset() argument
802 struct usb_serial_port *port = tty->driver_data; cp210x_tiocmset()
841 static int cp210x_tiocmget(struct tty_struct *tty) cp210x_tiocmget() argument
843 struct usb_serial_port *port = tty->driver_data; cp210x_tiocmget()
861 static void cp210x_break_ctl(struct tty_struct *tty, int break_state) cp210x_break_ctl() argument
863 struct usb_serial_port *port = tty->driver_data; cp210x_break_ctl()
H A Dgarmin_gps.c30 #include <linux/tty.h>
136 __u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */
137 __u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */
300 the device, convert and send the next packet to tty. */ pkt_add()
344 /* send an ack packet back to the tty */ gsp_send_ack()
382 * called for a complete packet received from tty layer
454 * Called for data received from tty
463 * to the bulk pipe, send an ack back to the tty.
466 * tty layer.
588 * Sends a usb packet to the tty
737 * Called for data received from tty
921 static int garmin_open(struct tty_struct *tty, struct usb_serial_port *port) garmin_open() argument
1056 static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, garmin_write() argument
1128 static int garmin_write_room(struct tty_struct *tty) garmin_write_room() argument
1130 struct usb_serial_port *port = tty->driver_data; garmin_write_room()
1153 send it directly to the tty port */ garmin_read_process()
1305 * Sends the next queued packt to the tty port (garmin native mode only)
1331 static void garmin_throttle(struct tty_struct *tty) garmin_throttle() argument
1333 struct usb_serial_port *port = tty->driver_data; garmin_throttle()
1344 static void garmin_unthrottle(struct tty_struct *tty) garmin_unthrottle() argument
1346 struct usb_serial_port *port = tty->driver_data; garmin_unthrottle()
1354 /* in native mode send queued data to tty, in garmin_unthrottle()
1370 * the tty in cases where the protocol provides no own handshaking
1377 /* send the next queued packet to the tty port */ timeout_handler()
1429 .description = "Garmin GPS usb/tty",
H A Diuu_phoenix.c21 #include <linux/tty.h>
121 static int iuu_tiocmset(struct tty_struct *tty, iuu_tiocmset() argument
124 struct usb_serial_port *port = tty->driver_data; iuu_tiocmset()
150 static int iuu_tiocmget(struct tty_struct *tty) iuu_tiocmget() argument
152 struct usb_serial_port *port = tty->driver_data; iuu_tiocmget()
704 static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port, iuu_uart_write() argument
887 static void iuu_set_termios(struct tty_struct *tty, iuu_set_termios() argument
892 unsigned int cflag = tty->termios.c_cflag; iuu_set_termios()
901 baud = tty->termios.c_ospeed; iuu_set_termios()
932 tty_termios_copy_hw(&tty->termios, old_termios); iuu_set_termios()
936 tty_encode_baud_rate(tty, baud, baud); iuu_set_termios()
937 tty->termios.c_cflag &= ~(supported_mask|CSIZE); iuu_set_termios()
938 tty->termios.c_cflag |= newval | csize; iuu_set_termios()
953 static void iuu_init_termios(struct tty_struct *tty) iuu_init_termios() argument
955 tty->termios = tty_std_termios; iuu_init_termios()
956 tty->termios.c_cflag = CLOCAL | CREAD | CS8 | B9600 iuu_init_termios()
958 tty->termios.c_ispeed = 9600; iuu_init_termios()
959 tty->termios.c_ospeed = 9600; iuu_init_termios()
960 tty->termios.c_lflag = 0; iuu_init_termios()
961 tty->termios.c_oflag = 0; iuu_init_termios()
962 tty->termios.c_iflag = 0; iuu_init_termios()
965 static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) iuu_open() argument
975 baud = tty->termios.c_ospeed; iuu_open()
976 tty->termios.c_ispeed = baud; iuu_open()
978 tty_encode_baud_rate(tty, baud, baud); iuu_open()
H A Dmos7720.c26 #include <linux/tty.h>
993 static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port) mos7720_open() argument
1092 * this function is called by the tty driver when it wants to know how many
1099 static int mos7720_chars_in_buffer(struct tty_struct *tty) mos7720_chars_in_buffer() argument
1101 struct usb_serial_port *port = tty->driver_data; mos7720_chars_in_buffer()
1153 static void mos7720_break(struct tty_struct *tty, int break_state) mos7720_break() argument
1155 struct usb_serial_port *port = tty->driver_data; mos7720_break()
1177 * this function is called by the tty driver when it wants to know how many
1182 static int mos7720_write_room(struct tty_struct *tty) mos7720_write_room() argument
1184 struct usb_serial_port *port = tty->driver_data; mos7720_write_room()
1204 static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, mos7720_write() argument
1273 static void mos7720_throttle(struct tty_struct *tty) mos7720_throttle() argument
1275 struct usb_serial_port *port = tty->driver_data; mos7720_throttle()
1290 if (I_IXOFF(tty)) { mos7720_throttle()
1291 unsigned char stop_char = STOP_CHAR(tty); mos7720_throttle()
1292 status = mos7720_write(tty, port, &stop_char, 1); mos7720_throttle()
1298 if (tty->termios.c_cflag & CRTSCTS) { mos7720_throttle()
1305 static void mos7720_unthrottle(struct tty_struct *tty) mos7720_unthrottle() argument
1307 struct usb_serial_port *port = tty->driver_data; mos7720_unthrottle()
1320 if (I_IXOFF(tty)) { mos7720_unthrottle()
1321 unsigned char start_char = START_CHAR(tty); mos7720_unthrottle()
1322 status = mos7720_write(tty, port, &start_char, 1); mos7720_unthrottle()
1328 if (tty->termios.c_cflag & CRTSCTS) { mos7720_unthrottle()
1509 static void change_port_settings(struct tty_struct *tty, change_port_settings() argument
1541 cflag = tty->termios.c_cflag; change_port_settings()
1542 iflag = tty->termios.c_iflag; change_port_settings()
1632 baud = tty_get_baud_rate(tty); change_port_settings()
1651 tty_encode_baud_rate(tty, baud, baud); change_port_settings()
1664 * this function is called by the tty driver when it wants to change the
1667 static void mos7720_set_termios(struct tty_struct *tty, mos7720_set_termios() argument
1689 cflag = tty->termios.c_cflag; mos7720_set_termios()
1692 tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); mos7720_set_termios()
1698 change_port_settings(tty, mos7720_port, old_termios); mos7720_set_termios()
1717 static int get_lsr_info(struct tty_struct *tty, get_lsr_info() argument
1720 struct usb_serial_port *port = tty->driver_data; get_lsr_info()
1726 count = mos7720_chars_in_buffer(tty); get_lsr_info()
1740 static int mos7720_tiocmget(struct tty_struct *tty) mos7720_tiocmget() argument
1742 struct usb_serial_port *port = tty->driver_data; mos7720_tiocmget()
1761 static int mos7720_tiocmset(struct tty_struct *tty, mos7720_tiocmset() argument
1764 struct usb_serial_port *port = tty->driver_data; mos7720_tiocmset()
1861 static int mos7720_ioctl(struct tty_struct *tty, mos7720_ioctl() argument
1864 struct usb_serial_port *port = tty->driver_data; mos7720_ioctl()
1874 return get_lsr_info(tty, mos7720_port, mos7720_ioctl()
H A Dcyberjack.c34 #include <linux/tty.h>
55 static int cyberjack_open(struct tty_struct *tty,
58 static int cyberjack_write(struct tty_struct *tty,
60 static int cyberjack_write_room(struct tty_struct *tty);
138 static int cyberjack_open(struct tty_struct *tty, cyberjack_open() argument
164 static int cyberjack_write(struct tty_struct *tty, cyberjack_write() argument
249 static int cyberjack_write_room(struct tty_struct *tty) cyberjack_write_room() argument
H A Dftdi_sio.c37 #include <linux/tty.h>
1039 static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port);
1044 static void ftdi_set_termios(struct tty_struct *tty,
1046 static int ftdi_tiocmget(struct tty_struct *tty);
1047 static int ftdi_tiocmset(struct tty_struct *tty,
1049 static int ftdi_ioctl(struct tty_struct *tty,
1051 static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
1231 static __u32 get_ftdi_divisor(struct tty_struct *tty, get_ftdi_divisor() argument
1243 * 1. Standard baud rates are set in tty->termios->c_cflag get_ftdi_divisor()
1246 * - set tty->termios->c_cflag speed to B38400 get_ftdi_divisor()
1247 * - set your real speed in tty->alt_speed; it gets ignored when get_ftdi_divisor()
1256 * - set tty->termios->c_cflag speed to B38400 get_ftdi_divisor()
1267 /* 1. Get the baud rate from the tty settings, this observes get_ftdi_divisor()
1270 baud = tty_get_baud_rate(tty); get_ftdi_divisor()
1365 tty_encode_baud_rate(tty, baud, baud); get_ftdi_divisor()
1369 static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) change_speed() argument
1377 urb_index_value = get_ftdi_divisor(tty, port); change_speed()
1463 static int set_serial_info(struct tty_struct *tty, set_serial_info() argument
1507 tty->alt_speed = 57600; set_serial_info()
1509 tty->alt_speed = 115200; set_serial_info()
1511 tty->alt_speed = 230400; set_serial_info()
1513 tty->alt_speed = 460800; set_serial_info()
1515 tty->alt_speed = 0; set_serial_info()
1521 change_speed(tty, port); set_serial_info()
1940 static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) ftdi_open() argument
1953 port->tty->termios - this would lose speed settings, etc. ftdi_open()
1957 if (tty) ftdi_open()
1958 ftdi_set_termios(tty, port, NULL); ftdi_open()
1960 return usb_serial_generic_open(tty, port); ftdi_open()
2055 struct tty_struct *tty; ftdi_process_packet() local
2058 tty = tty_port_tty_get(&port->port); ftdi_process_packet()
2059 if (tty) ftdi_process_packet()
2060 usb_serial_handle_dcd_change(port, tty, ftdi_process_packet()
2062 tty_kref_put(tty); ftdi_process_packet()
2133 static void ftdi_break_ctl(struct tty_struct *tty, int break_state) ftdi_break_ctl() argument
2135 struct usb_serial_port *port = tty->driver_data; ftdi_break_ctl()
2177 /* old_termios contains the original termios settings and tty->termios contains
2181 static void ftdi_set_termios(struct tty_struct *tty, ftdi_set_termios() argument
2187 struct ktermios *termios = &tty->termios; ftdi_set_termios()
2200 tty_encode_baud_rate(tty, priv->force_baud, ftdi_set_termios()
2224 if (C_CSIZE(tty) == CS6) { ftdi_set_termios()
2315 if (change_speed(tty, port)) ftdi_set_termios()
2369 * ! XOFF. CHECKME Assuming XON/XOFF handled by tty ftdi_set_termios()
2450 static int ftdi_tiocmget(struct tty_struct *tty) ftdi_tiocmget() argument
2452 struct usb_serial_port *port = tty->driver_data; ftdi_tiocmget()
2470 static int ftdi_tiocmset(struct tty_struct *tty, ftdi_tiocmset() argument
2473 struct usb_serial_port *port = tty->driver_data; ftdi_tiocmset()
2478 static int ftdi_ioctl(struct tty_struct *tty, ftdi_ioctl() argument
2481 struct usb_serial_port *port = tty->driver_data; ftdi_ioctl()
2491 return set_serial_info(tty, port, ftdi_ioctl()
H A Dipw.c42 #include <linux/tty.h>
52 #define DRIVER_DESC "IPWireless tty driver"
136 static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) ipw_open() argument
169 usb_wwan_open(tty, port); ipw_open()
H A Dxsens_mt.c12 #include <linux/tty.h>
H A Dkeyspan.h38 static int keyspan_open (struct tty_struct *tty,
47 static int keyspan_write_room (struct tty_struct *tty);
49 static int keyspan_write (struct tty_struct *tty,
58 static void keyspan_set_termios (struct tty_struct *tty,
61 static void keyspan_break_ctl (struct tty_struct *tty,
63 static int keyspan_tiocmget (struct tty_struct *tty);
64 static int keyspan_tiocmset (struct tty_struct *tty,
/linux-4.1.27/drivers/net/caif/
H A Dcaif_serial.c15 #include <linux/tty.h>
70 struct tty_struct *tty; member in struct:ser_device
85 static void ldisc_tx_wakeup(struct tty_struct *tty);
90 ser->tty->stopped << 5 | update_tty_status()
91 ser->tty->flow_stopped << 3 | update_tty_status()
92 ser->tty->packet << 2 | update_tty_status()
93 ser->tty->port->low_latency << 1; update_tty_status()
95 static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty) debugfs_init() argument
98 debugfs_create_dir(tty->name, debugfsdir); debugfs_init()
146 static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty) debugfs_init() argument
168 static void ldisc_receive(struct tty_struct *tty, const u8 *data, ldisc_receive() argument
176 ser = tty->disc_data; ldisc_receive()
219 struct tty_struct *tty; handle_tx() local
223 tty = ser->tty; handle_tx()
235 room = tty_write_room(tty); handle_tx()
243 /* Write to tty or loopback */ handle_tx()
245 tty_wr = tty->ops->write(tty, skb->data, len); handle_tx()
249 ldisc_receive(tty, skb->data, NULL, len); handle_tx()
299 static void ldisc_tx_wakeup(struct tty_struct *tty) ldisc_tx_wakeup() argument
303 ser = tty->disc_data; ldisc_tx_wakeup()
305 WARN_ON(ser->tty != tty); ldisc_tx_wakeup()
332 static int ldisc_open(struct tty_struct *tty) ldisc_open() argument
340 if (tty->ops->write == NULL) ldisc_open()
348 result = snprintf(name, sizeof(name), "cf%s", tty->name); ldisc_open()
357 ser->tty = tty_kref_get(tty); ldisc_open()
359 debugfs_init(ser, tty); ldisc_open()
360 tty->receive_room = N_TTY_BUF_SIZE; ldisc_open()
361 tty->disc_data = ser; ldisc_open()
362 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); ldisc_open()
380 static void ldisc_close(struct tty_struct *tty) ldisc_close() argument
382 struct ser_device *ser = tty->disc_data; ldisc_close()
384 tty_kref_put(ser->tty); ldisc_close()
/linux-4.1.27/arch/alpha/kernel/
H A Dsrmcons.c16 #include <linux/tty.h>
82 if (port->tty) srmcons_receive_chars()
116 * Check for pending input iff a tty port was provided srmcons_do_write()
132 srmcons_write(struct tty_struct *tty, srmcons_write() argument
138 srmcons_do_write(tty->port, (const char *) buf, count); srmcons_write()
145 srmcons_write_room(struct tty_struct *tty) srmcons_write_room() argument
151 srmcons_chars_in_buffer(struct tty_struct *tty) srmcons_chars_in_buffer() argument
157 srmcons_open(struct tty_struct *tty, struct file *filp) srmcons_open() argument
165 if (!port->tty) { srmcons_open()
166 tty->driver_data = srmconsp; srmcons_open()
167 tty->port = port; srmcons_open()
168 port->tty = tty; /* XXX proper refcounting */ srmcons_open()
178 srmcons_close(struct tty_struct *tty, struct file *filp) srmcons_close() argument
180 struct srmcons_private *srmconsp = tty->driver_data; srmcons_close()
186 if (tty->count == 1) { srmcons_close()
187 port->tty = NULL; srmcons_close()
H A Dconsole.c10 #include <linux/tty.h>
/linux-4.1.27/drivers/staging/dgnc/
H A Ddgnc_utils.c1 #include <linux/tty.h>
H A Ddgnc_tty.c18 * This file implements the tty driver functionality for the
30 #include <linux/tty.h>
90 static int dgnc_tty_open(struct tty_struct *tty, struct file *file);
91 static void dgnc_tty_close(struct tty_struct *tty, struct file *file);
92 static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch);
93 static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
94 static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo);
95 static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info);
96 static int dgnc_tty_write_room(struct tty_struct *tty);
97 static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c);
98 static int dgnc_tty_chars_in_buffer(struct tty_struct *tty);
99 static void dgnc_tty_start(struct tty_struct *tty);
100 static void dgnc_tty_stop(struct tty_struct *tty);
101 static void dgnc_tty_throttle(struct tty_struct *tty);
102 static void dgnc_tty_unthrottle(struct tty_struct *tty);
103 static void dgnc_tty_flush_chars(struct tty_struct *tty);
104 static void dgnc_tty_flush_buffer(struct tty_struct *tty);
105 static void dgnc_tty_hangup(struct tty_struct *tty);
106 static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value);
108 static int dgnc_tty_tiocmget(struct tty_struct *tty);
109 static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear);
110 static int dgnc_tty_send_break(struct tty_struct *tty, int msec);
111 static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout);
112 static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count);
113 static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios);
114 static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch);
149 * Initialize any global tty related data before we download any boards.
175 * Init the tty subsystem for this board.
216 /* Register tty devices */ dgnc_tty_register()
220 "Can't register tty device (%d)\n", rc); dgnc_tty_register()
287 * Init the tty subsystem. Called once per board after board has been
384 * UnInitialize any global tty related data.
590 * The tty layer in the kernel has changed in 2.6.16+. dgnc_input()
592 * The flip buffers in the tty structure are no longer exposed, dgnc_input()
596 * of the tty layers that exist. dgnc_input()
601 * the new 2.6.16+ tty layer, which has its API more well defined. dgnc_input()
608 * bounded either by how much the Linux tty layer can handle, dgnc_input()
650 /* Tell the tty layer its okay to "eat" the data now */ dgnc_input()
1008 static int dgnc_tty_open(struct tty_struct *tty, struct file *file) dgnc_tty_open() argument
1020 major = MAJOR(tty_devnum(tty)); dgnc_tty_open()
1021 minor = MINOR(tty_devnum(tty)); dgnc_tty_open()
1104 tty->driver_data = un; dgnc_tty_open()
1108 * Initialize tty's dgnc_tty_open()
1112 un->un_tty = tty; dgnc_tty_open()
1162 ch->ch_c_cflag = tty->termios.c_cflag; dgnc_tty_open()
1163 ch->ch_c_iflag = tty->termios.c_iflag; dgnc_tty_open()
1164 ch->ch_c_oflag = tty->termios.c_oflag; dgnc_tty_open()
1165 ch->ch_c_lflag = tty->termios.c_lflag; dgnc_tty_open()
1166 ch->ch_startc = tty->termios.c_cc[VSTART]; dgnc_tty_open()
1167 ch->ch_stopc = tty->termios.c_cc[VSTOP]; dgnc_tty_open()
1185 brd->bd_ops->param(tty); dgnc_tty_open()
1195 rc = dgnc_block_til_ready(tty, file, ch); dgnc_tty_open()
1213 static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) dgnc_block_til_ready() argument
1221 if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGNC_CHANNEL_MAGIC) dgnc_block_til_ready()
1224 un = tty->driver_data; dgnc_block_til_ready()
1245 /* If tty was hung up, break out of loop and set error. */ dgnc_block_til_ready()
1262 * 1) NONBLOCKING on the tty is set. dgnc_block_til_ready()
1270 if (tty->flags & (1 << TTY_IO_ERROR)) { dgnc_block_til_ready()
1343 static void dgnc_tty_hangup(struct tty_struct *tty) dgnc_tty_hangup() argument
1347 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_hangup()
1350 un = tty->driver_data; dgnc_tty_hangup()
1355 dgnc_tty_flush_buffer(tty); dgnc_tty_hangup()
1364 static void dgnc_tty_close(struct tty_struct *tty, struct file *file) dgnc_tty_close() argument
1373 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_close()
1376 un = tty->driver_data; dgnc_tty_close()
1388 ts = &tty->termios; dgnc_tty_close()
1396 if ((tty->count == 1) && (un->un_open_count != 1)) { dgnc_tty_close()
1398 * Uh, oh. tty->count is 1, which means that the tty dgnc_tty_close()
1404 dev_dbg(tty->dev, dgnc_tty_close()
1405 "tty->count is 1, un open count is %d\n", dgnc_tty_close()
1413 dev_dbg(tty->dev, dgnc_tty_close()
1427 tty->closing = 1; dgnc_tty_close()
1451 rc = bd->bd_ops->drain(tty, 0); dgnc_tty_close()
1453 dgnc_tty_flush_buffer(tty); dgnc_tty_close()
1454 tty_ldisc_flush(tty); dgnc_tty_close()
1458 tty->closing = 0; dgnc_tty_close()
1514 static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) dgnc_tty_chars_in_buffer() argument
1524 if (tty == NULL) dgnc_tty_chars_in_buffer()
1527 un = tty->driver_data; dgnc_tty_chars_in_buffer()
1564 static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) dgnc_maxcps_room() argument
1569 if (!tty) dgnc_maxcps_room()
1572 un = tty->driver_data; dgnc_maxcps_room()
1617 static int dgnc_tty_write_room(struct tty_struct *tty) dgnc_tty_write_room() argument
1627 if (tty == NULL || dgnc_TmpWriteBuf == NULL) dgnc_tty_write_room()
1630 un = tty->driver_data; dgnc_tty_write_room()
1649 ret = dgnc_maxcps_room(tty, ret); dgnc_tty_write_room()
1680 static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c) dgnc_tty_put_char() argument
1685 dgnc_tty_write(tty, &c, 1); dgnc_tty_put_char()
1696 static int dgnc_tty_write(struct tty_struct *tty, dgnc_tty_write() argument
1710 if (tty == NULL || dgnc_TmpWriteBuf == NULL) dgnc_tty_write()
1713 un = tty->driver_data; dgnc_tty_write()
1746 bufcount = dgnc_maxcps_room(tty, bufcount); dgnc_tty_write()
1884 static int dgnc_tty_tiocmget(struct tty_struct *tty) dgnc_tty_tiocmget() argument
1892 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_tiocmget()
1895 un = tty->driver_data; dgnc_tty_tiocmget()
1934 static int dgnc_tty_tiocmset(struct tty_struct *tty, dgnc_tty_tiocmset() argument
1943 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_tiocmset()
1946 un = tty->driver_data; dgnc_tty_tiocmset()
1985 static int dgnc_tty_send_break(struct tty_struct *tty, int msec) dgnc_tty_send_break() argument
1993 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_send_break()
1996 un = tty->driver_data; dgnc_tty_send_break()
2035 static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout) dgnc_tty_wait_until_sent() argument
2042 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_wait_until_sent()
2045 un = tty->driver_data; dgnc_tty_wait_until_sent()
2057 rc = bd->bd_ops->drain(tty, 0); dgnc_tty_wait_until_sent()
2066 static void dgnc_tty_send_xchar(struct tty_struct *tty, char c) dgnc_tty_send_xchar() argument
2073 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_send_xchar()
2076 un = tty->driver_data; dgnc_tty_send_xchar()
2088 dev_dbg(tty->dev, "dgnc_tty_send_xchar start\n"); dgnc_tty_send_xchar()
2094 dev_dbg(tty->dev, "dgnc_tty_send_xchar finish\n"); dgnc_tty_send_xchar()
2162 static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value) dgnc_set_modem_info() argument
2171 if (!tty || tty->magic != TTY_MAGIC) dgnc_set_modem_info()
2174 un = tty->driver_data; dgnc_set_modem_info()
2245 static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo) dgnc_tty_digigeta() argument
2255 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_digigeta()
2258 un = tty->driver_data; dgnc_tty_digigeta()
2287 static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info) dgnc_tty_digiseta() argument
2295 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_digiseta()
2298 un = tty->driver_data; dgnc_tty_digiseta()
2354 ch->ch_bd->bd_ops->param(tty); dgnc_tty_digiseta()
2365 static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) dgnc_tty_set_termios() argument
2372 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_set_termios()
2375 un = tty->driver_data; dgnc_tty_set_termios()
2389 ch->ch_c_cflag = tty->termios.c_cflag; dgnc_tty_set_termios()
2390 ch->ch_c_iflag = tty->termios.c_iflag; dgnc_tty_set_termios()
2391 ch->ch_c_oflag = tty->termios.c_oflag; dgnc_tty_set_termios()
2392 ch->ch_c_lflag = tty->termios.c_lflag; dgnc_tty_set_termios()
2393 ch->ch_startc = tty->termios.c_cc[VSTART]; dgnc_tty_set_termios()
2394 ch->ch_stopc = tty->termios.c_cc[VSTOP]; dgnc_tty_set_termios()
2396 ch->ch_bd->bd_ops->param(tty); dgnc_tty_set_termios()
2403 static void dgnc_tty_throttle(struct tty_struct *tty) dgnc_tty_throttle() argument
2409 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_throttle()
2412 un = tty->driver_data; dgnc_tty_throttle()
2428 static void dgnc_tty_unthrottle(struct tty_struct *tty) dgnc_tty_unthrottle() argument
2434 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_unthrottle()
2437 un = tty->driver_data; dgnc_tty_unthrottle()
2453 static void dgnc_tty_start(struct tty_struct *tty) dgnc_tty_start() argument
2460 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_start()
2463 un = tty->driver_data; dgnc_tty_start()
2483 static void dgnc_tty_stop(struct tty_struct *tty) dgnc_tty_stop() argument
2490 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_stop()
2493 un = tty->driver_data; dgnc_tty_stop()
2526 static void dgnc_tty_flush_chars(struct tty_struct *tty) dgnc_tty_flush_chars() argument
2533 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_flush_chars()
2536 un = tty->driver_data; dgnc_tty_flush_chars()
2562 static void dgnc_tty_flush_buffer(struct tty_struct *tty) dgnc_tty_flush_buffer() argument
2568 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_flush_buffer()
2571 un = tty->driver_data; dgnc_tty_flush_buffer()
2614 static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, dgnc_tty_ioctl() argument
2624 if (!tty || tty->magic != TTY_MAGIC) dgnc_tty_ioctl()
2627 un = tty->driver_data; dgnc_tty_ioctl()
2659 rc = tty_check_change(tty); dgnc_tty_ioctl()
2664 rc = ch->ch_bd->bd_ops->drain(tty, 0); dgnc_tty_ioctl()
2685 rc = tty_check_change(tty); dgnc_tty_ioctl()
2690 rc = ch->ch_bd->bd_ops->drain(tty, 0); dgnc_tty_ioctl()
2703 rc = tty_check_change(tty); dgnc_tty_ioctl()
2708 rc = ch->ch_bd->bd_ops->drain(tty, 0); dgnc_tty_ioctl()
2729 rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg); dgnc_tty_ioctl()
2740 tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); dgnc_tty_ioctl()
2741 ch->ch_bd->bd_ops->param(tty); dgnc_tty_ioctl()
2754 return dgnc_set_modem_info(tty, cmd, uarg); dgnc_tty_ioctl()
2762 * The linux tty driver doesn't have a flush dgnc_tty_ioctl()
2770 rc = tty_check_change(tty); dgnc_tty_ioctl()
2807 * The linux tty driver doesn't have a flush dgnc_tty_ioctl()
2826 rc = ch->ch_bd->bd_ops->drain(tty, 0); dgnc_tty_ioctl()
2836 rc = ch->ch_bd->bd_ops->drain(tty, 0); dgnc_tty_ioctl()
2851 return dgnc_tty_digigeta(tty, uarg); dgnc_tty_ioctl()
2860 rc = ch->ch_bd->bd_ops->drain(tty, 0); dgnc_tty_ioctl()
2867 tty_ldisc_flush(tty); dgnc_tty_ioctl()
2873 return dgnc_tty_digiseta(tty, uarg); dgnc_tty_ioctl()
2891 ch->ch_bd->bd_ops->param(tty); dgnc_tty_ioctl()
2911 ch->ch_bd->bd_ops->param(tty); dgnc_tty_ioctl()
/linux-4.1.27/drivers/staging/gdm724x/
H A Dgdm_tty.c18 #include <linux/tty.h>
71 static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty) gdm_tty_install() argument
80 if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) { gdm_tty_install()
81 j = tty->index; gdm_tty_install()
98 ret = tty_standard_install(driver, tty); gdm_tty_install()
105 tty->driver_data = gdm; gdm_tty_install()
111 static int gdm_tty_open(struct tty_struct *tty, struct file *filp) gdm_tty_open() argument
113 struct gdm *gdm = tty->driver_data; gdm_tty_open()
115 return tty_port_open(&gdm->port, tty, filp); gdm_tty_open()
118 static void gdm_tty_cleanup(struct tty_struct *tty) gdm_tty_cleanup() argument
120 struct gdm *gdm = tty->driver_data; gdm_tty_cleanup()
125 static void gdm_tty_hangup(struct tty_struct *tty) gdm_tty_hangup() argument
127 struct gdm *gdm = tty->driver_data; gdm_tty_hangup()
132 static void gdm_tty_close(struct tty_struct *tty, struct file *filp) gdm_tty_close() argument
134 struct gdm *gdm = tty->driver_data; gdm_tty_close()
136 tty_port_close(&gdm->port, tty, filp); gdm_tty_close()
178 static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf, gdm_tty_write() argument
181 struct gdm *gdm = tty->driver_data; gdm_tty_write()
211 static int gdm_tty_write_room(struct tty_struct *tty) gdm_tty_write_room() argument
213 struct gdm *gdm = tty->driver_data; gdm_tty_write_room()
269 struct tty_struct *tty; unregister_lte_tty_device() local
281 tty = tty_port_tty_get(&gdm->port); unregister_lte_tty_device()
282 if (tty) { unregister_lte_tty_device()
283 tty_vhangup(tty); unregister_lte_tty_device()
284 tty_kref_put(tty); unregister_lte_tty_device()
H A Dgdm_tty.h18 #include <linux/tty.h>
/linux-4.1.27/fs/proc/
H A Dproc_tty.c2 * proc_tty.c -- handles /proc/tty
14 #include <linux/tty.h>
19 * The /proc/tty directory inodes...
24 * This is the handler for /proc/tty/drivers
41 seq_puts(m, ":/dev/tty"); show_tty_range()
75 seq_printf(m, "%-20s /dev/%-8s ", "/dev/tty", "tty"); show_tty_driver()
77 seq_puts(m, "system:/dev/tty\n"); show_tty_driver()
141 * registering the driver's /proc handler into /proc/tty/driver/<foo>
173 * Called by proc_root_init() to initialize the /proc/tty subtree
177 if (!proc_mkdir("tty", NULL)) proc_tty_init()
179 proc_mkdir("tty/ldisc", NULL); /* Preserved: it's userspace visible */ proc_tty_init()
181 * /proc/tty/driver/serial reveals the exact character counts for proc_tty_init()
186 proc_tty_driver = proc_mkdir_mode("tty/driver", S_IRUSR|S_IXUSR, NULL); proc_tty_init()
187 proc_create("tty/ldiscs", 0, NULL, &tty_ldiscs_proc_fops); proc_tty_init()
188 proc_create("tty/drivers", 0, NULL, &proc_tty_drivers_operations); proc_tty_init()
/linux-4.1.27/arch/um/os-Linux/
H A DMakefile7 registers.o sigio.o signal.o start_up.o time.o tty.o \
14 tty.o umid.o util.o
/linux-4.1.27/drivers/mmc/card/
H A Dsdio_uart.c37 #include <linux/tty.h>
146 * the tty layer. Be careful to prevent any further access sdio_uart_port_remove()
147 * to the SDIO function and arrange for the tty layer to sdio_uart_port_remove()
434 struct tty_struct *tty; sdio_uart_transmit_chars() local
445 tty = tty_port_tty_get(&port->port); sdio_uart_transmit_chars()
447 if (tty == NULL || !kfifo_len(xmit) || sdio_uart_transmit_chars()
448 tty->stopped || tty->hw_stopped) { sdio_uart_transmit_chars()
450 tty_kref_put(tty); sdio_uart_transmit_chars()
462 tty_wakeup(tty); sdio_uart_transmit_chars()
466 tty_kref_put(tty); sdio_uart_transmit_chars()
472 struct tty_struct *tty; sdio_uart_check_modem_status() local
489 /* DCD drop - hang up if tty attached */ sdio_uart_check_modem_status()
495 tty = tty_port_tty_get(&port->port); sdio_uart_check_modem_status()
496 if (tty && (tty->termios.c_cflag & CRTSCTS)) { sdio_uart_check_modem_status()
498 if (tty->hw_stopped) { sdio_uart_check_modem_status()
500 tty->hw_stopped = 0; sdio_uart_check_modem_status()
502 tty_wakeup(tty); sdio_uart_check_modem_status()
506 tty->hw_stopped = 1; sdio_uart_check_modem_status()
511 tty_kref_put(tty); sdio_uart_check_modem_status()
527 * interaction with the tty core may end up calling us back sdio_uart_irq()
564 * @tport: tty port to be updated
567 * Called by the tty port helpers when the modem signals need to be
587 * @tport: tty port to activate
588 * @tty: tty bound to this port
590 * Activate a tty port. The port locking guarantees us this will be
600 static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty) sdio_uart_activate() argument
610 set_bit(TTY_IO_ERROR, &tty->flags); sdio_uart_activate()
649 sdio_uart_change_speed(port, &tty->termios, NULL); sdio_uart_activate()
651 if (tty->termios.c_cflag & CBAUD) sdio_uart_activate()
654 if (tty->termios.c_cflag & CRTSCTS) sdio_uart_activate()
656 tty->hw_stopped = 1; sdio_uart_activate()
658 clear_bit(TTY_IO_ERROR, &tty->flags); sdio_uart_activate()
675 * @tport: tty port to shut down
677 * Deactivate a tty port. The port locking guarantees us this will be
726 * @tty: the tty being bound
728 * Look up and bind the tty and the driver together. Initialize
732 static int sdio_uart_install(struct tty_driver *driver, struct tty_struct *tty) sdio_uart_install() argument
734 int idx = tty->index; sdio_uart_install()
736 int ret = tty_standard_install(driver, tty); sdio_uart_install()
740 tty->driver_data = port; sdio_uart_install()
747 * sdio_uart_cleanup - called on the last tty kref drop
748 * @tty: the tty being destroyed
750 * Called asynchronously when the last reference to the tty is dropped.
751 * We cannot destroy the tty->driver_data port kref until this point
754 static void sdio_uart_cleanup(struct tty_struct *tty) sdio_uart_cleanup() argument
756 struct sdio_uart_port *port = tty->driver_data; sdio_uart_cleanup()
757 tty->driver_data = NULL; /* Bug trap */ sdio_uart_cleanup()
765 static int sdio_uart_open(struct tty_struct *tty, struct file *filp) sdio_uart_open() argument
767 struct sdio_uart_port *port = tty->driver_data; sdio_uart_open()
768 return tty_port_open(&port->port, tty, filp); sdio_uart_open()
771 static void sdio_uart_close(struct tty_struct *tty, struct file * filp) sdio_uart_close() argument
773 struct sdio_uart_port *port = tty->driver_data; sdio_uart_close()
774 tty_port_close(&port->port, tty, filp); sdio_uart_close()
777 static void sdio_uart_hangup(struct tty_struct *tty) sdio_uart_hangup() argument
779 struct sdio_uart_port *port = tty->driver_data; sdio_uart_hangup()
783 static int sdio_uart_write(struct tty_struct *tty, const unsigned char *buf, sdio_uart_write() argument
786 struct sdio_uart_port *port = tty->driver_data; sdio_uart_write()
806 static int sdio_uart_write_room(struct tty_struct *tty) sdio_uart_write_room() argument
808 struct sdio_uart_port *port = tty->driver_data; sdio_uart_write_room()
812 static int sdio_uart_chars_in_buffer(struct tty_struct *tty) sdio_uart_chars_in_buffer() argument
814 struct sdio_uart_port *port = tty->driver_data; sdio_uart_chars_in_buffer()
818 static void sdio_uart_send_xchar(struct tty_struct *tty, char ch) sdio_uart_send_xchar() argument
820 struct sdio_uart_port *port = tty->driver_data; sdio_uart_send_xchar()
832 static void sdio_uart_throttle(struct tty_struct *tty) sdio_uart_throttle() argument
834 struct sdio_uart_port *port = tty->driver_data; sdio_uart_throttle()
836 if (!I_IXOFF(tty) && !(tty->termios.c_cflag & CRTSCTS)) sdio_uart_throttle()
842 if (I_IXOFF(tty)) { sdio_uart_throttle()
843 port->x_char = STOP_CHAR(tty); sdio_uart_throttle()
847 if (tty->termios.c_cflag & CRTSCTS) sdio_uart_throttle()
854 static void sdio_uart_unthrottle(struct tty_struct *tty) sdio_uart_unthrottle() argument
856 struct sdio_uart_port *port = tty->driver_data; sdio_uart_unthrottle()
858 if (!I_IXOFF(tty) && !(tty->termios.c_cflag & CRTSCTS)) sdio_uart_unthrottle()
864 if (I_IXOFF(tty)) { sdio_uart_unthrottle()
868 port->x_char = START_CHAR(tty); sdio_uart_unthrottle()
873 if (tty->termios.c_cflag & CRTSCTS) sdio_uart_unthrottle()
880 static void sdio_uart_set_termios(struct tty_struct *tty, sdio_uart_set_termios() argument
883 struct sdio_uart_port *port = tty->driver_data; sdio_uart_set_termios()
884 unsigned int cflag = tty->termios.c_cflag; sdio_uart_set_termios()
889 sdio_uart_change_speed(port, &tty->termios, old_termios); sdio_uart_set_termios()
898 if (!(cflag & CRTSCTS) || !test_bit(TTY_THROTTLED, &tty->flags)) sdio_uart_set_termios()
905 tty->hw_stopped = 0; sdio_uart_set_termios()
912 tty->hw_stopped = 1; sdio_uart_set_termios()
920 static int sdio_uart_break_ctl(struct tty_struct *tty, int break_state) sdio_uart_break_ctl() argument
922 struct sdio_uart_port *port = tty->driver_data; sdio_uart_break_ctl()
939 static int sdio_uart_tiocmget(struct tty_struct *tty) sdio_uart_tiocmget() argument
941 struct sdio_uart_port *port = tty->driver_data; sdio_uart_tiocmget()
953 static int sdio_uart_tiocmset(struct tty_struct *tty, sdio_uart_tiocmset() argument
956 struct sdio_uart_port *port = tty->driver_data; sdio_uart_tiocmset()
/linux-4.1.27/drivers/staging/speakup/
H A Dselection.c8 #include <linux/tty.h>
52 int speakup_set_selection(struct tty_struct *tty) speakup_set_selection() argument
77 dev_warn(tty->dev, speakup_set_selection()
131 struct tty_struct *tty; member in struct:speakup_paste_work
138 struct tty_struct *tty = xchg(&spw->tty, NULL); __speakup_paste_selection() local
139 struct vc_data *vc = (struct vc_data *) tty->driver_data; __speakup_paste_selection()
144 ld = tty_ldisc_ref(tty); __speakup_paste_selection()
152 if (test_bit(TTY_THROTTLED, &tty->flags)) { __speakup_paste_selection()
167 tty_kref_put(tty); __speakup_paste_selection()
175 int speakup_paste_selection(struct tty_struct *tty) speakup_paste_selection() argument
177 if (cmpxchg(&speakup_paste_work.tty, NULL, tty) != NULL) speakup_paste_selection()
180 tty_kref_get(tty); speakup_paste_selection()
188 tty_kref_put(speakup_paste_work.tty); speakup_cancel_paste()
H A Dbuffers.c30 if ((vc_cons[i].d != NULL) && (vc_cons[i].d->port.tty != NULL)) speakup_start_ttys()
31 start_tty(vc_cons[i].d->port.tty); speakup_start_ttys()
41 if ((vc_cons[i].d != NULL) && (vc_cons[i].d->port.tty != NULL)) speakup_stop_ttys()
42 stop_tty(vc_cons[i].d->port.tty); speakup_stop_ttys()
H A Dspeakup.h78 extern int speakup_set_selection(struct tty_struct *tty);
79 extern int speakup_paste_selection(struct tty_struct *tty);
/linux-4.1.27/drivers/ipack/devices/
H A Dipoctal.c19 #include <linux/tty.h>
74 static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty) ipoctal_port_activate() argument
78 channel = dev_get_drvdata(tty->dev); ipoctal_port_activate()
89 static int ipoctal_open(struct tty_struct *tty, struct file *file) ipoctal_open() argument
91 struct ipoctal_channel *channel = dev_get_drvdata(tty->dev); ipoctal_open()
92 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index); ipoctal_open()
95 tty->driver_data = channel; ipoctal_open()
100 err = tty_port_open(&channel->tty_port, tty, file); ipoctal_open()
125 static void ipoctal_close(struct tty_struct *tty, struct file *filp) ipoctal_close() argument
127 struct ipoctal_channel *channel = tty->driver_data; ipoctal_close()
129 tty_port_close(&channel->tty_port, tty, filp); ipoctal_close()
133 static int ipoctal_get_icount(struct tty_struct *tty, ipoctal_get_icount() argument
136 struct ipoctal_channel *channel = tty->driver_data; ipoctal_get_icount()
271 struct tty_driver *tty; ipoctal_inst_slot() local
355 tty = alloc_tty_driver(NR_CHANNELS); ipoctal_inst_slot()
357 if (!tty) ipoctal_inst_slot()
361 tty->owner = THIS_MODULE; ipoctal_inst_slot()
362 tty->driver_name = KBUILD_MODNAME; ipoctal_inst_slot()
364 tty->name = name; ipoctal_inst_slot()
365 tty->major = 0; ipoctal_inst_slot()
367 tty->minor_start = 0; ipoctal_inst_slot()
368 tty->type = TTY_DRIVER_TYPE_SERIAL; ipoctal_inst_slot()
369 tty->subtype = SERIAL_TYPE_NORMAL; ipoctal_inst_slot()
370 tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; ipoctal_inst_slot()
371 tty->init_termios = tty_std_termios; ipoctal_inst_slot()
372 tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; ipoctal_inst_slot()
373 tty->init_termios.c_ispeed = 9600; ipoctal_inst_slot()
374 tty->init_termios.c_ospeed = 9600; ipoctal_inst_slot()
376 tty_set_operations(tty, &ipoctal_fops); ipoctal_inst_slot()
377 res = tty_register_driver(tty); ipoctal_inst_slot()
379 dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n"); ipoctal_inst_slot()
380 put_tty_driver(tty); ipoctal_inst_slot()
385 ipoctal->tty_drv = tty; ipoctal_inst_slot()
400 tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL); ipoctal_inst_slot()
402 dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n"); ipoctal_inst_slot()
443 static int ipoctal_write_tty(struct tty_struct *tty, ipoctal_write_tty() argument
446 struct ipoctal_channel *channel = tty->driver_data; ipoctal_write_tty()
466 static int ipoctal_write_room(struct tty_struct *tty) ipoctal_write_room() argument
468 struct ipoctal_channel *channel = tty->driver_data; ipoctal_write_room()
473 static int ipoctal_chars_in_buffer(struct tty_struct *tty) ipoctal_chars_in_buffer() argument
475 struct ipoctal_channel *channel = tty->driver_data; ipoctal_chars_in_buffer()
480 static void ipoctal_set_termios(struct tty_struct *tty, ipoctal_set_termios() argument
487 struct ipoctal_channel *channel = tty->driver_data; ipoctal_set_termios()
490 cflag = tty->termios.c_cflag; ipoctal_set_termios()
507 tty->termios.c_cflag = (cflag & ~CSIZE) | CS8; ipoctal_set_termios()
521 tty->termios.c_cflag &= ~CMSPAR; ipoctal_set_termios()
553 baud = tty_get_baud_rate(tty); ipoctal_set_termios()
554 tty_termios_encode_baud_rate(&tty->termios, baud, baud); ipoctal_set_termios()
598 tty_termios_encode_baud_rate(&tty->termios, 38400, 38400); ipoctal_set_termios()
615 static void ipoctal_hangup(struct tty_struct *tty) ipoctal_hangup() argument
618 struct ipoctal_channel *channel = tty->driver_data; ipoctal_hangup()
637 static void ipoctal_shutdown(struct tty_struct *tty) ipoctal_shutdown() argument
639 struct ipoctal_channel *channel = tty->driver_data; ipoctal_shutdown()
648 static void ipoctal_cleanup(struct tty_struct *tty) ipoctal_cleanup() argument
650 struct ipoctal_channel *channel = tty->driver_data; ipoctal_cleanup()
651 struct ipoctal *ipoctal = chan_to_ipoctal(channel, tty->index); ipoctal_cleanup()
/linux-4.1.27/drivers/pps/clients/
H A Dpps-ldisc.c26 #include <linux/tty.h>
32 static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status) pps_tty_dcd_change() argument
39 pps = pps_lookup_dev(tty); pps_tty_dcd_change()
55 static int (*alias_n_tty_open)(struct tty_struct *tty);
57 static int pps_tty_open(struct tty_struct *tty) pps_tty_open() argument
60 struct tty_driver *drv = tty->driver; pps_tty_open()
61 int index = tty->index + drv->name_base; pps_tty_open()
79 pps->lookup_cookie = tty; pps_tty_open()
82 ret = alias_n_tty_open(tty); pps_tty_open()
84 pr_err("cannot open tty ldisc \"%s\"\n", info.path); pps_tty_open()
97 static void (*alias_n_tty_close)(struct tty_struct *tty);
99 static void pps_tty_close(struct tty_struct *tty) pps_tty_close() argument
101 struct pps_device *pps = pps_lookup_dev(tty); pps_tty_close()
103 alias_n_tty_close(tty); pps_tty_close()
/linux-4.1.27/drivers/char/
H A Dttyprintk.c19 #include <linux/tty.h>
97 static int tpk_open(struct tty_struct *tty, struct file *filp) tpk_open() argument
99 tty->driver_data = &tpk_port; tpk_open()
101 return tty_port_open(&tpk_port.port, tty, filp); tpk_open()
107 static void tpk_close(struct tty_struct *tty, struct file *filp) tpk_close() argument
109 struct ttyprintk_port *tpkp = tty->driver_data; tpk_close()
116 tty_port_close(&tpkp->port, tty, filp); tpk_close()
122 static int tpk_write(struct tty_struct *tty, tpk_write() argument
125 struct ttyprintk_port *tpkp = tty->driver_data; tpk_write()
129 /* exclusive use of tpk_printk within this tty */ tpk_write()
140 static int tpk_write_room(struct tty_struct *tty) tpk_write_room() argument
148 static int tpk_ioctl(struct tty_struct *tty, tpk_ioctl() argument
151 struct ttyprintk_port *tpkp = tty->driver_data; tpk_ioctl()
/linux-4.1.27/drivers/net/can/
H A Dslcan.c2 * slcan.c - serial line CAN interface driver (using tty line discipline)
44 #include <linux/tty.h>
83 struct tty_struct *tty; /* ptr to TTY structure */ member in struct:slcan
227 /* parse tty input stream */ slcan_unesc()
305 set_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); slc_encaps()
306 actual = sl->tty->ops->write(sl->tty, sl->xbuff, pos - sl->xbuff); slc_encaps()
312 /* Write out any remaining transmit buffer. Scheduled when tty is writable */ slcan_transmit()
320 if (!sl->tty || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) { slcan_transmit()
329 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); slcan_transmit()
335 actual = sl->tty->ops->write(sl->tty, sl->xhead, sl->xleft); slcan_transmit()
345 static void slcan_write_wakeup(struct tty_struct *tty) slcan_write_wakeup() argument
347 struct slcan *sl = tty->disc_data; slcan_write_wakeup()
366 if (sl->tty == NULL) { slc_xmit()
391 if (sl->tty) { slc_close()
393 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); slc_close()
408 if (sl->tty == NULL) slc_open()
466 static void slcan_receive_buf(struct tty_struct *tty, slcan_receive_buf() argument
469 struct slcan *sl = (struct slcan *) tty->disc_data; slcan_receive_buf()
503 if (sl->tty) slc_sync()
510 /* Find a free SLCAN channel, and link in this `tty' line. */ slc_alloc()
551 * sure the tty line exists, we only have to link it to
557 static int slcan_open(struct tty_struct *tty) slcan_open() argument
565 if (tty->ops->write == NULL) slcan_open()
577 sl = tty->disc_data; slcan_open()
586 sl = slc_alloc(tty_devnum(tty)); slcan_open()
590 sl->tty = tty; slcan_open()
591 tty->disc_data = sl; slcan_open()
607 tty->receive_room = 65536; /* We don't flow control */ slcan_open()
613 sl->tty = NULL; slcan_open()
614 tty->disc_data = NULL; slcan_open()
632 static void slcan_close(struct tty_struct *tty) slcan_close() argument
634 struct slcan *sl = (struct slcan *) tty->disc_data; slcan_close()
637 if (!sl || sl->magic != SLCAN_MAGIC || sl->tty != tty) slcan_close()
641 tty->disc_data = NULL; slcan_close()
642 sl->tty = NULL; slcan_close()
652 static int slcan_hangup(struct tty_struct *tty) slcan_hangup() argument
654 slcan_close(tty); slcan_hangup()
659 static int slcan_ioctl(struct tty_struct *tty, struct file *file, slcan_ioctl() argument
662 struct slcan *sl = (struct slcan *) tty->disc_data; slcan_ioctl()
680 return tty_mode_ioctl(tty, file, cmd, arg); slcan_ioctl()
743 if (sl->tty) { slcan_exit()
745 tty_hangup(sl->tty); slcan_exit()
761 if (sl->tty) { slcan_exit()
762 printk(KERN_ERR "%s: tty discipline still running\n", slcan_exit()
/linux-4.1.27/drivers/net/ppp/
H A Dppp_synctty.c2 * PPP synchronous tty channel driver for Linux.
4 * This is a ppp channel driver that can be used with tty device drivers
38 #include <linux/tty.h>
56 struct tty_struct *tty; member in struct:syncppp
125 * We have a potential race on dereferencing tty->disc_data,
126 * because the tty layer provides no locking at all - thus one
128 * calls ppp_synctty_close, which zeroes tty->disc_data and
130 * way to fix this is to use a rwlock in the tty struct, but for now
137 static struct syncppp *sp_get(struct tty_struct *tty) sp_get() argument
142 ap = tty->disc_data; sp_get()
156 * Called when a tty is put into sync-PPP line discipline.
159 ppp_sync_open(struct tty_struct *tty) ppp_sync_open() argument
165 if (tty->ops->write == NULL) ppp_sync_open()
174 ap->tty = tty; ppp_sync_open()
192 speed = tty_get_baud_rate(tty); ppp_sync_open()
198 tty->disc_data = ap; ppp_sync_open()
199 tty->receive_room = 65536; ppp_sync_open()
209 * Called when the tty is put into another line discipline
217 ppp_sync_close(struct tty_struct *tty) ppp_sync_close() argument
222 ap = tty->disc_data; ppp_sync_close()
223 tty->disc_data = NULL; ppp_sync_close()
246 * Called on tty hangup in process context.
251 static int ppp_sync_hangup(struct tty_struct *tty) ppp_sync_hangup() argument
253 ppp_sync_close(tty); ppp_sync_hangup()
262 ppp_sync_read(struct tty_struct *tty, struct file *file, ppp_sync_read() argument
269 * Write on the tty does nothing, the packets all come in
273 ppp_sync_write(struct tty_struct *tty, struct file *file, ppp_sync_write() argument
280 ppp_synctty_ioctl(struct tty_struct *tty, struct file *file, ppp_synctty_ioctl() argument
283 struct syncppp *ap = sp_get(tty); ppp_synctty_ioctl()
309 err = n_tty_ioctl_helper(tty, file, cmd, arg); ppp_synctty_ioctl()
320 err = tty_mode_ioctl(tty, file, cmd, arg); ppp_synctty_ioctl()
330 ppp_sync_poll(struct tty_struct *tty, struct file *file, poll_table *wait) ppp_sync_poll() argument
337 ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, ppp_sync_receive() argument
340 struct syncppp *ap = sp_get(tty); ppp_sync_receive()
351 tty_unthrottle(tty); ppp_sync_receive()
355 ppp_sync_wakeup(struct tty_struct *tty) ppp_sync_wakeup() argument
357 struct syncppp *ap = sp_get(tty); ppp_sync_wakeup()
359 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); ppp_sync_wakeup()
563 * Send a packet to the peer over an sync tty line.
588 * Push as much data as possible out to the tty.
594 struct tty_struct *tty = ap->tty; ppp_sync_push() local
603 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); ppp_sync_push()
604 sent = tty->ops->write(tty, ap->tpkt->data, ap->tpkt->len); ppp_sync_push()
663 /* called when the tty driver has data for us.
H A Dppp_async.c24 #include <linux/tty.h>
46 struct tty_struct *tty; member in struct:asyncppp
123 * We have a potential race on dereferencing tty->disc_data,
124 * because the tty layer provides no locking at all - thus one
126 * calls ppp_asynctty_close, which zeroes tty->disc_data and
128 * way to fix this is to use a rwlock in the tty struct, but for now
136 static struct asyncppp *ap_get(struct tty_struct *tty) ap_get() argument
141 ap = tty->disc_data; ap_get()
155 * Called when a tty is put into PPP line discipline. Called in process
159 ppp_asynctty_open(struct tty_struct *tty) ppp_asynctty_open() argument
165 if (tty->ops->write == NULL) ppp_asynctty_open()
174 ap->tty = tty; ppp_asynctty_open()
194 speed = tty_get_baud_rate(tty); ppp_asynctty_open()
200 tty->disc_data = ap; ppp_asynctty_open()
201 tty->receive_room = 65536; ppp_asynctty_open()
211 * Called when the tty is put into another line discipline
219 ppp_asynctty_close(struct tty_struct *tty) ppp_asynctty_close() argument
224 ap = tty->disc_data; ppp_asynctty_close()
225 tty->disc_data = NULL; ppp_asynctty_close()
249 * Called on tty hangup in process context.
254 static int ppp_asynctty_hangup(struct tty_struct *tty) ppp_asynctty_hangup() argument
256 ppp_asynctty_close(tty); ppp_asynctty_hangup()
265 ppp_asynctty_read(struct tty_struct *tty, struct file *file, ppp_asynctty_read() argument
272 * Write on the tty does nothing, the packets all come in
276 ppp_asynctty_write(struct tty_struct *tty, struct file *file, ppp_asynctty_write() argument
288 ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file, ppp_asynctty_ioctl() argument
291 struct asyncppp *ap = ap_get(tty); ppp_asynctty_ioctl()
317 err = n_tty_ioctl_helper(tty, file, cmd, arg); ppp_asynctty_ioctl()
329 err = tty_mode_ioctl(tty, file, cmd, arg); ppp_asynctty_ioctl()
338 ppp_asynctty_poll(struct tty_struct *tty, struct file *file, poll_table *wait) ppp_asynctty_poll() argument
345 ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf, ppp_asynctty_receive() argument
348 struct asyncppp *ap = ap_get(tty); ppp_asynctty_receive()
359 tty_unthrottle(tty); ppp_asynctty_receive()
363 ppp_asynctty_wakeup(struct tty_struct *tty) ppp_asynctty_wakeup() argument
365 struct asyncppp *ap = ap_get(tty); ppp_asynctty_wakeup()
367 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); ppp_asynctty_wakeup()
626 * Send a packet to the peer over an async tty line.
648 * Push as much data as possible out to the tty.
654 struct tty_struct *tty = ap->tty; ppp_async_push() local
658 * We can get called recursively here if the tty write ppp_async_push()
674 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); ppp_async_push()
675 sent = tty->ops->write(tty, ap->optr, avail); ppp_async_push()
831 /* Called when the tty driver has data for us. Runs parallel with the
916 } else if (I_IXON(ap->tty)) { ppp_async_input()
917 if (c == START_CHAR(ap->tty)) ppp_async_input()
918 start_tty(ap->tty); ppp_async_input()
919 else if (c == STOP_CHAR(ap->tty)) ppp_async_input()
920 stop_tty(ap->tty); ppp_async_input()
/linux-4.1.27/drivers/tty/hvc/
H A Dhvc_console.c36 #include <linux/tty.h>
54 * hypervisor before allowing the tty to complete a close operation.
93 * This value is used to assign a tty->index value to a hvc_struct based
131 * console interfaces but can still be used as a tty device. This has to be
282 /* make sure no no tty has been registered in this index */ hvc_instantiate()
311 static void hvc_unthrottle(struct tty_struct *tty) hvc_unthrottle() argument
316 static int hvc_install(struct tty_driver *driver, struct tty_struct *tty) hvc_install() argument
322 if (!(hp = hvc_get_by_index(tty->index))) hvc_install()
325 tty->driver_data = hp; hvc_install()
327 rc = tty_port_install(&hp->port, driver, tty); hvc_install()
337 static int hvc_open(struct tty_struct *tty, struct file * filp) hvc_open() argument
339 struct hvc_struct *hp = tty->driver_data; hvc_open()
352 tty_port_tty_set(&hp->port, tty); hvc_open()
358 * If the notifier fails we return an error. The tty layer hvc_open()
361 * tty fields and return the kref reference. hvc_open()
365 tty->driver_data = NULL; hvc_open()
370 if (C_BAUD(tty)) hvc_open()
380 static void hvc_close(struct tty_struct *tty, struct file * filp) hvc_close() argument
390 * hvc_open by the tty layer's release_dev() function and we can just hvc_close()
393 if (!tty->driver_data) hvc_close()
396 hp = tty->driver_data; hvc_close()
402 /* We are done with the tty pointer now. */ hvc_close()
405 if (C_HUPCL(tty)) hvc_close()
412 /* cancel pending tty resize work */ hvc_close()
420 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT); hvc_close()
429 static void hvc_cleanup(struct tty_struct *tty) hvc_cleanup() argument
431 struct hvc_struct *hp = tty->driver_data; hvc_cleanup()
436 static void hvc_hangup(struct tty_struct *tty) hvc_hangup() argument
438 struct hvc_struct *hp = tty->driver_data; hvc_hangup()
444 /* cancel pending tty resize work */ hvc_hangup()
496 static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count) hvc_write() argument
498 struct hvc_struct *hp = tty->driver_data; hvc_write()
502 /* This write was probably executed during a tty close. */ hvc_write()
538 * hvc_set_winsz() - Resize the hvc tty terminal window.
550 struct tty_struct *tty; hvc_set_winsz() local
555 tty = tty_port_tty_get(&hp->port); hvc_set_winsz()
556 if (!tty) hvc_set_winsz()
563 tty_do_resize(tty, &ws); hvc_set_winsz()
564 tty_kref_put(tty); hvc_set_winsz()
568 * This is actually a contract between the driver and the tty layer outlining
572 static int hvc_write_room(struct tty_struct *tty) hvc_write_room() argument
574 struct hvc_struct *hp = tty->driver_data; hvc_write_room()
582 static int hvc_chars_in_buffer(struct tty_struct *tty) hvc_chars_in_buffer() argument
584 struct hvc_struct *hp = tty->driver_data; hvc_chars_in_buffer()
608 struct tty_struct *tty; hvc_poll() local
628 /* No tty attached, just skip */ hvc_poll()
629 tty = tty_port_tty_get(&hp->port); hvc_poll()
630 if (tty == NULL) hvc_poll()
634 if (test_bit(TTY_THROTTLED, &tty->flags)) hvc_poll()
655 /* Hangup the tty when disconnected from host */ hvc_poll()
658 tty_hangup(tty); hvc_poll()
664 * Let the tty clear the flip buff to make room. hvc_poll()
697 tty_wakeup(tty); hvc_poll()
709 tty_kref_put(tty); hvc_poll()
721 * The function schedule the tty resize update.
782 static int hvc_tiocmget(struct tty_struct *tty) hvc_tiocmget() argument
784 struct hvc_struct *hp = tty->driver_data; hvc_tiocmget()
791 static int hvc_tiocmset(struct tty_struct *tty, hvc_tiocmset() argument
794 struct hvc_struct *hp = tty->driver_data; hvc_tiocmset()
809 struct tty_struct *tty = driver->ttys[0]; hvc_poll_get_char() local
810 struct hvc_struct *hp = tty->driver_data; hvc_poll_get_char()
824 struct tty_struct *tty = driver->ttys[0]; hvc_poll_put_char() local
825 struct hvc_struct *hp = tty->driver_data; hvc_poll_put_char()
919 struct tty_struct *tty; hvc_remove() local
921 tty = tty_port_tty_get(&hp->port); hvc_remove()
946 if (tty) { hvc_remove()
947 tty_vhangup(tty); hvc_remove()
948 tty_kref_put(tty); hvc_remove()
992 * Make sure tty is fully registered before allowing it to be hvc_init()
H A Dhvc_console.h30 #include <linux/tty.h>
36 * can't be used as a console device but is still a valid tty device.
41 * The Linux TTY code does not support dynamic addition of tty derived devices
42 * so we need to know how many tty devices we might need when space is allocated
43 * for the tty device. Since this driver supports hotplug of vty adapters we
79 /* Callbacks to handle tty ports */
87 /* register a vterm for hvc tty operation (module_init or hotplug add) */
90 /* remove a vterm from hvc tty operation (module_exit or hotplug remove) */
97 /* Resize hvc tty terminal window */
H A Dhvsi.c44 #include <linux/tty.h>
239 struct tty_struct *tty, struct hvsi_struct **to_handshake) hvsi_recv_control()
249 if (tty && !C_CLOCAL(tty)) hvsi_recv_control()
250 tty_hangup(tty); hvsi_recv_control()
353 * We could get 252 bytes of data at once here. But the tty layer only
356 * buffer, which will give the tty buffer a chance to throttle us. Should the
395 * Used both to get packets for tty connections and to advance the state
396 * machine during console handshaking (in which case tty = NULL and we ignore
399 static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct *tty, hvsi_load_chunk() argument
442 hvsi_recv_control(hp, packet, tty, handshake); hvsi_load_chunk()
490 struct tty_struct *tty; hvsi_interrupt() local
496 tty = tty_port_tty_get(&hp->port); hvsi_interrupt()
500 again = hvsi_load_chunk(hp, tty, &handshake); hvsi_interrupt()
510 if (tty && hp->n_throttle && !test_bit(TTY_THROTTLED, &tty->flags)) { hvsi_interrupt()
518 tty_kref_put(tty); hvsi_interrupt()
710 static int hvsi_open(struct tty_struct *tty, struct file *filp) hvsi_open() argument
718 hp = &hvsi_ports[tty->index]; hvsi_open()
720 tty->driver_data = hp; hvsi_open()
726 tty_port_tty_set(&hp->port, tty); hvsi_open()
738 printk(KERN_ERR "%s: HVSI handshaking failed\n", tty->name); hvsi_open()
744 printk(KERN_ERR "%s: couldn't get initial modem flags\n", tty->name); hvsi_open()
750 printk(KERN_ERR "%s: couldn't set DTR\n", tty->name); hvsi_open()
773 static void hvsi_close(struct tty_struct *tty, struct file *filp) hvsi_close() argument
775 struct hvsi_struct *hp = tty->driver_data; hvsi_close()
794 * any data delivered to the tty layer after this will be hvsi_close()
797 tty->closing = 1; hvsi_close()
825 static void hvsi_hangup(struct tty_struct *tty) hvsi_hangup() argument
827 struct hvsi_struct *hp = tty->driver_data; hvsi_hangup()
904 static int hvsi_write_room(struct tty_struct *tty) hvsi_write_room() argument
906 struct hvsi_struct *hp = tty->driver_data; hvsi_write_room()
911 static int hvsi_chars_in_buffer(struct tty_struct *tty) hvsi_chars_in_buffer() argument
913 struct hvsi_struct *hp = tty->driver_data; hvsi_chars_in_buffer()
918 static int hvsi_write(struct tty_struct *tty, hvsi_write() argument
921 struct hvsi_struct *hp = tty->driver_data; hvsi_write()
942 while ((count > 0) && (hvsi_write_room(tty) > 0)) { hvsi_write()
943 int chunksize = min(count, hvsi_write_room(tty)); hvsi_write()
977 static void hvsi_throttle(struct tty_struct *tty) hvsi_throttle() argument
979 struct hvsi_struct *hp = tty->driver_data; hvsi_throttle()
986 static void hvsi_unthrottle(struct tty_struct *tty) hvsi_unthrottle() argument
988 struct hvsi_struct *hp = tty->driver_data; hvsi_unthrottle()
1004 static int hvsi_tiocmget(struct tty_struct *tty) hvsi_tiocmget() argument
1006 struct hvsi_struct *hp = tty->driver_data; hvsi_tiocmget()
1012 static int hvsi_tiocmset(struct tty_struct *tty, hvsi_tiocmset() argument
1015 struct hvsi_struct *hp = tty->driver_data; hvsi_tiocmset()
1092 /***** console (not tty) code: *****/
238 hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet, struct tty_struct *tty, struct hvsi_struct **to_handshake) hvsi_recv_control() argument
H A Dhvcs.c23 * "hvcs". The IBM hvcs provides a tty driver interface to allow Linux
44 * partition; attempts to open the tty device to the partition's console using
80 #include <linux/tty.h>
108 * align with how the tty layer always assigns the lowest index available. This
137 * hypervisor before allowing the tty to complete a close operation.
143 * addition of tty derived devices and we shouldn't allocate thousands of
222 * index element with the numerically equal tty->index. This means that a
269 * specific tty index.
291 * Any variable below is valid before a tty is connected and
292 * stays valid after the tty is disconnected. These shouldn't be
308 static void hvcs_unthrottle(struct tty_struct *tty);
309 static void hvcs_throttle(struct tty_struct *tty);
312 static int hvcs_write(struct tty_struct *tty,
314 static int hvcs_write_room(struct tty_struct *tty);
315 static int hvcs_chars_in_buffer(struct tty_struct *tty);
329 static int hvcs_open(struct tty_struct *tty, struct file *filp);
330 static void hvcs_close(struct tty_struct *tty, struct file *filp);
331 static void hvcs_hangup(struct tty_struct * tty);
518 static void hvcs_unthrottle(struct tty_struct *tty) hvcs_unthrottle() argument
520 struct hvcs_struct *hvcsd = tty->driver_data; hvcs_unthrottle()
529 static void hvcs_throttle(struct tty_struct *tty) hvcs_throttle() argument
531 struct hvcs_struct *hvcsd = tty->driver_data; hvcs_throttle()
561 struct tty_struct *tty = hvcsd->port.tty; hvcs_try_write() local
577 * hypervisor even if the tty has been closed because hvcs_try_write()
579 * a non-existent tty. hvcs_try_write()
581 if (tty) { hvcs_try_write()
582 tty_wakeup(tty); hvcs_try_write()
591 struct tty_struct *tty; hvcs_io() local
599 tty = hvcsd->port.tty; hvcs_io()
603 if (!tty || test_bit(TTY_THROTTLED, &tty->flags)) { hvcs_io()
624 /* This is synch because tty->low_latency == 1 */ hvcs_io()
814 * If a user app opens a tty that corresponds to this vty-server before hvcs_probe()
842 struct tty_struct *tty; hvcs_remove() local
851 tty = hvcsd->port.tty; hvcs_remove()
863 * hvcs_hangup. The tty should always be valid at this time unless a hvcs_remove()
864 * simultaneous tty close already cleaned up the hvcs_struct. hvcs_remove()
866 if (tty) hvcs_remove()
867 tty_hangup(tty); hvcs_remove()
1100 static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty) hvcs_install() argument
1112 hvcsd = hvcs_get_by_index(tty->index); hvcs_install()
1115 " with tty->index %d.\n", tty->index); hvcs_install()
1131 hvcsd->port.tty = tty; hvcs_install()
1132 tty->driver_data = hvcsd; hvcs_install()
1157 retval = tty_port_install(&hvcsd->port, driver, tty); hvcs_install()
1177 static int hvcs_open(struct tty_struct *tty, struct file *filp) hvcs_open() argument
1179 struct hvcs_struct *hvcsd = tty->driver_data; hvcs_open()
1195 static void hvcs_close(struct tty_struct *tty, struct file *filp) hvcs_close() argument
1203 * we have hung up? If so tty->driver_data wouldn't be valid. hvcs_close()
1210 * failed hvcs_open by the tty layer's release_dev() api and we can just hvcs_close()
1213 if (!tty->driver_data) hvcs_close()
1216 hvcsd = tty->driver_data; hvcs_close()
1228 hvcsd->port.tty = NULL; hvcs_close()
1233 tty_wait_until_sent_from_close(tty, HVCS_CLOSE_WAIT); hvcs_close()
1240 tty->driver_data = NULL; hvcs_close()
1253 static void hvcs_cleanup(struct tty_struct * tty) hvcs_cleanup() argument
1255 struct hvcs_struct *hvcsd = tty->driver_data; hvcs_cleanup()
1260 static void hvcs_hangup(struct tty_struct * tty) hvcs_hangup() argument
1262 struct hvcs_struct *hvcsd = tty->driver_data; hvcs_hangup()
1280 /* I don't think the tty needs the hvcs_struct pointer after a hangup */ hvcs_hangup()
1281 tty->driver_data = NULL; hvcs_hangup()
1282 hvcsd->port.tty = NULL; hvcs_hangup()
1320 static int hvcs_write(struct tty_struct *tty, hvcs_write() argument
1323 struct hvcs_struct *hvcsd = tty->driver_data; hvcs_write()
1425 static int hvcs_write_room(struct tty_struct *tty) hvcs_write_room() argument
1427 struct hvcs_struct *hvcsd = tty->driver_data; hvcs_write_room()
1435 static int hvcs_chars_in_buffer(struct tty_struct *tty) hvcs_chars_in_buffer() argument
1437 struct hvcs_struct *hvcsd = tty->driver_data; hvcs_chars_in_buffer()
1530 printk(KERN_ERR "HVCS: registration as a tty driver failed.\n"); hvcs_initialize()
H A Dhvc_iucv.c23 #include <linux/tty.h>
100 /* Array of allocated hvc iucv tty lines... */
230 * HVC layer to hang up the tty device. */ hvc_iucv_write()
238 /* receive an iucv message and flip data to the tty (ldisc) */ hvc_iucv_write()
353 * (that can be passed to HVC layer to cause a tty hangup).
484 * The function sets the tty state to TTY_OPENED for the struct hvc_iucv_private
520 * tty_outqueue_empty() - Test if the tty outq is empty
558 * hvc_iucv_hangup() - Sever IUCV path and schedule hvc tty hang up
570 * IUCV_SEVERED state causes the tty hang-up in the HVC layer.
572 * If the tty has not yet been opened, clean up the hvc_iucv_private
574 * If the tty has been opened, let get_chars() return -EPIPE to signal
575 * the HVC layer to hang up the tty and, if so, wake up the HVC thread
580 * 2. do_tty_hangup() calls tty->ops->close() for console_filp
584 * Finally, the back-end is not being notified, thus, the tty session is
624 * This routine notifies the HVC back-end that a tty hangup (carrier loss,
629 * disable writing to the tty by other applications).
630 * If the tty has been opened and an established IUCV path has been severed
631 * (we caused the tty hangup), the function calls hvc_iucv_cleanup().
649 * If the tty was hung up otherwise (e.g. vhangup()), then we hvc_iucv_notifier_hangup()
709 * This routine notifies the HVC back-end that the last tty device fd has been
710 * closed. The function cleans up tty resources. The clean-up of the IUCV
898 * If the tty has not yet been opened, the message is rejected.
916 /* reject messages if tty has not yet been opened */ hvc_iucv_msg_pending()
922 /* allocate tty buffer to save iucv msg only */ hvc_iucv_msg_pending()
H A Dhvsi_lib.c377 /* Keep track of the tty data structure */ hvsilib_open()
378 pv->tty = tty_port_tty_get(&hp->port); hvsilib_open()
401 if (!pv->tty || (pv->tty->termios.c_cflag & HUPCL)) hvsilib_close()
408 tty_kref_put(pv->tty); hvsilib_close()
409 pv->tty = NULL; hvsilib_close()
/linux-4.1.27/drivers/net/slip/
H A Dslip.c30 * Dmitry Gorodchanin : Code cleanup. Reduce tty driver
58 * Vitaly E. Lavrov : Sane behaviour on tty hangup.
59 * Alexey Kuznetsov : Cleanup interfaces to tty & netdevice
74 #include <linux/tty.h>
171 if (sl->tty == NULL) { sl_alloc_bufs()
260 if (sl->tty == NULL)
407 set_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); sl_encaps()
408 actual = sl->tty->ops->write(sl->tty, sl->xbuff, count); sl_encaps()
420 /* Write out any remaining transmit buffer. Scheduled when tty is writable */ slip_transmit()
428 if (!sl->tty || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) { slip_transmit()
437 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); slip_transmit()
443 actual = sl->tty->ops->write(sl->tty, sl->xhead, sl->xleft); slip_transmit()
453 static void slip_write_wakeup(struct tty_struct *tty) slip_write_wakeup() argument
455 struct slip *sl = tty->disc_data; slip_write_wakeup()
480 (tty_chars_in_buffer(sl->tty) || sl->xleft) ? sl_tx_timeout()
483 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); sl_tx_timeout()
505 if (sl->tty == NULL) { sl_xmit()
533 if (sl->tty) sl_close()
535 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); sl_close()
550 if (sl->tty == NULL) sl_open()
684 static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp, slip_receive_buf() argument
687 struct slip *sl = tty->disc_data; slip_receive_buf()
726 if (sl->tty || sl->leased) sl_sync()
734 /* Find a free SLIP channel, and link in this `tty' line. */ sl_alloc()
782 * sure the tty line exists, we only have to link it to
788 static int slip_open(struct tty_struct *tty) slip_open() argument
796 if (tty->ops->write == NULL) slip_open()
808 sl = tty->disc_data; slip_open()
817 sl = sl_alloc(tty_devnum(tty)); slip_open()
821 sl->tty = tty; slip_open()
822 tty->disc_data = sl; slip_open()
851 tty->receive_room = 65536; /* We don't flow control */ slip_open()
860 sl->tty = NULL; slip_open()
861 tty->disc_data = NULL; slip_open()
879 static void slip_close(struct tty_struct *tty) slip_close() argument
881 struct slip *sl = tty->disc_data; slip_close()
884 if (!sl || sl->magic != SLIP_MAGIC || sl->tty != tty) slip_close()
888 tty->disc_data = NULL; slip_close()
889 sl->tty = NULL; slip_close()
904 static int slip_hangup(struct tty_struct *tty) slip_hangup() argument
906 slip_close(tty); slip_hangup()
1070 static int slip_ioctl(struct tty_struct *tty, struct file *file, slip_ioctl() argument
1073 struct slip *sl = tty->disc_data; slip_ioctl()
1125 if (!sl->tty) { slip_ioctl()
1150 if (!sl->tty) { slip_ioctl()
1171 return tty_mode_ioctl(tty, file, cmd, arg); slip_ioctl()
1176 static long slip_compat_ioctl(struct tty_struct *tty, struct file *file, slip_compat_ioctl() argument
1188 return slip_ioctl(tty, file, cmd, slip_compat_ioctl()
1212 if (!sl->tty) { sl_ioctl()
1261 if (sl->tty != current->signal->tty && sl_ioctl()
1353 if (sl->tty) { slip_exit()
1355 tty_hangup(sl->tty); slip_exit()
1371 if (sl->tty) { slip_exit()
1372 printk(KERN_ERR "%s: tty discipline still running\n", slip_exit()
1404 if (sl->tty == NULL) sl_outfill()
1415 /* put END into tty queue. Is it right ??? */ sl_outfill()
1418 sl->tty->ops->write(sl->tty, &s, 1); sl_outfill()
1435 if (sl->tty == NULL) sl_keepalive()
1445 /* this must hangup tty & close slip */ sl_keepalive()
1446 tty_hangup(sl->tty); sl_keepalive()
/linux-4.1.27/drivers/isdn/capi/
H A Dcapi.c25 #include <linux/tty.h>
303 struct tty_struct *tty; capincci_free_minor() local
306 tty = tty_port_tty_get(&mp->port); capincci_free_minor()
307 if (tty) { capincci_free_minor()
308 tty_vhangup(tty); capincci_free_minor()
309 tty_kref_put(tty); capincci_free_minor()
320 struct tty_struct *tty; capincci_minor_opencount() local
323 tty = tty_port_tty_get(&mp->port); capincci_minor_opencount()
324 if (tty) { capincci_minor_opencount()
325 count = tty->count; capincci_minor_opencount()
326 tty_kref_put(tty); capincci_minor_opencount()
404 struct tty_struct *tty; handle_recv_skb() local
410 tty = tty_port_tty_get(&mp->port); handle_recv_skb()
411 if (!tty) { handle_recv_skb()
416 ld = tty_ldisc_ref(tty); handle_recv_skb()
430 pr_debug("capi: recv tty throttled\n"); handle_recv_skb()
434 if (tty->receive_room < datalen) { handle_recv_skb()
435 pr_debug("capi: no room in tty\n"); handle_recv_skb()
453 ld->ops->receive_buf(tty, skb->data, NULL, skb->len); handle_recv_skb()
471 tty_kref_put(tty); handle_recv_skb()
488 struct tty_struct *tty; handle_minor_send() local
494 tty = tty_port_tty_get(&mp->port); handle_minor_send()
495 if (!tty) handle_minor_send()
499 pr_debug("capi: send: tty stopped\n"); handle_minor_send()
500 tty_kref_put(tty); handle_minor_send()
562 tty_kref_put(tty); handle_minor_send()
998 capinc_tty_install(struct tty_driver *driver, struct tty_struct *tty) capinc_tty_install() argument
1000 struct capiminor *mp = capiminor_get(tty->index); capinc_tty_install()
1001 int ret = tty_standard_install(driver, tty); capinc_tty_install()
1004 tty->driver_data = mp; capinc_tty_install()
1010 static void capinc_tty_cleanup(struct tty_struct *tty) capinc_tty_cleanup() argument
1012 struct capiminor *mp = tty->driver_data; capinc_tty_cleanup()
1013 tty->driver_data = NULL; capinc_tty_cleanup()
1017 static int capinc_tty_open(struct tty_struct *tty, struct file *filp) capinc_tty_open() argument
1019 struct capiminor *mp = tty->driver_data; capinc_tty_open()
1022 err = tty_port_open(&mp->port, tty, filp); capinc_tty_open()
1030 static void capinc_tty_close(struct tty_struct *tty, struct file *filp) capinc_tty_close() argument
1032 struct capiminor *mp = tty->driver_data; capinc_tty_close()
1034 tty_port_close(&mp->port, tty, filp); capinc_tty_close()
1037 static int capinc_tty_write(struct tty_struct *tty, capinc_tty_write() argument
1040 struct capiminor *mp = tty->driver_data; capinc_tty_write()
1072 static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch) capinc_tty_put_char() argument
1074 struct capiminor *mp = tty->driver_data; capinc_tty_put_char()
1113 static void capinc_tty_flush_chars(struct tty_struct *tty) capinc_tty_flush_chars() argument
1115 struct capiminor *mp = tty->driver_data; capinc_tty_flush_chars()
1135 static int capinc_tty_write_room(struct tty_struct *tty) capinc_tty_write_room() argument
1137 struct capiminor *mp = tty->driver_data; capinc_tty_write_room()
1146 static int capinc_tty_chars_in_buffer(struct tty_struct *tty) capinc_tty_chars_in_buffer() argument
1148 struct capiminor *mp = tty->driver_data; capinc_tty_chars_in_buffer()
1157 static int capinc_tty_ioctl(struct tty_struct *tty, capinc_tty_ioctl() argument
1163 static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios *old) capinc_tty_set_termios() argument
1168 static void capinc_tty_throttle(struct tty_struct *tty) capinc_tty_throttle() argument
1170 struct capiminor *mp = tty->driver_data; capinc_tty_throttle()
1175 static void capinc_tty_unthrottle(struct tty_struct *tty) capinc_tty_unthrottle() argument
1177 struct capiminor *mp = tty->driver_data; capinc_tty_unthrottle()
1184 static void capinc_tty_stop(struct tty_struct *tty) capinc_tty_stop() argument
1186 struct capiminor *mp = tty->driver_data; capinc_tty_stop()
1192 static void capinc_tty_start(struct tty_struct *tty) capinc_tty_start() argument
1194 struct capiminor *mp = tty->driver_data; capinc_tty_start()
1201 static void capinc_tty_hangup(struct tty_struct *tty) capinc_tty_hangup() argument
1203 struct capiminor *mp = tty->driver_data; capinc_tty_hangup()
1209 static int capinc_tty_break_ctl(struct tty_struct *tty, int state) capinc_tty_break_ctl() argument
1215 static void capinc_tty_flush_buffer(struct tty_struct *tty) capinc_tty_flush_buffer() argument
1220 static void capinc_tty_set_ldisc(struct tty_struct *tty) capinc_tty_set_ldisc() argument
1225 static void capinc_tty_send_xchar(struct tty_struct *tty, char ch) capinc_tty_send_xchar() argument
/linux-4.1.27/arch/xtensa/platforms/iss/
H A Dconsole.c28 #include <linux/tty.h>
51 * initialization for the tty structure.
56 static int rs_open(struct tty_struct *tty, struct file * filp) rs_open() argument
58 tty->port = &serial_port; rs_open()
60 if (tty->count == 1) { rs_open()
81 static void rs_close(struct tty_struct *tty, struct file * filp) rs_close() argument
84 if (tty->count == 1) rs_close()
90 static int rs_write(struct tty_struct * tty, rs_write() argument
124 static int rs_put_char(struct tty_struct *tty, unsigned char ch) rs_put_char() argument
126 return rs_write(tty, &ch, 1); rs_put_char()
129 static void rs_flush_chars(struct tty_struct *tty) rs_flush_chars() argument
133 static int rs_write_room(struct tty_struct *tty) rs_write_room() argument
139 static int rs_chars_in_buffer(struct tty_struct *tty) rs_chars_in_buffer() argument
145 static void rs_hangup(struct tty_struct *tty) rs_hangup() argument
150 static void rs_wait_until_sent(struct tty_struct *tty, int timeout) rs_wait_until_sent() argument
234 * other tty drivers that depend on tty_init and which must use
/linux-4.1.27/drivers/net/hamradio/
H A D6pack.c22 #include <linux/tty.h>
87 struct tty_struct *tty; /* ptr to TTY structure */ member in struct:sixpack
149 sp->tty->ops->write(sp->tty, &sp->led_state, 1); sp_xmit_on_air()
151 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); sp_xmit_on_air()
155 sp->tty->ops->write(sp->tty, &sp->led_state, 1); sp_xmit_on_air()
195 set_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags); sp_encaps()
221 sp->tty->ops->write(sp->tty, &sp->led_state, 1); sp_encaps()
223 actual = sp->tty->ops->write(sp->tty, sp->xbuff, count); sp_encaps()
227 sp->tty->ops->write(sp->tty, &sp->led_state, 1); sp_encaps()
269 if (sp->tty == NULL) sp_open_dev()
280 if (sp->tty) { sp_close()
282 clear_bit(TTY_DO_WRITE_WAKEUP, &sp->tty->flags); sp_close()
368 * We have a potential race on dereferencing tty->disc_data, because the tty
371 * tty->disc_data and frees the memory that sixpack_receive_buf is using. The
372 * best way to fix this is to use a rwlock in the tty struct, but for now we
377 static struct sixpack *sp_get(struct tty_struct *tty) sp_get() argument
382 sp = tty->disc_data; sp_get()
400 static void sixpack_write_wakeup(struct tty_struct *tty) sixpack_write_wakeup() argument
402 struct sixpack *sp = sp_get(tty); sixpack_write_wakeup()
411 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); sixpack_write_wakeup()
418 actual = tty->ops->write(tty, sp->xhead, sp->xleft); sixpack_write_wakeup()
435 static void sixpack_receive_buf(struct tty_struct *tty, sixpack_receive_buf() argument
445 sp = sp_get(tty); sixpack_receive_buf()
465 tty_unthrottle(tty); sixpack_receive_buf()
526 sp->tty->ops->write(sp->tty, &sp->led_state, 1); resync_tnc()
527 sp->tty->ops->write(sp->tty, &resync_cmd, 1); resync_tnc()
545 sp->tty->ops->write(sp->tty, &inbyte, 1); tnc_init()
560 * sure the tty line exists, we only have to link it to
563 static int sixpack_open(struct tty_struct *tty) sixpack_open() argument
573 if (tty->ops->write == NULL) sixpack_open()
604 sp->tty = tty; sixpack_open()
639 tty->disc_data = sp; sixpack_open()
640 tty->receive_room = 65536; sixpack_open()
668 static void sixpack_close(struct tty_struct *tty) sixpack_close() argument
673 sp = tty->disc_data; sixpack_close()
674 tty->disc_data = NULL; sixpack_close()
697 static int sixpack_ioctl(struct tty_struct *tty, struct file *file, sixpack_ioctl() argument
700 struct sixpack *sp = sp_get(tty); sixpack_ioctl()
751 err = tty_mode_ioctl(tty, file, cmd, arg); sixpack_ioctl()
760 static long sixpack_compat_ioctl(struct tty_struct * tty, struct file * file, sixpack_compat_ioctl() argument
768 return sixpack_ioctl(tty, file, cmd, sixpack_compat_ioctl()
910 sp->tty->ops->write(sp->tty, &sp->led_state, 1); decode_prio_command()
912 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2); decode_prio_command()
922 sp->tty->ops->write(sp->tty, &sp->led_state, 1); decode_prio_command()
952 sp->tty->ops->write(sp->tty, &sp->led_state, 1); decode_std_command()
957 sp->tty->ops->write(sp->tty, &sp->led_state, 1); decode_std_command()
H A Dmkiss.c28 #include <linux/tty.h>
51 struct tty_struct *tty; /* ptr to TTY structure */ member in struct:mkiss
517 set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); ax_encaps()
518 actual = ax->tty->ops->write(ax->tty, ax->xbuff, count); ax_encaps()
551 (tty_chars_in_buffer(ax->tty) || ax->xleft) ? ax_xmit()
555 clear_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); ax_xmit()
571 if (ax->tty == NULL) ax_open_dev()
583 if (ax->tty == NULL) ax_open()
632 if (ax->tty) ax_close()
633 clear_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); ax_close()
666 * We have a potential race on dereferencing tty->disc_data, because the tty
669 * tty->disc_data and frees the memory that sixpack_receive_buf is using. The
670 * best way to fix this is to use a rwlock in the tty struct, but for now we
675 static struct mkiss *mkiss_get(struct tty_struct *tty) mkiss_get() argument
680 ax = tty->disc_data; mkiss_get()
696 static int mkiss_open(struct tty_struct *tty) mkiss_open() argument
704 if (tty->ops->write == NULL) mkiss_open()
721 ax->tty = tty; mkiss_open()
722 tty->disc_data = ax; mkiss_open()
723 tty->receive_room = 65535; mkiss_open()
725 tty_driver_flush_buffer(tty); mkiss_open()
781 static void mkiss_close(struct tty_struct *tty) mkiss_close() argument
786 ax = tty->disc_data; mkiss_close()
787 tty->disc_data = NULL; mkiss_close()
806 ax->tty = NULL; mkiss_close()
810 static int mkiss_ioctl(struct tty_struct *tty, struct file *file, mkiss_ioctl() argument
813 struct mkiss *ax = mkiss_get(tty); mkiss_ioctl()
873 static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file, mkiss_compat_ioctl() argument
881 return mkiss_ioctl(tty, file, cmd, mkiss_compat_ioctl()
895 static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp, mkiss_receive_buf() argument
898 struct mkiss *ax = mkiss_get(tty); mkiss_receive_buf()
923 tty_unthrottle(tty); mkiss_receive_buf()
930 static void mkiss_write_wakeup(struct tty_struct *tty) mkiss_write_wakeup() argument
932 struct mkiss *ax = mkiss_get(tty); mkiss_write_wakeup()
942 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); mkiss_write_wakeup()
948 actual = tty->ops->write(tty, ax->xhead, ax->xleft); mkiss_write_wakeup()
/linux-4.1.27/arch/m68k/emu/
H A Dnfcon.c12 #include <linux/tty.h>
64 static int nfcon_tty_open(struct tty_struct *tty, struct file *filp) nfcon_tty_open() argument
69 static void nfcon_tty_close(struct tty_struct *tty, struct file *filp) nfcon_tty_close() argument
73 static int nfcon_tty_write(struct tty_struct *tty, const unsigned char *buf, nfcon_tty_write() argument
80 static int nfcon_tty_put_char(struct tty_struct *tty, unsigned char ch) nfcon_tty_put_char() argument
88 static int nfcon_tty_write_room(struct tty_struct *tty) nfcon_tty_write_room() argument
146 pr_err("failed to register nfcon tty driver\n"); nfcon_init()
/linux-4.1.27/drivers/net/wan/
H A Dx25_asy.c27 #include <linux/tty.h>
51 /* Find a free X.25 channel, and link in this `tty' line. */ x25_asy_alloc()
247 set_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); x25_asy_encaps()
248 actual = sl->tty->ops->write(sl->tty, sl->xbuff, count); x25_asy_encaps()
259 static void x25_asy_write_wakeup(struct tty_struct *tty) x25_asy_write_wakeup() argument
262 struct x25_asy *sl = tty->disc_data; x25_asy_write_wakeup()
272 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); x25_asy_write_wakeup()
277 actual = tty->ops->write(tty, sl->xhead, sl->xleft); x25_asy_write_wakeup()
292 (tty_chars_in_buffer(sl->tty) || sl->xleft) ? x25_asy_timeout()
295 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); x25_asy_timeout()
381 if (netif_queue_stopped(sl->dev) || sl->tty == NULL) { x25_asy_data_transmit()
456 if (sl->tty == NULL) x25_asy_open()
504 if (sl->tty) x25_asy_close()
505 clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); x25_asy_close()
521 static void x25_asy_receive_buf(struct tty_struct *tty, x25_asy_receive_buf() argument
524 struct x25_asy *sl = tty->disc_data; x25_asy_receive_buf()
546 * sure the tty line exists, we only have to link it to
550 static int x25_asy_open_tty(struct tty_struct *tty) x25_asy_open_tty() argument
552 struct x25_asy *sl = tty->disc_data; x25_asy_open_tty()
555 if (tty->ops->write == NULL) x25_asy_open_tty()
567 sl->tty = tty; x25_asy_open_tty()
568 tty->disc_data = sl; x25_asy_open_tty()
569 tty->receive_room = 65536; x25_asy_open_tty()
570 tty_driver_flush_buffer(tty); x25_asy_open_tty()
571 tty_ldisc_flush(tty); x25_asy_open_tty()
591 static void x25_asy_close_tty(struct tty_struct *tty) x25_asy_close_tty() argument
593 struct x25_asy *sl = tty->disc_data; x25_asy_close_tty()
610 tty->disc_data = NULL; x25_asy_close_tty()
611 sl->tty = NULL; x25_asy_close_tty()
688 static int x25_asy_ioctl(struct tty_struct *tty, struct file *file, x25_asy_ioctl() argument
691 struct x25_asy *sl = tty->disc_data; x25_asy_ioctl()
706 return tty_mode_ioctl(tty, file, cmd, arg); x25_asy_ioctl()
711 static long x25_asy_compat_ioctl(struct tty_struct *tty, struct file *file, x25_asy_compat_ioctl() argument
717 return x25_asy_ioctl(tty, file, cmd, x25_asy_compat_ioctl()
728 if (sl->tty == NULL) x25_asy_open_dev()
809 if (sl->tty) exit_x25_asy()
810 tty_hangup(sl->tty); exit_x25_asy()
H A Dx25_asy.h22 struct tty_struct *tty; /* ptr to TTY structure */ member in struct:x25_asy
/linux-4.1.27/drivers/usb/gadget/function/
H A Du_serial.c25 #include <linux/tty.h>
61 * gs_port is the I/O nexus, used by the tty driver
62 * tty_struct links to the tty/filesystem framework
417 if (do_tty_wake && port->port.tty) gs_start_tx()
418 tty_wakeup(port->port.tty); gs_start_tx()
437 struct tty_struct *tty; gs_start_rx() local
440 tty = port->port.tty; gs_start_rx()
441 if (!tty) gs_start_rx()
486 struct tty_struct *tty; gs_rx_push() local
491 /* hand any queued data to the tty */ gs_rx_push()
493 tty = port->port.tty; gs_rx_push()
499 /* leave data queued if tty was rx throttled */ gs_rx_push()
500 if (tty && test_bit(TTY_THROTTLED, &tty->flags)) gs_rx_push()
519 /* push data to (open) tty */ gs_rx_push()
551 /* Push from tty to ldisc; this is handled by a workqueue, gs_rx_push()
559 * in the tty and ldisc (not here). If we couldn't push any gs_rx_push()
566 if (!list_empty(queue) && tty) { gs_rx_push()
567 if (!test_bit(TTY_THROTTLED, &tty->flags)) { gs_rx_push()
587 /* Queue all received data until the tty layer is ready for it. */ gs_read_complete()
700 tty_wakeup(port->port.tty); gs_start_io()
720 static int gs_open(struct tty_struct *tty, struct file *file) gs_open() argument
722 int port_num = tty->index; gs_open()
781 port->port_num, tty, file); gs_open()
793 tty->driver_data = port; gs_open()
794 port->port.tty = tty; gs_open()
810 pr_debug("gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file); gs_open()
831 static void gs_close(struct tty_struct *tty, struct file *file) gs_close() argument
833 struct gs_port *port = tty->driver_data; gs_close()
846 pr_debug("gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file); gs_close()
879 tty->driver_data = NULL; gs_close()
880 port->port.tty = NULL; gs_close()
885 port->port_num, tty, file); gs_close()
892 static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count) gs_write() argument
894 struct gs_port *port = tty->driver_data; gs_write()
899 port->port_num, tty, count); gs_write()
912 static int gs_put_char(struct tty_struct *tty, unsigned char ch) gs_put_char() argument
914 struct gs_port *port = tty->driver_data; gs_put_char()
919 port->port_num, tty, ch, __builtin_return_address(0)); gs_put_char()
928 static void gs_flush_chars(struct tty_struct *tty) gs_flush_chars() argument
930 struct gs_port *port = tty->driver_data; gs_flush_chars()
933 pr_vdebug("gs_flush_chars: (%d,%p)\n", port->port_num, tty); gs_flush_chars()
941 static int gs_write_room(struct tty_struct *tty) gs_write_room() argument
943 struct gs_port *port = tty->driver_data; gs_write_room()
953 port->port_num, tty, room); gs_write_room()
958 static int gs_chars_in_buffer(struct tty_struct *tty) gs_chars_in_buffer() argument
960 struct gs_port *port = tty->driver_data; gs_chars_in_buffer()
969 port->port_num, tty, chars); gs_chars_in_buffer()
975 static void gs_unthrottle(struct tty_struct *tty) gs_unthrottle() argument
977 struct gs_port *port = tty->driver_data; gs_unthrottle()
992 static int gs_break_ctl(struct tty_struct *tty, int duration) gs_break_ctl() argument
994 struct gs_port *port = tty->driver_data; gs_break_ctl()
1130 pr_err("%s: failed to register tty for port %d, err %ld\n", gserial_alloc_line()
1196 /* then tell the tty glue that I/O can work */ gserial_connect()
1260 if (port->port.tty) gserial_disconnect()
1261 tty_hangup(port->port.tty); gserial_disconnect()
/linux-4.1.27/sound/soc/codecs/
H A Dcx20442.c16 #include <linux/tty.h>
217 static int v253_open(struct tty_struct *tty) v253_open() argument
222 if (!tty->ops->write) v253_open()
226 if (!tty->disc_data) v253_open()
229 if (tty->ops->write(tty, v253_init, len) != len) { v253_open()
236 tty->disc_data = NULL; v253_open()
241 static void v253_close(struct tty_struct *tty) v253_close() argument
243 struct snd_soc_codec *codec = tty->disc_data; v253_close()
246 tty->disc_data = NULL; v253_close()
260 static int v253_hangup(struct tty_struct *tty) v253_hangup() argument
262 v253_close(tty); v253_hangup()
267 static void v253_receive(struct tty_struct *tty, v253_receive() argument
270 struct snd_soc_codec *codec = tty->disc_data; v253_receive()
282 cx20442->control_data = tty; v253_receive()
283 codec->hw_write = (hw_write_t)tty->ops->write; v253_receive()
289 static void v253_wakeup(struct tty_struct *tty) v253_wakeup() argument
386 struct tty_struct *tty = cx20442->control_data; cx20442_codec_remove() local
387 tty_hangup(tty); cx20442_codec_remove()
/linux-4.1.27/drivers/char/pcmcia/
H A Dsynclink_cs.c45 #include <linux/tty.h>
366 static void tx_start(MGSLPC_INFO *info, struct tty_struct *tty);
402 static bool rx_get_frame(MGSLPC_INFO *info, struct tty_struct *tty);
413 static void bh_transmit(MGSLPC_INFO *info, struct tty_struct *tty);
419 static int tiocmget(struct tty_struct *tty);
420 static int tiocmset(struct tty_struct *tty,
424 static int set_params(MGSLPC_INFO *info, MGSL_PARAMS __user *new_params, struct tty_struct *tty);
427 static int set_txenable(MGSLPC_INFO *info, int enable, struct tty_struct *tty);
466 static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty);
467 static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout);
495 static void ldisc_receive_buf(struct tty_struct *tty, ldisc_receive_buf() argument
499 if (!tty) ldisc_receive_buf()
501 ld = tty_ldisc_ref(tty); ldisc_receive_buf()
504 ld->ops->receive_buf(tty, data, flags, count); ldisc_receive_buf()
704 static void tx_pause(struct tty_struct *tty) tx_pause() argument
706 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; tx_pause()
709 if (mgslpc_paranoia_check(info, tty->name, "tx_pause")) tx_pause()
720 static void tx_release(struct tty_struct *tty) tx_release() argument
722 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; tx_release()
725 if (mgslpc_paranoia_check(info, tty->name, "tx_release")) tx_release()
732 tx_start(info, tty); tx_release()
771 struct tty_struct *tty; bh_handler() local
779 tty = tty_port_tty_get(&info->port); bh_handler()
791 while(rx_get_frame(info, tty)); bh_handler()
794 bh_transmit(info, tty); bh_handler()
806 tty_kref_put(tty); bh_handler()
812 static void bh_transmit(MGSLPC_INFO *info, struct tty_struct *tty) bh_transmit() argument
817 if (tty) bh_transmit()
818 tty_wakeup(tty); bh_transmit()
933 /* discard char if tty control flags say so */ rx_ready_async()
961 static void tx_done(MGSLPC_INFO *info, struct tty_struct *tty) tx_done() argument
990 if (tty && (tty->stopped || tty->hw_stopped)) { tx_done()
998 static void tx_ready(MGSLPC_INFO *info, struct tty_struct *tty) tx_ready() argument
1010 if (tty && (tty->stopped || tty->hw_stopped)) { tx_ready()
1047 static void cts_change(MGSLPC_INFO *info, struct tty_struct *tty) cts_change() argument
1060 if (tty && tty_port_cts_enabled(&info->port)) { cts_change()
1061 if (tty->hw_stopped) { cts_change()
1065 tty->hw_stopped = 0; cts_change()
1066 tx_start(info, tty); cts_change()
1074 tty->hw_stopped = 1; cts_change()
1082 static void dcd_change(MGSLPC_INFO *info, struct tty_struct *tty) dcd_change() argument
1113 if (tty) dcd_change()
1114 tty_hangup(tty); dcd_change()
1160 struct tty_struct *tty; mgslpc_isr() local
1171 tty = tty_port_tty_get(&info->port); mgslpc_isr()
1188 dcd_change(info, tty); mgslpc_isr()
1190 cts_change(info, tty); mgslpc_isr()
1208 do_SAK(tty); mgslpc_isr()
1226 tx_done(info, tty); mgslpc_isr()
1230 tx_done(info, tty); mgslpc_isr()
1233 tx_ready(info, tty); mgslpc_isr()
1257 tty_kref_put(tty); mgslpc_isr()
1268 static int startup(MGSLPC_INFO * info, struct tty_struct *tty) startup() argument
1302 if (capable(CAP_SYS_ADMIN) && tty) startup()
1303 set_bit(TTY_IO_ERROR, &tty->flags); startup()
1309 mgslpc_change_params(info, tty); startup()
1311 if (tty) startup()
1312 clear_bit(TTY_IO_ERROR, &tty->flags); startup()
1321 static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) shutdown() argument
1352 if (!tty || tty->termios.c_cflag & HUPCL) { shutdown()
1361 if (tty) shutdown()
1362 set_bit(TTY_IO_ERROR, &tty->flags); shutdown()
1367 static void mgslpc_program_hw(MGSLPC_INFO *info, struct tty_struct *tty) mgslpc_program_hw() argument
1393 if (info->netcount || (tty && (tty->termios.c_cflag & CREAD))) mgslpc_program_hw()
1401 static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty) mgslpc_change_params() argument
1406 if (!tty) mgslpc_change_params()
1413 cflag = tty->termios.c_cflag; mgslpc_change_params()
1456 * allow tty settings to override, otherwise keep the mgslpc_change_params()
1460 info->params.data_rate = tty_get_baud_rate(tty); mgslpc_change_params()
1479 /* process tty input control flags */ mgslpc_change_params()
1482 if (I_INPCK(tty)) mgslpc_change_params()
1484 if (I_IGNPAR(tty)) mgslpc_change_params()
1487 mgslpc_program_hw(info, tty); mgslpc_change_params()
1492 static int mgslpc_put_char(struct tty_struct *tty, unsigned char ch) mgslpc_put_char() argument
1494 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_put_char()
1502 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char")) mgslpc_put_char()
1525 static void mgslpc_flush_chars(struct tty_struct *tty) mgslpc_flush_chars() argument
1527 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_flush_chars()
1534 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_chars")) mgslpc_flush_chars()
1537 if (info->tx_count <= 0 || tty->stopped || mgslpc_flush_chars()
1538 tty->hw_stopped || !info->tx_buf) mgslpc_flush_chars()
1547 tx_start(info, tty); mgslpc_flush_chars()
1555 * tty pointer to tty information structure
1561 static int mgslpc_write(struct tty_struct * tty, mgslpc_write() argument
1565 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_write()
1572 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") || mgslpc_write()
1606 if (info->tx_count && !tty->stopped && !tty->hw_stopped) { mgslpc_write()
1609 tx_start(info, tty); mgslpc_write()
1621 static int mgslpc_write_room(struct tty_struct *tty) mgslpc_write_room() argument
1623 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_write_room()
1626 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room")) mgslpc_write_room()
1649 static int mgslpc_chars_in_buffer(struct tty_struct *tty) mgslpc_chars_in_buffer() argument
1651 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_chars_in_buffer()
1658 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_chars_in_buffer")) mgslpc_chars_in_buffer()
1675 static void mgslpc_flush_buffer(struct tty_struct *tty) mgslpc_flush_buffer() argument
1677 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_flush_buffer()
1684 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_flush_buffer")) mgslpc_flush_buffer()
1692 wake_up_interruptible(&tty->write_wait); mgslpc_flush_buffer()
1693 tty_wakeup(tty); mgslpc_flush_buffer()
1698 static void mgslpc_send_xchar(struct tty_struct *tty, char ch) mgslpc_send_xchar() argument
1700 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_send_xchar()
1707 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_send_xchar")) mgslpc_send_xchar()
1714 tx_start(info, tty); mgslpc_send_xchar()
1721 static void mgslpc_throttle(struct tty_struct * tty) mgslpc_throttle() argument
1723 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_throttle()
1730 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_throttle")) mgslpc_throttle()
1733 if (I_IXOFF(tty)) mgslpc_throttle()
1734 mgslpc_send_xchar(tty, STOP_CHAR(tty)); mgslpc_throttle()
1736 if (tty->termios.c_cflag & CRTSCTS) { mgslpc_throttle()
1746 static void mgslpc_unthrottle(struct tty_struct * tty) mgslpc_unthrottle() argument
1748 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_unthrottle()
1755 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_unthrottle")) mgslpc_unthrottle()
1758 if (I_IXOFF(tty)) { mgslpc_unthrottle()
1762 mgslpc_send_xchar(tty, START_CHAR(tty)); mgslpc_unthrottle()
1765 if (tty->termios.c_cflag & CRTSCTS) { mgslpc_unthrottle()
1812 static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params, struct tty_struct *tty) set_params() argument
1833 mgslpc_change_params(info, tty); set_params()
1894 static int set_txenable(MGSLPC_INFO * info, int enable, struct tty_struct *tty) set_txenable() argument
1904 tx_start(info, tty); set_txenable()
2121 static int tiocmget(struct tty_struct *tty) tiocmget() argument
2123 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; tiocmget()
2146 static int tiocmset(struct tty_struct *tty, tiocmset() argument
2149 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; tiocmset()
2174 * Arguments: tty pointer to tty instance data
2177 static int mgslpc_break(struct tty_struct *tty, int break_state) mgslpc_break() argument
2179 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; mgslpc_break()
2186 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break")) mgslpc_break()
2198 static int mgslpc_get_icount(struct tty_struct *tty, mgslpc_get_icount() argument
2201 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; mgslpc_get_icount()
2228 * tty pointer to tty instance data
2234 static int mgslpc_ioctl(struct tty_struct *tty, mgslpc_ioctl() argument
2237 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; mgslpc_ioctl()
2244 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_ioctl")) mgslpc_ioctl()
2249 if (tty->flags & (1 << TTY_IO_ERROR)) mgslpc_ioctl()
2257 return set_params(info, argp, tty); mgslpc_ioctl()
2267 return set_txenable(info,(int)arg, tty); mgslpc_ioctl()
2288 * tty pointer to tty structure
2291 static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_termios) mgslpc_set_termios() argument
2293 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; mgslpc_set_termios()
2298 tty->driver->name); mgslpc_set_termios()
2301 if ((tty->termios.c_cflag == old_termios->c_cflag) mgslpc_set_termios()
2302 && (RELEVANT_IFLAG(tty->termios.c_iflag) mgslpc_set_termios()
2306 mgslpc_change_params(info, tty); mgslpc_set_termios()
2310 !(tty->termios.c_cflag & CBAUD)) { mgslpc_set_termios()
2319 tty->termios.c_cflag & CBAUD) { mgslpc_set_termios()
2321 if (!(tty->termios.c_cflag & CRTSCTS) || mgslpc_set_termios()
2322 !test_bit(TTY_THROTTLED, &tty->flags)) { mgslpc_set_termios()
2332 !(tty->termios.c_cflag & CRTSCTS)) { mgslpc_set_termios()
2333 tty->hw_stopped = 0; mgslpc_set_termios()
2334 tx_release(tty); mgslpc_set_termios()
2338 static void mgslpc_close(struct tty_struct *tty, struct file * filp) mgslpc_close() argument
2340 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; mgslpc_close()
2343 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close")) mgslpc_close()
2350 if (tty_port_close_start(port, tty, filp) == 0) mgslpc_close()
2354 mgslpc_wait_until_sent(tty, info->timeout); mgslpc_close()
2356 mgslpc_flush_buffer(tty); mgslpc_close()
2358 tty_ldisc_flush(tty); mgslpc_close()
2359 shutdown(info, tty); mgslpc_close()
2361 tty_port_close_end(port, tty); mgslpc_close()
2366 tty->driver->name, port->count); mgslpc_close()
2371 static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) mgslpc_wait_until_sent() argument
2373 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; mgslpc_wait_until_sent()
2383 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) mgslpc_wait_until_sent()
2435 static void mgslpc_hangup(struct tty_struct *tty) mgslpc_hangup() argument
2437 MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; mgslpc_hangup()
2443 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_hangup")) mgslpc_hangup()
2446 mgslpc_flush_buffer(tty); mgslpc_hangup()
2447 shutdown(info, tty); mgslpc_hangup()
2480 static int mgslpc_open(struct tty_struct *tty, struct file * filp) mgslpc_open() argument
2488 line = tty->index; mgslpc_open()
2499 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open")) mgslpc_open()
2503 tty->driver_data = info; mgslpc_open()
2504 tty_port_tty_set(port, tty); mgslpc_open()
2508 __FILE__, __LINE__, tty->driver->name, port->count); mgslpc_open()
2512 wait_event_interruptible_tty(tty, port->close_wait, mgslpc_open()
2534 retval = startup(info, tty); mgslpc_open()
2539 retval = tty_port_block_til_ready(&info->port, tty, filp); mgslpc_open()
2882 printk(KERN_INFO "%s %s, tty major#%d\n", driver_name, driver_version, synclink_cs_init()
3319 static void tx_start(MGSLPC_INFO *info, struct tty_struct *tty) tx_start() argument
3343 tx_ready(info, tty); tx_start()
3347 tx_ready(info, tty); tx_start()
3668 static bool rx_get_frame(MGSLPC_INFO *info, struct tty_struct *tty) rx_get_frame() argument
3737 ldisc_receive_buf(tty, buf->data, info->flag_buf, framesize); rx_get_frame()
3894 struct tty_struct *tty = tty_port_tty_get(&info->port); tx_timeout() local
3895 bh_transmit(info, tty); tx_timeout()
3896 tty_kref_put(tty); tx_timeout()
3916 struct tty_struct *tty; hdlcdev_attach() local
3947 tty = tty_port_tty_get(&info->port); hdlcdev_attach()
3948 mgslpc_program_hw(info, tty); hdlcdev_attach()
3949 tty_kref_put(tty); hdlcdev_attach()
3991 struct tty_struct *tty = tty_port_tty_get(&info->port); hdlcdev_xmit() local
3992 tx_start(info, tty); hdlcdev_xmit()
3993 tty_kref_put(tty); hdlcdev_xmit()
4011 struct tty_struct *tty; hdlcdev_open() local
4023 /* arbitrate between network and tty opens */ hdlcdev_open()
4033 tty = tty_port_tty_get(&info->port); hdlcdev_open()
4035 rc = startup(info, tty); hdlcdev_open()
4037 tty_kref_put(tty); hdlcdev_open()
4045 mgslpc_program_hw(info, tty); hdlcdev_open()
4046 tty_kref_put(tty); hdlcdev_open()
4074 struct tty_struct *tty = tty_port_tty_get(&info->port); hdlcdev_close() local
4083 shutdown(info, tty); hdlcdev_close()
4084 tty_kref_put(tty); hdlcdev_close()
4191 struct tty_struct *tty = tty_port_tty_get(&info->port); hdlcdev_ioctl() local
4192 mgslpc_program_hw(info, tty); hdlcdev_ioctl()
4193 tty_kref_put(tty); hdlcdev_ioctl()
/linux-4.1.27/include/net/irda/
H A Dircomm_tty.h35 #include <linux/tty.h> /* struct tty_struct */
103 void ircomm_tty_start(struct tty_struct *tty);
106 int ircomm_tty_tiocmget(struct tty_struct *tty);
107 int ircomm_tty_tiocmset(struct tty_struct *tty, unsigned int set,
109 int ircomm_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
111 void ircomm_tty_set_termios(struct tty_struct *tty,
/linux-4.1.27/drivers/misc/
H A Dpti.c30 #include <linux/tty.h>
403 * ID to the PTI device via tty device.
405 * @tty: tty interface.
412 * The main purpose of using the tty device interface is for
413 * each tty port to have a unique PTI write aperture. In an
421 static int pti_tty_driver_open(struct tty_struct *tty, struct file *filp) pti_tty_driver_open() argument
430 return tty_port_open(tty->port, tty, filp); pti_tty_driver_open()
434 * pti_tty_driver_close()- close tty device and release Application
435 * master, channel aperture ID to the PTI device via tty device.
437 * @tty: tty interface.
440 * The main purpose of using the tty device interface is to route
444 static void pti_tty_driver_close(struct tty_struct *tty, struct file *filp) pti_tty_driver_close() argument
446 tty_port_close(tty->port, tty, filp); pti_tty_driver_close()
451 * to tty ports for organizational purposes when
454 * @driver: tty driver information.
455 * @tty: tty struct containing pti information.
461 static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty) pti_tty_install() argument
463 int idx = tty->index; pti_tty_install()
465 int ret = tty_standard_install(driver, tty); pti_tty_install()
481 tty->driver_data = pti_tty_data; pti_tty_install()
489 * tied to tty's of this driver.
491 * @tty: tty struct containing pti information.
493 static void pti_tty_cleanup(struct tty_struct *tty) pti_tty_cleanup() argument
495 struct pti_tty *pti_tty_data = tty->driver_data; pti_tty_cleanup()
500 tty->driver_data = NULL; pti_tty_cleanup()
516 static int pti_tty_driver_write(struct tty_struct *tty, pti_tty_driver_write() argument
519 struct pti_tty *pti_tty_data = tty->driver_data; pti_tty_driver_write()
535 * @tty: contains tty info of the pti driver.
537 static int pti_tty_write_room(struct tty_struct *tty) pti_tty_write_room() argument
690 * pti_console_device()- Return the driver tty structure and set the
727 * The console should be enabled upon when the tty port is
729 * the tty port is to hook up syslog to it, the tty port
745 * @port- The tty port number of the PTI device.
746 * @tty- The tty struct associated with this device.
751 * Notes: The primary purpose of the PTI tty port 0 is to hook
755 static int pti_port_activate(struct tty_port *port, struct tty_struct *tty) pti_port_activate() argument
757 if (port->tty->index == PTITTY_MINOR_START) pti_port_activate()
764 * last tty port close.
766 * @port- The tty port number of the PTI device.
768 * Notes: The primary purpose of the PTI tty port 0 is to hook
774 if (port->tty->index == PTITTY_MINOR_START) pti_port_shutdown()
784 * Note the _probe() call sets everything up and ties the char and tty
923 /* First register module as tty device */ pti_init()
973 * pti_exit()- Unregisters this module as a tty and pci driver.
/linux-4.1.27/drivers/staging/fwserial/
H A Dfwserial.c47 * Threshold below which the tty is woken for writing
48 * - should be equal to WAKEUP_CHARS in drivers/tty/n_tty.c because
62 * port_table: array of tty ports allocated to each fw_card
64 * tty ports are allocated during probe when an fw_serial is first
76 /* total # of tty ports created per fw_card */
309 struct tty_struct *tty; fwtty_update_port_status() local
329 tty = tty_port_tty_get(&port->port); fwtty_update_port_status()
330 if (tty && !C_CLOCAL(tty)) { fwtty_update_port_status()
336 tty_kref_put(tty); fwtty_update_port_status()
340 tty = tty_port_tty_get(&port->port); fwtty_update_port_status()
341 if (tty && C_CRTSCTS(tty)) { fwtty_update_port_status()
342 if (tty->hw_stopped) { fwtty_update_port_status()
344 tty->hw_stopped = 0; fwtty_update_port_status()
352 tty->hw_stopped = 1; fwtty_update_port_status()
355 tty_kref_put(tty); fwtty_update_port_status()
358 tty = tty_port_tty_get(&port->port); fwtty_update_port_status()
359 if (tty) { fwtty_update_port_status()
360 if (tty->hw_stopped) { fwtty_update_port_status()
362 tty->hw_stopped = 0; fwtty_update_port_status()
370 tty->hw_stopped = 1; fwtty_update_port_status()
373 tty_kref_put(tty); fwtty_update_port_status()
456 struct tty_struct *tty; fwtty_throttle_port() local
459 tty = tty_port_tty_get(&port->port); fwtty_throttle_port()
460 if (!tty) fwtty_throttle_port()
467 if (C_CRTSCTS(tty)) fwtty_throttle_port()
474 tty_kref_put(tty); fwtty_throttle_port()
482 * drop DTR on the remote which will drop carrier here. Typically, the tty is
500 struct tty_struct *tty; fwtty_do_hangup() local
504 tty = tty_port_tty_get(&port->port); fwtty_do_hangup()
505 if (tty) fwtty_do_hangup()
506 tty_vhangup(tty); fwtty_do_hangup()
507 tty_kref_put(tty); fwtty_do_hangup()
716 struct tty_struct *tty; fwtty_tx() local
719 tty = tty_port_tty_get(&port->port); fwtty_tx()
720 if (!tty) fwtty_tx()
737 while (!tty->stopped && !tty->hw_stopped && fwtty_tx()
794 tty_wakeup(tty); fwtty_tx()
802 tty_kref_put(tty); fwtty_tx()
924 * This port operation is polled after a tty has been opened and is waiting for
925 * carrier detect -- see drivers/tty/tty_port:tty_port_block_til_ready().
939 static unsigned set_termios(struct fwtty_port *port, struct tty_struct *tty) set_termios() argument
943 baud = tty_termios_baud_rate(&tty->termios); set_termios()
944 tty_termios_encode_baud_rate(&tty->termios, baud, baud); set_termios()
947 frame = 12 + ((C_CSTOPB(tty)) ? 4 : 2) + ((C_PARENB(tty)) ? 2 : 0); set_termios()
949 switch (C_CSIZE(tty)) { set_termios()
951 frame -= (C_CSTOPB(tty)) ? 1 : 0; set_termios()
967 if (_I_FLAG(tty, BRKINT | PARMRK)) set_termios()
971 if (I_IGNBRK(tty)) { set_termios()
973 if (I_IGNPAR(tty)) set_termios()
977 port->write_only = !C_CREAD(tty); set_termios()
981 tty->termios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHOKE | set_termios()
983 tty->termios.c_oflag &= ~ONLCR; set_termios()
990 struct tty_struct *tty) fwtty_port_activate()
996 set_bit(TTY_IO_ERROR, &tty->flags); fwtty_port_activate()
1008 baud = set_termios(port, tty); fwtty_port_activate()
1017 if (C_CRTSCTS(tty) && ~port->mstatus & TIOCM_CTS) fwtty_port_activate()
1018 tty->hw_stopped = 1; fwtty_port_activate()
1023 clear_bit(TTY_IO_ERROR, &tty->flags); fwtty_port_activate()
1031 * Note: the tty port core ensures this is not the console and
1052 static int fwtty_open(struct tty_struct *tty, struct file *fp) fwtty_open() argument
1054 struct fwtty_port *port = tty->driver_data; fwtty_open()
1056 return tty_port_open(&port->port, tty, fp); fwtty_open()
1059 static void fwtty_close(struct tty_struct *tty, struct file *fp) fwtty_close() argument
1061 struct fwtty_port *port = tty->driver_data; fwtty_close()
1063 tty_port_close(&port->port, tty, fp); fwtty_close()
1066 static void fwtty_hangup(struct tty_struct *tty) fwtty_hangup() argument
1068 struct fwtty_port *port = tty->driver_data; fwtty_hangup()
1073 static void fwtty_cleanup(struct tty_struct *tty) fwtty_cleanup() argument
1075 struct fwtty_port *port = tty->driver_data; fwtty_cleanup()
1077 tty->driver_data = NULL; fwtty_cleanup()
1081 static int fwtty_install(struct tty_driver *driver, struct tty_struct *tty) fwtty_install() argument
1083 struct fwtty_port *port = fwtty_port_get(tty->index); fwtty_install()
1086 err = tty_standard_install(driver, tty); fwtty_install()
1088 tty->driver_data = port; fwtty_install()
1094 static int fwloop_install(struct tty_driver *driver, struct tty_struct *tty) fwloop_install() argument
1096 struct fwtty_port *port = fwtty_port_get(table_idx(tty->index)); fwloop_install()
1099 err = tty_standard_install(driver, tty); fwloop_install()
1101 tty->driver_data = port; fwloop_install()
1107 static int fwtty_write(struct tty_struct *tty, const unsigned char *buf, int c) fwtty_write() argument
1109 struct fwtty_port *port = tty->driver_data; fwtty_write()
1130 static int fwtty_write_room(struct tty_struct *tty) fwtty_write_room() argument
1132 struct fwtty_port *port = tty->driver_data; fwtty_write_room()
1144 static int fwtty_chars_in_buffer(struct tty_struct *tty) fwtty_chars_in_buffer() argument
1146 struct fwtty_port *port = tty->driver_data; fwtty_chars_in_buffer()
1158 static void fwtty_send_xchar(struct tty_struct *tty, char ch) fwtty_send_xchar() argument
1160 struct fwtty_port *port = tty->driver_data; fwtty_send_xchar()
1167 static void fwtty_throttle(struct tty_struct *tty) fwtty_throttle() argument
1169 struct fwtty_port *port = tty->driver_data; fwtty_throttle()
1174 * accepted by the tty flip buffer. For example, it is fwtty_throttle()
1175 * possible for received data to overflow the tty buffer long fwtty_throttle()
1178 * but the tty buffer is still emptying, so the line discipline is fwtty_throttle()
1185 static void fwtty_unthrottle(struct tty_struct *tty) fwtty_unthrottle() argument
1187 struct fwtty_port *port = tty->driver_data; fwtty_unthrottle()
1189 fwtty_dbg(port, "CRTSCTS: %d\n", C_CRTSCTS(tty) != 0); fwtty_unthrottle()
1195 if (C_CRTSCTS(tty)) fwtty_unthrottle()
1237 tmp.line = port->port.tty->index; get_serial_info()
1269 static int fwtty_ioctl(struct tty_struct *tty, unsigned cmd, fwtty_ioctl() argument
1272 struct fwtty_port *port = tty->driver_data; fwtty_ioctl()
1299 static void fwtty_set_termios(struct tty_struct *tty, struct ktermios *old) fwtty_set_termios() argument
1301 struct fwtty_port *port = tty->driver_data; fwtty_set_termios()
1305 baud = set_termios(port, tty); fwtty_set_termios()
1310 if (C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags)) fwtty_set_termios()
1319 if (!C_CRTSCTS(tty)) { fwtty_set_termios()
1320 tty->hw_stopped = 0; fwtty_set_termios()
1323 } else if (C_CRTSCTS(tty) && ~port->mstatus & TIOCM_CTS) { fwtty_set_termios()
1324 tty->hw_stopped = 1; fwtty_set_termios()
1338 static int fwtty_break_ctl(struct tty_struct *tty, int state) fwtty_break_ctl() argument
1340 struct fwtty_port *port = tty->driver_data; fwtty_break_ctl()
1371 static int fwtty_tiocmget(struct tty_struct *tty) fwtty_tiocmget() argument
1373 struct fwtty_port *port = tty->driver_data; fwtty_tiocmget()
1385 static int fwtty_tiocmset(struct tty_struct *tty, unsigned set, unsigned clear) fwtty_tiocmset() argument
1387 struct fwtty_port *port = tty->driver_data; fwtty_tiocmset()
1401 static int fwtty_get_icount(struct tty_struct *tty, fwtty_get_icount() argument
1404 struct fwtty_port *port = tty->driver_data; fwtty_get_icount()
1901 * HUP the tty (if the tty exists) and unregister the tty device.
1911 struct tty_struct *tty; fwserial_close_port() local
1914 tty = tty_port_tty_get(&port->port); fwserial_close_port()
1915 if (tty) { fwserial_close_port()
1916 tty_vhangup(tty); fwserial_close_port()
1917 tty_kref_put(tty); fwserial_close_port()
2051 * available tty port. This function is called either directly or indirectly
2277 fwtty_err(&unit, "register tty device error (%d)\n", fwserial_create()
2839 pr_err("register tty driver failed (%d)\n", err); fwserial_init()
2953 MODULE_PARM_DESC(auto, "Auto-connect a tty to each firewire node discovered");
989 fwtty_port_activate(struct tty_port *tty_port, struct tty_struct *tty) fwtty_port_activate() argument
/linux-4.1.27/lib/
H A Dbust_spinlocks.c13 #include <linux/tty.h>
/linux-4.1.27/include/linux/usb/
H A Dserial.h70 * @throttle_req: nonzero if the tty wants to throttle us
219 * the corresponding tty port functions are called. If they are not
255 /* Called by console and by the tty layer */
256 int (*open)(struct tty_struct *tty, struct usb_serial_port *port);
258 int (*write)(struct tty_struct *tty, struct usb_serial_port *port,
260 /* Called only by the tty layer */
261 int (*write_room)(struct tty_struct *tty);
262 int (*ioctl)(struct tty_struct *tty,
264 void (*set_termios)(struct tty_struct *tty,
266 void (*break_ctl)(struct tty_struct *tty, int break_state);
267 int (*chars_in_buffer)(struct tty_struct *tty);
268 void (*wait_until_sent)(struct tty_struct *tty, long timeout);
270 void (*throttle)(struct tty_struct *tty);
271 void (*unthrottle)(struct tty_struct *tty);
272 int (*tiocmget)(struct tty_struct *tty);
273 int (*tiocmset)(struct tty_struct *tty,
275 int (*tiocmiwait)(struct tty_struct *tty, unsigned long arg);
276 int (*get_icount)(struct tty_struct *tty,
278 /* Called by the tty layer for port level work. There may or may not
279 be an attached tty at this point */
284 void (*init_termios)(struct tty_struct *tty);
321 extern int usb_serial_generic_open(struct tty_struct *tty, usb_serial_console_disconnect()
325 extern int usb_serial_generic_write(struct tty_struct *tty, usb_serial_console_disconnect()
329 extern int usb_serial_generic_write_room(struct tty_struct *tty); usb_serial_console_disconnect()
330 extern int usb_serial_generic_chars_in_buffer(struct tty_struct *tty); usb_serial_console_disconnect()
331 extern void usb_serial_generic_wait_until_sent(struct tty_struct *tty, usb_serial_console_disconnect()
335 extern void usb_serial_generic_throttle(struct tty_struct *tty); usb_serial_console_disconnect()
336 extern void usb_serial_generic_unthrottle(struct tty_struct *tty); usb_serial_console_disconnect()
337 extern int usb_serial_generic_tiocmiwait(struct tty_struct *tty, usb_serial_console_disconnect()
339 extern int usb_serial_generic_get_icount(struct tty_struct *tty, usb_serial_console_disconnect()
352 struct tty_struct *tty, usb_serial_console_disconnect()
/linux-4.1.27/drivers/staging/comedi/drivers/
H A Dserial2002.c50 struct file *tty; member in struct:serial2002_private
413 serial2002_tty_setspeed(devpriv->tty, devpriv->speed); serial2002_setup_subdevs()
414 serial2002_poll_channel(devpriv->tty, 31); serial2002_setup_subdevs()
416 struct serial_data data = serial2002_read(devpriv->tty, 1000); serial2002_setup_subdevs()
542 if (devpriv->tty) { serial2002_setup_subdevs()
543 filp_close(devpriv->tty, NULL); serial2002_setup_subdevs()
544 devpriv->tty = NULL; serial2002_setup_subdevs()
558 devpriv->tty = filp_open(port, O_RDWR, 0); serial2002_open()
559 if (IS_ERR(devpriv->tty)) { serial2002_open()
560 result = (int)PTR_ERR(devpriv->tty); serial2002_open()
572 if (!IS_ERR(devpriv->tty) && devpriv->tty) serial2002_close()
573 filp_close(devpriv->tty, NULL); serial2002_close()
589 serial2002_poll_digital(devpriv->tty, chan); serial2002_di_insn_read()
591 read = serial2002_read(devpriv->tty, 1000); serial2002_di_insn_read()
616 serial2002_write(devpriv->tty, write); serial2002_do_insn_write()
634 serial2002_poll_channel(devpriv->tty, chan); serial2002_ai_insn_read()
636 read = serial2002_read(devpriv->tty, 1000); serial2002_ai_insn_read()
661 serial2002_write(devpriv->tty, write); serial2002_ao_insn_write()
695 serial2002_poll_channel(devpriv->tty, chan); serial2002_encoder_insn_read()
697 read = serial2002_read(devpriv->tty, 1000); serial2002_encoder_insn_read()
/linux-4.1.27/drivers/misc/ti-st/
H A Dst_core.c25 #include <linux/tty.h>
61 * This is a wrapper function to tty->ops->write_room.
67 struct tty_struct *tty; st_get_uart_wr_room() local
68 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { st_get_uart_wr_room()
69 pr_err("tty unavailable to perform write"); st_get_uart_wr_room()
72 tty = st_gdata->tty; st_get_uart_wr_room()
73 return tty->ops->write_room(tty); st_get_uart_wr_room()
81 * to tty->ops->write
86 struct tty_struct *tty; st_int_write() local
87 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { st_int_write()
88 pr_err("tty unavailable to perform write"); st_int_write()
91 tty = st_gdata->tty; st_int_write()
96 return tty->ops->write(tty, data, count); st_int_write()
485 set_bit(TTY_DO_WRITE_WAKEUP, &st_data->tty->flags); st_tx_wakeup()
667 /* stop traffic on tty */ st_unregister()
668 if (st_gdata->tty) { st_unregister()
669 tty_ldisc_flush(st_gdata->tty); st_unregister()
670 stop_tty(st_gdata->tty); st_unregister()
692 || st_gdata->tty == NULL)) { st_write()
693 pr_err("data/tty unavailable to perform write"); st_write()
716 static int st_tty_open(struct tty_struct *tty) st_tty_open() argument
723 st_gdata->tty = tty; st_tty_open()
724 tty->disc_data = st_gdata; st_tty_open()
727 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); st_tty_open()
731 tty->receive_room = 65536; st_tty_open()
733 tty_ldisc_flush(tty); st_tty_open()
734 tty_driver_flush_buffer(tty); st_tty_open()
744 static void st_tty_close(struct tty_struct *tty) st_tty_close() argument
748 struct st_data_s *st_gdata = tty->disc_data; st_tty_close()
770 st_gdata->tty = NULL; st_tty_close()
772 tty_ldisc_flush(tty); st_tty_close()
773 tty_driver_flush_buffer(tty); st_tty_close()
789 static void st_tty_receive(struct tty_struct *tty, const unsigned char *data, st_tty_receive() argument
801 st_recv(tty->disc_data, data, count); st_tty_receive()
808 static void st_tty_wakeup(struct tty_struct *tty) st_tty_wakeup() argument
810 struct st_data_s *st_gdata = tty->disc_data; st_tty_wakeup()
813 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); st_tty_wakeup()
819 static void st_tty_flush_buffer(struct tty_struct *tty) st_tty_flush_buffer() argument
821 struct st_data_s *st_gdata = tty->disc_data; st_tty_flush_buffer()
827 tty_driver_flush_buffer(tty); st_tty_flush_buffer()
/linux-4.1.27/drivers/isdn/i4l/
H A Disdn_tty.c2 * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel).
52 * to stuff incoming data directly into a tty's flip-buffer. This
53 * is done to speed up tty-receiving if the receive-queue is empty.
116 * the tty's flip-buffer.
178 /* if midx is invalid, packet is not for tty */ isdn_tty_rcv_skb()
255 /* Try to deliver directly via tty-buf if queue is empty */ isdn_tty_rcv_skb()
299 struct tty_struct *tty = info->port.tty; isdn_tty_tint() local
303 tty_wakeup(tty); isdn_tty_tint()
417 * outgoing data from the tty's xmit-buffer, handles voice-decompression or
540 * into the tty's buffer.
592 /* isdn_tty_dial() performs dialing of a tty an the necessary
679 /* isdn_tty_hangup() disassociates a tty from the real
704 isdn_tty_flush_buffer(info->port.tty); isdn_tty_modem_hup()
762 /* isdn_tty_suspend() tries to suspend the current tty connection
1010 if (!port->tty) isdn_tty_change_speed()
1012 cflag = port->tty->termios.c_cflag; isdn_tty_change_speed()
1018 port->tty->termios.c_cflag &= ~CBAUDEX; isdn_tty_change_speed()
1066 if (info->port.tty) isdn_tty_startup()
1067 clear_bit(TTY_IO_ERROR, &info->port.tty->flags); isdn_tty_startup()
1093 if (!info->port.tty || (info->port.tty->termios.c_cflag & HUPCL)) { isdn_tty_shutdown()
1103 if (info->port.tty) isdn_tty_shutdown()
1104 set_bit(TTY_IO_ERROR, &info->port.tty->flags); isdn_tty_shutdown()
1119 isdn_tty_write(struct tty_struct *tty, const u_char *buf, int count) isdn_tty_write() argument
1123 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_write()
1126 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_write")) isdn_tty_write()
1158 tty_wakeup(tty); isdn_tty_write()
1229 isdn_tty_write_room(struct tty_struct *tty) isdn_tty_write_room() argument
1231 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_write_room()
1234 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_write_room")) isdn_tty_write_room()
1243 isdn_tty_chars_in_buffer(struct tty_struct *tty) isdn_tty_chars_in_buffer() argument
1245 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_chars_in_buffer()
1247 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_chars_in_buffer")) isdn_tty_chars_in_buffer()
1255 isdn_tty_flush_buffer(struct tty_struct *tty) isdn_tty_flush_buffer() argument
1259 if (!tty) { isdn_tty_flush_buffer()
1262 info = (modem_info *) tty->driver_data; isdn_tty_flush_buffer()
1263 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_flush_buffer")) { isdn_tty_flush_buffer()
1268 tty_wakeup(tty); isdn_tty_flush_buffer()
1272 isdn_tty_flush_chars(struct tty_struct *tty) isdn_tty_flush_chars() argument
1274 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_flush_chars()
1276 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_flush_chars")) isdn_tty_flush_chars()
1286 * This routine is called by the upper-layer tty layer to signal that
1291 isdn_tty_throttle(struct tty_struct *tty) isdn_tty_throttle() argument
1293 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_throttle()
1295 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_throttle")) isdn_tty_throttle()
1297 if (I_IXOFF(tty)) isdn_tty_throttle()
1298 info->x_char = STOP_CHAR(tty); isdn_tty_throttle()
1303 isdn_tty_unthrottle(struct tty_struct *tty) isdn_tty_unthrottle() argument
1305 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_unthrottle()
1307 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_unthrottle")) isdn_tty_unthrottle()
1309 if (I_IXOFF(tty)) { isdn_tty_unthrottle()
1313 info->x_char = START_CHAR(tty); isdn_tty_unthrottle()
1347 isdn_tty_tiocmget(struct tty_struct *tty) isdn_tty_tiocmget() argument
1349 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_tiocmget()
1352 if (isdn_tty_paranoia_check(info, tty->name, __func__)) isdn_tty_tiocmget()
1354 if (tty->flags & (1 << TTY_IO_ERROR)) isdn_tty_tiocmget()
1374 isdn_tty_tiocmset(struct tty_struct *tty, isdn_tty_tiocmset() argument
1377 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_tiocmset()
1379 if (isdn_tty_paranoia_check(info, tty->name, __func__)) isdn_tty_tiocmset()
1381 if (tty->flags & (1 << TTY_IO_ERROR)) isdn_tty_tiocmset()
1415 isdn_tty_ioctl(struct tty_struct *tty, uint cmd, ulong arg) isdn_tty_ioctl() argument
1417 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_ioctl()
1420 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_ioctl")) isdn_tty_ioctl()
1422 if (tty->flags & (1 << TTY_IO_ERROR)) isdn_tty_ioctl()
1429 retval = tty_check_change(tty); isdn_tty_ioctl()
1432 tty_wait_until_sent(tty, 0); isdn_tty_ioctl()
1438 retval = tty_check_change(tty); isdn_tty_ioctl()
1441 tty_wait_until_sent(tty, 0); isdn_tty_ioctl()
1458 isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) isdn_tty_set_termios() argument
1460 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_set_termios()
1465 if (tty->termios.c_cflag == old_termios->c_cflag && isdn_tty_set_termios()
1466 tty->termios.c_ispeed == old_termios->c_ispeed && isdn_tty_set_termios()
1467 tty->termios.c_ospeed == old_termios->c_ospeed) isdn_tty_set_termios()
1479 static int isdn_tty_install(struct tty_driver *driver, struct tty_struct *tty) isdn_tty_install() argument
1481 modem_info *info = &dev->mdm.info[tty->index]; isdn_tty_install()
1483 if (isdn_tty_paranoia_check(info, tty->name, __func__)) isdn_tty_install()
1486 tty->driver_data = info; isdn_tty_install()
1488 return tty_port_install(&info->port, driver, tty); isdn_tty_install()
1495 * initialization for the tty structure.
1498 isdn_tty_open(struct tty_struct *tty, struct file *filp) isdn_tty_open() argument
1500 modem_info *info = tty->driver_data; isdn_tty_open()
1505 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, isdn_tty_open()
1509 port->tty = tty; isdn_tty_open()
1520 retval = tty_port_block_til_ready(port, tty, filp); isdn_tty_open()
1538 isdn_tty_close(struct tty_struct *tty, struct file *filp) isdn_tty_close() argument
1540 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_close()
1544 if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close")) isdn_tty_close()
1552 if ((tty->count == 1) && (port->count != 1)) { isdn_tty_close()
1554 * Uh, oh. tty->count is 1, which means that the tty isdn_tty_close()
1560 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, " isdn_tty_close()
1577 tty->closing = 1; isdn_tty_close()
1585 tty_wait_until_sent_from_close(tty, 3000); /* 30 seconds timeout */ isdn_tty_close()
1600 isdn_tty_flush_buffer(tty); isdn_tty_close()
1601 tty_ldisc_flush(tty); isdn_tty_close()
1602 port->tty = NULL; isdn_tty_close()
1605 tty_port_close_end(port, tty); isdn_tty_close()
1615 isdn_tty_hangup(struct tty_struct *tty) isdn_tty_hangup() argument
1617 modem_info *info = (modem_info *) tty->driver_data; isdn_tty_hangup()
1620 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup")) isdn_tty_hangup()
1625 port->tty = NULL; isdn_tty_hangup()
1927 * Search the tty-devices for an appropriate device and bind
2059 /* Signal cause to tty-device */ isdn_tty_stat_callback()
2066 /* Signal display to tty-device */ isdn_tty_stat_callback()
2116 /* Schedule CONNECT-Message to any tty isdn_tty_stat_callback()
2216 * Put a message from the AT-emulator into receive-buffer of tty,
2363 * Return result of AT-emulator to tty-receive-buffer, depending on
2390 (!info->port.tty)); isdn_tty_modem_result()
2395 if ((info->port.flags & ASYNC_CLOSING) || (!info->port.tty)) isdn_tty_modem_result()
2528 if ((info->port.flags & ASYNC_CLOSING) || (!info->port.tty)) isdn_tty_modem_result()
2532 tty_hangup(info->port.tty); isdn_tty_modem_result()
3736 * For all online tty's, try sending data to
/linux-4.1.27/sound/soc/omap/
H A Dams-delta.c27 #include <linux/tty.h>
94 * from the board initialization code to the tty line discipline.
279 static int cx81801_open(struct tty_struct *tty) cx81801_open() argument
290 tty->disc_data = cx20442_codec; cx81801_open()
292 ret = v253_ops.open(tty); cx81801_open()
295 tty->disc_data = NULL; cx81801_open()
301 static void cx81801_close(struct tty_struct *tty) cx81801_close() argument
303 struct snd_soc_codec *codec = tty->disc_data; cx81801_close()
314 v253_ops.close(tty); cx81801_close()
331 static int cx81801_hangup(struct tty_struct *tty) cx81801_hangup() argument
333 cx81801_close(tty); cx81801_hangup()
338 static void cx81801_receive(struct tty_struct *tty, cx81801_receive() argument
341 struct snd_soc_codec *codec = tty->disc_data; cx81801_receive()
354 v253_ops.receive_buf(tty, cp, fp, count); cx81801_receive()
368 v253_ops.receive_buf(tty, cp, fp, count); cx81801_receive()
391 static void cx81801_wakeup(struct tty_struct *tty) cx81801_wakeup() argument
393 v253_ops.write_wakeup(tty); cx81801_wakeup()
469 /* Store a pointer to the codec structure for tty ldisc use */ ams_delta_cx20442_init()
/linux-4.1.27/drivers/tty/vt/
H A Dselection.c13 #include <linux/tty.h>
152 * @tty: the console tty
159 int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty) set_selection() argument
194 mouse_report(tty, sel_mode & TIOCL_SELBUTTONMASK, xs, ys); set_selection()
331 * queue of the tty associated with the current console.
337 int paste_selection(struct tty_struct *tty) paste_selection() argument
339 struct vc_data *vc = tty->driver_data; paste_selection()
349 ld = tty_ldisc_ref_wait(tty); paste_selection()
355 if (test_bit(TTY_THROTTLED, &tty->flags)) { paste_selection()
H A Dvt.c76 #include <linux/tty.h>
151 static void con_flush_chars(struct tty_struct *tty);
210 * Unfortunately, we need to delay tty echo when we're currently writing to the
237 * /sys/class/tty/tty0/
664 /* printk("redraw_screen: tty %d not allocated ??\n", new_console+1); */ redraw_screen()
824 * vc_do_resize - resizing method for the tty
825 * @tty: tty being resized
826 * @real_tty: real tty (different to tty if a pty/tty pair)
832 * If the caller passes a tty structure then update the termios winsize
836 * ctrl_lock of the tty IFF a tty is passed.
839 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, vc_do_resize() argument
935 if (tty) { vc_do_resize()
943 tty_do_resize(tty, &ws); vc_do_resize()
961 * vc->port.tty
966 return vc_do_resize(vc->port.tty, vc, cols, rows); vc_resize()
971 * @tty: tty to resize
974 * Resize a virtual terminal. This is called by the tty layer as we
978 * Takes the console sem and the called methods then take the tty
979 * termios_rwsem and the tty ctrl_lock in that order.
981 static int vt_resize(struct tty_struct *tty, struct winsize *ws) vt_resize() argument
983 struct vc_data *vc = tty->driver_data; vt_resize()
987 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); vt_resize()
1433 static void cursor_report(struct vc_data *vc, struct tty_struct *tty) cursor_report() argument
1438 respond_string(buf, tty->port); cursor_report()
1441 static inline void status_report(struct tty_struct *tty) status_report() argument
1443 respond_string("\033[0n", tty->port); /* Terminal ok */ status_report()
1446 static inline void respond_ID(struct tty_struct *tty) respond_ID() argument
1448 respond_string(VT102ID, tty->port); respond_ID()
1451 void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry) mouse_report() argument
1457 respond_string(buf, tty->port); mouse_report()
1728 static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) do_con_trol() argument
1815 respond_ID(tty); do_con_trol()
1926 status_report(tty); do_con_trol()
1928 cursor_report(vc, tty); do_con_trol()
2001 respond_ID(tty); do_con_trol()
2156 static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) do_con_write() argument
2184 vc = tty->driver_data; do_con_write()
2194 pr_warn_once("con_write: tty %d not allocated\n", currcons+1); do_con_write()
2208 while (!tty->stopped && count) { do_con_write()
2407 do_con_trol(tty, vc, orig); do_con_write()
2552 /* printk("vt_console_print: tty %d not allocated ??\n", currcons+1); */ vt_console_print()
2625 .name = "tty",
2649 int tioclinux(struct tty_struct *tty, unsigned long arg) tioclinux() argument
2656 if (current->signal->tty != tty && !capable(CAP_SYS_ADMIN)) tioclinux()
2666 ret = set_selection((struct tiocl_selection __user *)(p+1), tty); tioclinux()
2670 ret = paste_selection(tty); tioclinux()
2757 static int con_write(struct tty_struct *tty, const unsigned char *buf, int count) con_write() argument
2761 retval = do_con_write(tty, buf, count); con_write()
2762 con_flush_chars(tty); con_write()
2767 static int con_put_char(struct tty_struct *tty, unsigned char ch) con_put_char() argument
2771 return do_con_write(tty, &ch, 1); con_put_char()
2774 static int con_write_room(struct tty_struct *tty) con_write_room() argument
2776 if (tty->stopped) con_write_room()
2781 static int con_chars_in_buffer(struct tty_struct *tty) con_chars_in_buffer() argument
2791 static void con_throttle(struct tty_struct *tty) con_throttle() argument
2795 static void con_unthrottle(struct tty_struct *tty) con_unthrottle() argument
2797 struct vc_data *vc = tty->driver_data; con_unthrottle()
2803 * Turn the Scroll-Lock LED on when the tty is stopped
2805 static void con_stop(struct tty_struct *tty) con_stop() argument
2808 if (!tty) con_stop()
2810 console_num = tty->index; con_stop()
2819 static void con_start(struct tty_struct *tty) con_start() argument
2822 if (!tty) con_start()
2824 console_num = tty->index; con_start()
2830 static void con_flush_chars(struct tty_struct *tty) con_flush_chars() argument
2839 vc = tty->driver_data; con_flush_chars()
2848 static int con_install(struct tty_driver *driver, struct tty_struct *tty) con_install() argument
2850 unsigned int currcons = tty->index; con_install()
2862 if (vc->port.tty) { con_install()
2867 ret = tty_port_install(&vc->port, driver, tty); con_install()
2871 tty->driver_data = vc; con_install()
2872 vc->port.tty = tty; con_install()
2874 if (!tty->winsize.ws_row && !tty->winsize.ws_col) { con_install()
2875 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; con_install()
2876 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; con_install()
2879 tty->termios.c_iflag |= IUTF8; con_install()
2881 tty->termios.c_iflag &= ~IUTF8; con_install()
2887 static int con_open(struct tty_struct *tty, struct file *filp) con_open() argument
2894 static void con_close(struct tty_struct *tty, struct file *filp) con_close() argument
2899 static void con_shutdown(struct tty_struct *tty) con_shutdown() argument
2901 struct vc_data *vc = tty->driver_data; con_shutdown()
2904 vc->port.tty = NULL; con_shutdown()
3040 return sprintf(buf, "tty%d\n", fg_console + 1); show_tty_active()
3069 console_driver->name = "tty"; vty_init()
3850 pr_warn("unblank_screen: tty %d not allocated ??\n", do_unblank_screen()
H A Dvt_ioctl.c14 #include <linux/tty.h>
334 int vt_ioctl(struct tty_struct *tty, vt_ioctl() argument
337 struct vc_data *vc = tty->driver_data; vt_ioctl()
357 * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. vt_ioctl()
360 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) vt_ioctl()
365 ret = tioclinux(tty, arg); vt_ioctl()
515 tty_ldisc_flush(tty); vt_ioctl()
838 /* FIXME: review v tty lock */ vt_ioctl()
1070 struct tty_struct *tty; vc_SAK() local
1075 /* FIXME: review tty ref counting */ vc_SAK()
1076 tty = vc->port.tty; vc_SAK()
1081 if (tty) vc_SAK()
1082 __do_SAK(tty); vc_SAK()
1196 long vt_compat_ioctl(struct tty_struct *tty, vt_compat_ioctl() argument
1199 struct vc_data *vc = tty->driver_data; vt_compat_ioctl()
1215 * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. vt_compat_ioctl()
1218 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) vt_compat_ioctl()
1276 return vt_ioctl(tty, cmd, arg); vt_compat_ioctl()
1338 * to account for and tracking tty count may be undesirable. complete_change_console()
1410 * to account for and tracking tty count may be undesirable. change_console()
/linux-4.1.27/drivers/usb/class/
H A Dcdc-acm.c38 #include <linux/tty.h>
63 static void acm_tty_set_termios(struct tty_struct *tty,
449 /* throttle device if requested by tty */ acm_read_bulk_callback()
494 static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty) acm_tty_install() argument
499 dev_dbg(tty->dev, "%s\n", __func__); acm_tty_install()
501 acm = acm_get_by_index(tty->index); acm_tty_install()
505 retval = tty_standard_install(driver, tty); acm_tty_install()
509 tty->driver_data = acm; acm_tty_install()
518 static int acm_tty_open(struct tty_struct *tty, struct file *filp) acm_tty_open() argument
520 struct acm *acm = tty->driver_data; acm_tty_open()
522 dev_dbg(tty->dev, "%s\n", __func__); acm_tty_open()
524 return tty_port_open(&acm->port, tty, filp); acm_tty_open()
546 static int acm_port_activate(struct tty_port *port, struct tty_struct *tty) acm_port_activate() argument
566 set_bit(TTY_NO_WRITE_SPLIT, &tty->flags); acm_port_activate()
577 acm_tty_set_termios(tty, NULL); acm_port_activate()
633 * hold it due to the tty-port initialised flag. acm_port_shutdown()
658 static void acm_tty_cleanup(struct tty_struct *tty) acm_tty_cleanup() argument
660 struct acm *acm = tty->driver_data; acm_tty_cleanup()
665 static void acm_tty_hangup(struct tty_struct *tty) acm_tty_hangup() argument
667 struct acm *acm = tty->driver_data; acm_tty_hangup()
672 static void acm_tty_close(struct tty_struct *tty, struct file *filp) acm_tty_close() argument
674 struct acm *acm = tty->driver_data; acm_tty_close()
676 tty_port_close(&acm->port, tty, filp); acm_tty_close()
679 static int acm_tty_write(struct tty_struct *tty, acm_tty_write() argument
682 struct acm *acm = tty->driver_data; acm_tty_write()
733 static int acm_tty_write_room(struct tty_struct *tty) acm_tty_write_room() argument
735 struct acm *acm = tty->driver_data; acm_tty_write_room()
743 static int acm_tty_chars_in_buffer(struct tty_struct *tty) acm_tty_chars_in_buffer() argument
745 struct acm *acm = tty->driver_data; acm_tty_chars_in_buffer()
758 static void acm_tty_throttle(struct tty_struct *tty) acm_tty_throttle() argument
760 struct acm *acm = tty->driver_data; acm_tty_throttle()
767 static void acm_tty_unthrottle(struct tty_struct *tty) acm_tty_unthrottle() argument
769 struct acm *acm = tty->driver_data; acm_tty_unthrottle()
782 static int acm_tty_break_ctl(struct tty_struct *tty, int state) acm_tty_break_ctl() argument
784 struct acm *acm = tty->driver_data; acm_tty_break_ctl()
794 static int acm_tty_tiocmget(struct tty_struct *tty) acm_tty_tiocmget() argument
796 struct acm *acm = tty->driver_data; acm_tty_tiocmget()
806 static int acm_tty_tiocmset(struct tty_struct *tty, acm_tty_tiocmset() argument
809 struct acm *acm = tty->driver_data; acm_tty_tiocmset()
944 static int acm_tty_ioctl(struct tty_struct *tty, acm_tty_ioctl() argument
947 struct acm *acm = tty->driver_data; acm_tty_ioctl()
974 static void acm_tty_set_termios(struct tty_struct *tty, acm_tty_set_termios() argument
977 struct acm *acm = tty->driver_data; acm_tty_set_termios()
978 struct ktermios *termios = &tty->termios; acm_tty_set_termios()
982 newline.dwDTERate = cpu_to_le32(tty_get_baud_rate(tty)); acm_tty_set_termios()
1005 if (C_BAUD(tty) == B0) { acm_tty_set_termios()
1540 struct tty_struct *tty; acm_disconnect() local
1563 tty = tty_port_tty_get(&acm->port); acm_disconnect()
1564 if (tty) { acm_disconnect()
1565 tty_vhangup(tty); acm_disconnect()
1566 tty_kref_put(tty); acm_disconnect()
/linux-4.1.27/arch/mips/include/uapi/asm/
H A Dioctls.h28 #define TIOCEXCL 0x740d /* set exclusive use of tty */
29 #define TIOCNXCL 0x740e /* reset exclusive use of tty */
47 #define TIOCNOTTY 0x5471 /* void tty association */
59 #define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
60 #define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
96 #define TIOCSCTTY 0x5480 /* become controlling tty */
H A Dsignal.h52 #define SIGTTIN 26 /* Background read from tty (POSIX). */
53 #define SIGTTOU 27 /* Background write to tty (POSIX). */
/linux-4.1.27/arch/mips/fw/arc/
H A Darc_con.c9 #include <linux/tty.h>
/linux-4.1.27/arch/parisc/kernel/
H A Dpdc_cons.c52 #include <linux/tty.h>
98 static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp) pdc_console_tty_open() argument
100 tty_port_tty_set(&tty_port, tty); pdc_console_tty_open()
106 static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp) pdc_console_tty_close() argument
108 if (tty->count == 1) { pdc_console_tty_close()
114 static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) pdc_console_tty_write() argument
120 static int pdc_console_tty_write_room(struct tty_struct *tty) pdc_console_tty_write_room() argument
125 static int pdc_console_tty_chars_in_buffer(struct tty_struct *tty) pdc_console_tty_chars_in_buffer() argument
/linux-4.1.27/drivers/staging/dgap/
H A Ddgap.c56 #include <linux/tty.h>
830 case ID: /* letter ID used in tty name */ dgap_parsefile()
859 pr_err("bad number for start of tty count"); dgap_parsefile()
870 pr_err("bad number for start of tty count"); dgap_parsefile()
881 pr_err("bad number for start of tty count"); dgap_parsefile()
891 case TTYN: /* tty name prefix */ dgap_parsefile()
1171 case TTSIZ: /* size of tty structure */ dgap_parsefile()
1610 /* Decide how much data we can send into the tty layer */ dgap_input()
1688 * of the tty layers that exist. dgap_input()
1693 * the tty layer, which has its API more well defined. dgap_input()
1710 /* Tell the tty layer its okay to "eat" the data now */ dgap_input()
3067 static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, dgap_block_til_ready() argument
3076 if (!tty || tty->magic != TTY_MAGIC || !file || !ch || dgap_block_til_ready()
3080 un = tty->driver_data; dgap_block_til_ready()
3102 /* If tty was hung up, break out of loop and set error. */ dgap_block_til_ready()
3120 * 1) NONBLOCKING on the tty is set. dgap_block_til_ready()
3128 if (tty->flags & (1 << TTY_IO_ERROR)) dgap_block_til_ready()
3198 static void dgap_tty_flush_buffer(struct tty_struct *tty) dgap_tty_flush_buffer() argument
3207 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_flush_buffer()
3210 un = tty->driver_data; dgap_tty_flush_buffer()
3240 if (waitqueue_active(&tty->write_wait)) dgap_tty_flush_buffer()
3241 wake_up_interruptible(&tty->write_wait); dgap_tty_flush_buffer()
3242 tty_wakeup(tty); dgap_tty_flush_buffer()
3250 static void dgap_tty_hangup(struct tty_struct *tty) dgap_tty_hangup() argument
3256 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_hangup()
3259 un = tty->driver_data; dgap_tty_hangup()
3272 dgap_tty_flush_buffer(tty); dgap_tty_hangup()
3283 static int dgap_tty_chars_in_buffer(struct tty_struct *tty) dgap_tty_chars_in_buffer() argument
3295 if (!tty) dgap_tty_chars_in_buffer()
3298 un = tty->driver_data; dgap_tty_chars_in_buffer()
3375 static int dgap_wait_for_drain(struct tty_struct *tty) dgap_wait_for_drain() argument
3384 if (!tty || tty->magic != TTY_MAGIC) dgap_wait_for_drain()
3387 un = tty->driver_data; dgap_wait_for_drain()
3402 count = dgap_tty_chars_in_buffer(tty); dgap_wait_for_drain()
3505 static int dgap_tty_write_room(struct tty_struct *tty) dgap_tty_write_room() argument
3514 if (!tty) dgap_tty_write_room()
3517 un = tty->driver_data; dgap_tty_write_room()
3577 static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, dgap_tty_write() argument
3588 if (!tty) dgap_tty_write()
3591 un = tty->driver_data; dgap_tty_write()
3739 static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c) dgap_tty_put_char() argument
3744 dgap_tty_write(tty, &c, 1); dgap_tty_put_char()
3751 static int dgap_tty_tiocmget(struct tty_struct *tty) dgap_tty_tiocmget() argument
3759 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_tiocmget()
3762 un = tty->driver_data; dgap_tty_tiocmget()
3801 static int dgap_tty_tiocmset(struct tty_struct *tty, dgap_tty_tiocmset() argument
3810 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_tiocmset()
3813 un = tty->driver_data; dgap_tty_tiocmset()
3861 static int dgap_tty_send_break(struct tty_struct *tty, int msec) dgap_tty_send_break() argument
3869 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_send_break()
3872 un = tty->driver_data; dgap_tty_send_break()
3914 static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout) dgap_tty_wait_until_sent() argument
3916 dgap_wait_for_drain(tty); dgap_tty_wait_until_sent()
3924 static void dgap_tty_send_xchar(struct tty_struct *tty, char c) dgap_tty_send_xchar() argument
3932 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_send_xchar()
3935 un = tty->driver_data; dgap_tty_send_xchar()
3958 if (c == STOP_CHAR(tty)) dgap_tty_send_xchar()
3960 else if (c == START_CHAR(tty)) dgap_tty_send_xchar()
4171 static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo) dgap_tty_digigetedelay() argument
4181 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_digigetedelay()
4184 un = tty->driver_data; dgap_tty_digigetedelay()
4293 static void dgap_tty_set_termios(struct tty_struct *tty, dgap_tty_set_termios() argument
4302 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_set_termios()
4305 un = tty->driver_data; dgap_tty_set_termios()
4320 ch->ch_c_cflag = tty->termios.c_cflag; dgap_tty_set_termios()
4321 ch->ch_c_iflag = tty->termios.c_iflag; dgap_tty_set_termios()
4322 ch->ch_c_oflag = tty->termios.c_oflag; dgap_tty_set_termios()
4323 ch->ch_c_lflag = tty->termios.c_lflag; dgap_tty_set_termios()
4324 ch->ch_startc = tty->termios.c_cc[VSTART]; dgap_tty_set_termios()
4325 ch->ch_stopc = tty->termios.c_cc[VSTOP]; dgap_tty_set_termios()
4334 static void dgap_tty_throttle(struct tty_struct *tty) dgap_tty_throttle() argument
4342 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_throttle()
4345 un = tty->driver_data; dgap_tty_throttle()
4370 static void dgap_tty_unthrottle(struct tty_struct *tty) dgap_tty_unthrottle() argument
4378 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_unthrottle()
4381 un = tty->driver_data; dgap_tty_unthrottle()
4433 static int dgap_tty_open(struct tty_struct *tty, struct file *file) dgap_tty_open() argument
4446 major = MAJOR(tty_devnum(tty)); dgap_tty_open()
4447 minor = MINOR(tty_devnum(tty)); dgap_tty_open()
4472 if (MINOR(tty_devnum(tty)) > brd->nasync) { dgap_tty_open()
4500 tty->driver_data = un; dgap_tty_open()
4513 * Initialize tty's dgap_tty_open()
4517 un->un_tty = tty; dgap_tty_open()
4540 ch->ch_c_cflag = tty->termios.c_cflag; dgap_tty_open()
4541 ch->ch_c_iflag = tty->termios.c_iflag; dgap_tty_open()
4542 ch->ch_c_oflag = tty->termios.c_oflag; dgap_tty_open()
4543 ch->ch_c_lflag = tty->termios.c_lflag; dgap_tty_open()
4544 ch->ch_startc = tty->termios.c_cc[VSTART]; dgap_tty_open()
4545 ch->ch_stopc = tty->termios.c_cc[VSTOP]; dgap_tty_open()
4563 rc = dgap_block_til_ready(tty, file, ch); dgap_tty_open()
4582 static void dgap_tty_close(struct tty_struct *tty, struct file *file) dgap_tty_close() argument
4590 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_close()
4593 un = tty->driver_data; dgap_tty_close()
4605 ts = &tty->termios; dgap_tty_close()
4613 if ((tty->count == 1) && (un->un_open_count != 1)) { dgap_tty_close()
4615 * Uh, oh. tty->count is 1, which means that the tty dgap_tty_close()
4638 tty->closing = 1; dgap_tty_close()
4654 dgap_wait_for_drain(tty); dgap_tty_close()
4656 dgap_tty_flush_buffer(tty); dgap_tty_close()
4657 tty_ldisc_flush(tty); dgap_tty_close()
4661 tty->closing = 0; dgap_tty_close()
4700 tty->driver_data = NULL; dgap_tty_close()
4708 static void dgap_tty_start(struct tty_struct *tty) dgap_tty_start() argument
4716 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_start()
4719 un = tty->driver_data; dgap_tty_start()
4740 static void dgap_tty_stop(struct tty_struct *tty) dgap_tty_stop() argument
4748 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_stop()
4751 un = tty->driver_data; dgap_tty_stop()
4785 static void dgap_tty_flush_chars(struct tty_struct *tty) dgap_tty_flush_chars() argument
4793 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_flush_chars()
4796 un = tty->driver_data; dgap_tty_flush_chars()
4828 static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, dgap_tty_ioctl() argument
4840 if (!tty || tty->magic != TTY_MAGIC) dgap_tty_ioctl()
4843 un = tty->driver_data; dgap_tty_ioctl()
4877 rc = tty_check_change(tty); dgap_tty_ioctl()
4883 rc = dgap_wait_for_drain(tty); dgap_tty_ioctl()
4906 rc = tty_check_change(tty); dgap_tty_ioctl()
4912 rc = dgap_wait_for_drain(tty); dgap_tty_ioctl()
4933 rc = tty_check_change(tty); dgap_tty_ioctl()
4939 rc = dgap_wait_for_drain(tty); dgap_tty_ioctl()
4969 rc = put_user(C_CLOCAL(tty) ? 1 : 0, dgap_tty_ioctl()
4983 tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | dgap_tty_ioctl()
5009 * The linux tty driver doesn't have a flush dgap_tty_ioctl()
5017 rc = tty_check_change(tty); dgap_tty_ioctl()
5052 if (waitqueue_active(&tty->write_wait)) dgap_tty_ioctl()
5053 wake_up_interruptible(&tty->write_wait); dgap_tty_ioctl()
5058 tty_wakeup(tty); dgap_tty_ioctl()
5066 * The linux tty driver doesn't have a flush dgap_tty_ioctl()
5084 rc = dgap_wait_for_drain(tty); dgap_tty_ioctl()
5095 rc = dgap_wait_for_drain(tty); dgap_tty_ioctl()
5110 rc = tty_check_change(tty); dgap_tty_ioctl()
5122 dgap_tty_start(tty); dgap_tty_ioctl()
5127 dgap_tty_stop(tty); dgap_tty_ioctl()
5159 rc = dgap_wait_for_drain(tty); dgap_tty_ioctl()
5165 tty_ldisc_flush(tty); dgap_tty_ioctl()
5176 return dgap_tty_digigetedelay(tty, uarg); dgap_tty_ioctl()
5240 * Init the tty subsystem for this board.
5301 /* Register tty devices */ dgap_tty_register()
5909 if (strstr(cptr->u.ttyname, "tty")) { dgap_tty_name_show()
5921 "pr" : "tty", dgap_tty_name_show()
5934 "pr" : "tty", dgap_tty_name_show()
5951 "pr" : "tty", dgap_tty_name_show()
5962 (un->un_type == DGAP_PRINT) ? "pr" : "tty", bn, cn); dgap_tty_name_show()
6467 * Create pr and tty device entries
6746 * Init the tty subsystem. Called once per board after board has been
6867 * and general tty parameters. dgap_tty_init()
6957 * Do tty device initialization. dgap_init_one()
/linux-4.1.27/include/linux/platform_data/
H A Dserial-omap.h27 * Use tty device name as ttyO, [O -> OMAP]
/linux-4.1.27/include/uapi/linux/
H A Dtty.h5 * 'tty.h' defines some structures used by tty_io.c and some defines.
H A Disdn.h18 #include <linux/tty.h>
88 #define ISDN_LMSNLEN 255 /* Length of tty's Listen-MSN string */
/linux-4.1.27/arch/mn10300/kernel/
H A Dsys_mn10300.c22 #include <linux/tty.h>
/linux-4.1.27/arch/powerpc/include/asm/
H A Dhvsi.h73 struct tty_struct *tty; /* tty structure */ member in struct:hvsi_priv
/linux-4.1.27/drivers/net/usb/
H A Dhso.c61 #include <linux/tty.h>
315 static int hso_serial_tiocmset(struct tty_struct *tty,
1109 static void _hso_serial_set_termios(struct tty_struct *tty, _hso_serial_set_termios() argument
1112 struct hso_serial *serial = tty->driver_data; _hso_serial_set_termios()
1115 printk(KERN_ERR "%s: no tty structures", __func__); _hso_serial_set_termios()
1124 tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ _hso_serial_set_termios()
1126 tty->termios.c_cflag &= _hso_serial_set_termios()
1132 tty->termios.c_cflag |= CS8; /* character size 8 bits */ _hso_serial_set_termios()
1135 tty_encode_baud_rate(tty, 115200, 115200); _hso_serial_set_termios()
1252 static void hso_unthrottle(struct tty_struct *tty) hso_unthrottle() argument
1254 struct hso_serial *serial = tty->driver_data; hso_unthrottle()
1260 static int hso_serial_open(struct tty_struct *tty, struct file *filp) hso_serial_open() argument
1262 struct hso_serial *serial = get_serial_by_index(tty->index); hso_serial_open()
1268 tty->driver_data = NULL; hso_serial_open()
1281 tty->driver_data = serial; hso_serial_open()
1282 tty_port_tty_set(&serial->port, tty); hso_serial_open()
1289 _hso_serial_set_termios(tty, NULL); hso_serial_open()
1308 hso_serial_tiocmset(tty, TIOCM_RTS | TIOCM_DTR, 0); hso_serial_open()
1315 static void hso_serial_close(struct tty_struct *tty, struct file *filp) hso_serial_close() argument
1317 struct hso_serial *serial = tty->driver_data; hso_serial_close()
1351 static int hso_serial_write(struct tty_struct *tty, const unsigned char *buf, hso_serial_write() argument
1354 struct hso_serial *serial = tty->driver_data; hso_serial_write()
1384 static int hso_serial_write_room(struct tty_struct *tty) hso_serial_write_room() argument
1386 struct hso_serial *serial = tty->driver_data; hso_serial_write_room()
1398 static void hso_serial_cleanup(struct tty_struct *tty) hso_serial_cleanup() argument
1400 struct hso_serial *serial = tty->driver_data; hso_serial_cleanup()
1409 static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old) hso_serial_set_termios() argument
1411 struct hso_serial *serial = tty->driver_data; hso_serial_set_termios()
1416 tty->termios.c_cflag, old->c_cflag); hso_serial_set_termios()
1421 _hso_serial_set_termios(tty, old); hso_serial_set_termios()
1423 tty->termios = *old; hso_serial_set_termios()
1430 static int hso_serial_chars_in_buffer(struct tty_struct *tty) hso_serial_chars_in_buffer() argument
1432 struct hso_serial *serial = tty->driver_data; hso_serial_chars_in_buffer()
1612 static int hso_get_count(struct tty_struct *tty, hso_get_count() argument
1616 struct hso_serial *serial = tty->driver_data; hso_get_count()
1643 static int hso_serial_tiocmget(struct tty_struct *tty) hso_serial_tiocmget() argument
1646 struct hso_serial *serial = tty->driver_data; hso_serial_tiocmget()
1652 D1("no tty structures"); hso_serial_tiocmget()
1674 static int hso_serial_tiocmset(struct tty_struct *tty, hso_serial_tiocmset() argument
1680 struct hso_serial *serial = tty->driver_data; hso_serial_tiocmset()
1685 D1("no tty structures"); hso_serial_tiocmset()
1719 static int hso_serial_ioctl(struct tty_struct *tty, hso_serial_ioctl() argument
1722 struct hso_serial *serial = tty->driver_data; hso_serial_ioctl()
2021 struct tty_struct *tty; put_rxbuf_data() local
2030 tty = tty_port_tty_get(&serial->port); put_rxbuf_data()
2032 if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { put_rxbuf_data()
2033 tty_kref_put(tty); put_rxbuf_data()
2037 /* Push data to tty */ put_rxbuf_data()
2038 D1("data to push to tty"); put_rxbuf_data()
2049 tty_kref_put(tty); put_rxbuf_data()
3270 /* register the tty driver */ hso_init()
3317 /* set the major tty number (eg: insmod hso.ko tty_major=245) */
3318 MODULE_PARM_DESC(tty_major, "Set the major tty number");
/linux-4.1.27/arch/mips/rb532/
H A Dserial.c29 #include <linux/tty.h>
/linux-4.1.27/arch/mips/sgi-ip22/
H A Dip22-setup.c14 #include <linux/tty.h>
/linux-4.1.27/arch/cris/kernel/
H A Dcrisksyms.c10 #include <linux/tty.h>
/linux-4.1.27/arch/arm/mach-sa1100/
H A Dshannon.c9 #include <linux/tty.h>
H A Dhackkit.c17 #include <linux/tty.h>
25 #include <linux/tty.h>
/linux-4.1.27/arch/arm/plat-iop/
H A Di2c.c19 #include <linux/tty.h>
/linux-4.1.27/arch/arm/mach-iop33x/
H A Duart.c18 #include <linux/tty.h>
/linux-4.1.27/arch/arm/mach-ixp4xx/
H A Dgateway7001-setup.c18 #include <linux/tty.h>
H A Dwg302v2-setup.c19 #include <linux/tty.h>
/linux-4.1.27/arch/cris/arch-v10/kernel/
H A Ddebugport.c20 #include <linux/tty.h>
406 static int dummy_open(struct tty_struct *tty, struct file * filp) dummy_open() argument
411 static void dummy_close(struct tty_struct *tty, struct file * filp) dummy_close() argument
415 static int dummy_write(struct tty_struct * tty, dummy_write() argument
421 static int dummy_write_room(struct tty_struct *tty) dummy_write_room() argument
/linux-4.1.27/arch/sparc/include/uapi/asm/
H A Dioctls.h71 /* 118 is the non-posix setpgrp tty ioctl */
72 /* 119 is the non-posix getpgrp tty ioctl */

Completed in 8988 milliseconds

123