aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/serial_core.h
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2011-11-09 15:33:43 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-15 18:58:56 -0500
commit027d7dacf73273dbe07a75b2ef5579616f17272c (patch)
tree27a59e5a024cca9740a385a5c4acc27b17a909ca /include/linux/serial_core.h
parentf3706266198d3efb0fd589f34fa8471478ea364d (diff)
TTY: serial, cleanup include file
There are some functions (uart_handle_dcd_change, _handle_cts_change, _insert_char) which are big enough to not be inlined. So move them from .h to .c. We need to export them so that modules can actually use them. They will be even bigger when we introduce tty refcounting to them. While at it, cleanup the "Proud member of Uglyhacks'R'US". It means, define uart_handle_sysrq_char only when SUPPORT_SYSRQ is set. Otherwise define it as a macro. This is needed for some arm driver where the second parameter is undefined if expanded. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/serial_core.h')
-rw-r--r--include/linux/serial_core.h99
1 files changed, 12 insertions, 87 deletions
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index eadf33d0abba..945e02cae614 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -483,10 +483,19 @@ static inline int uart_tx_stopped(struct uart_port *port)
483/* 483/*
484 * The following are helper functions for the low level drivers. 484 * The following are helper functions for the low level drivers.
485 */ 485 */
486
487extern void uart_handle_dcd_change(struct uart_port *uport,
488 unsigned int status);
489extern void uart_handle_cts_change(struct uart_port *uport,
490 unsigned int status);
491
492extern void uart_insert_char(struct uart_port *port, unsigned int status,
493 unsigned int overrun, unsigned int ch, unsigned int flag);
494
495#ifdef SUPPORT_SYSRQ
486static inline int 496static inline int
487uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) 497uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
488{ 498{
489#ifdef SUPPORT_SYSRQ
490 if (port->sysrq) { 499 if (port->sysrq) {
491 if (ch && time_before(jiffies, port->sysrq)) { 500 if (ch && time_before(jiffies, port->sysrq)) {
492 handle_sysrq(ch); 501 handle_sysrq(ch);
@@ -495,11 +504,10 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
495 } 504 }
496 port->sysrq = 0; 505 port->sysrq = 0;
497 } 506 }
498#endif
499 return 0; 507 return 0;
500} 508}
501#ifndef SUPPORT_SYSRQ 509#else
502#define uart_handle_sysrq_char(port,ch) uart_handle_sysrq_char(port, 0) 510#define uart_handle_sysrq_char(port,ch) ({ (void)port; 0; })
503#endif 511#endif
504 512
505/* 513/*
@@ -522,89 +530,6 @@ static inline int uart_handle_break(struct uart_port *port)
522 return 0; 530 return 0;
523} 531}
524 532
525/**
526 * uart_handle_dcd_change - handle a change of carrier detect state
527 * @uport: uart_port structure for the open port
528 * @status: new carrier detect status, nonzero if active
529 */
530static inline void
531uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
532{
533 struct uart_state *state = uport->state;
534 struct tty_port *port = &state->port;
535 struct tty_ldisc *ld = tty_ldisc_ref(port->tty);
536 struct pps_event_time ts;
537
538 if (ld && ld->ops->dcd_change)
539 pps_get_ts(&ts);
540
541 uport->icount.dcd++;
542#ifdef CONFIG_HARD_PPS
543 if ((uport->flags & UPF_HARDPPS_CD) && status)
544 hardpps();
545#endif
546
547 if (port->flags & ASYNC_CHECK_CD) {
548 if (status)
549 wake_up_interruptible(&port->open_wait);
550 else if (port->tty)
551 tty_hangup(port->tty);
552 }
553
554 if (ld && ld->ops->dcd_change)
555 ld->ops->dcd_change(port->tty, status, &ts);
556 if (ld)
557 tty_ldisc_deref(ld);
558}
559
560/**
561 * uart_handle_cts_change - handle a change of clear-to-send state
562 * @uport: uart_port structure for the open port
563 * @status: new clear to send status, nonzero if active
564 */
565static inline void
566uart_handle_cts_change(struct uart_port *uport, unsigned int status)
567{
568 struct tty_port *port = &uport->state->port;
569 struct tty_struct *tty = port->tty;
570
571 uport->icount.cts++;
572
573 if (port->flags & ASYNC_CTS_FLOW) {
574 if (tty->hw_stopped) {
575 if (status) {
576 tty->hw_stopped = 0;
577 uport->ops->start_tx(uport);
578 uart_write_wakeup(uport);
579 }
580 } else {
581 if (!status) {
582 tty->hw_stopped = 1;
583 uport->ops->stop_tx(uport);
584 }
585 }
586 }
587}
588
589#include <linux/tty_flip.h>
590
591static inline void
592uart_insert_char(struct uart_port *port, unsigned int status,
593 unsigned int overrun, unsigned int ch, unsigned int flag)
594{
595 struct tty_struct *tty = port->state->port.tty;
596
597 if ((status & port->ignore_status_mask & ~overrun) == 0)
598 tty_insert_flip_char(tty, ch, flag);
599
600 /*
601 * Overrun is special. Since it's reported immediately,
602 * it doesn't affect the current character.
603 */
604 if (status & ~port->ignore_status_mask & overrun)
605 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
606}
607
608/* 533/*
609 * UART_ENABLE_MS - determine if port should enable modem status irqs 534 * UART_ENABLE_MS - determine if port should enable modem status irqs
610 */ 535 */