aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
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 /drivers/tty
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 'drivers/tty')
-rw-r--r--drivers/tty/serial/serial_core.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 0406d7ff505..8d825a36c84 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -22,6 +22,7 @@
22 */ 22 */
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/tty.h> 24#include <linux/tty.h>
25#include <linux/tty_flip.h>
25#include <linux/slab.h> 26#include <linux/slab.h>
26#include <linux/init.h> 27#include <linux/init.h>
27#include <linux/console.h> 28#include <linux/console.h>
@@ -2467,6 +2468,87 @@ int uart_match_port(struct uart_port *port1, struct uart_port *port2)
2467} 2468}
2468EXPORT_SYMBOL(uart_match_port); 2469EXPORT_SYMBOL(uart_match_port);
2469 2470
2471/**
2472 * uart_handle_dcd_change - handle a change of carrier detect state
2473 * @uport: uart_port structure for the open port
2474 * @status: new carrier detect status, nonzero if active
2475 */
2476void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
2477{
2478 struct uart_state *state = uport->state;
2479 struct tty_port *port = &state->port;
2480 struct tty_ldisc *ld = tty_ldisc_ref(port->tty);
2481 struct pps_event_time ts;
2482
2483 if (ld && ld->ops->dcd_change)
2484 pps_get_ts(&ts);
2485
2486 uport->icount.dcd++;
2487#ifdef CONFIG_HARD_PPS
2488 if ((uport->flags & UPF_HARDPPS_CD) && status)
2489 hardpps();
2490#endif
2491
2492 if (port->flags & ASYNC_CHECK_CD) {
2493 if (status)
2494 wake_up_interruptible(&port->open_wait);
2495 else if (port->tty)
2496 tty_hangup(port->tty);
2497 }
2498
2499 if (ld && ld->ops->dcd_change)
2500 ld->ops->dcd_change(port->tty, status, &ts);
2501 if (ld)
2502 tty_ldisc_deref(ld);
2503}
2504EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
2505
2506/**
2507 * uart_handle_cts_change - handle a change of clear-to-send state
2508 * @uport: uart_port structure for the open port
2509 * @status: new clear to send status, nonzero if active
2510 */
2511void uart_handle_cts_change(struct uart_port *uport, unsigned int status)
2512{
2513 struct tty_port *port = &uport->state->port;
2514 struct tty_struct *tty = port->tty;
2515
2516 uport->icount.cts++;
2517
2518 if (port->flags & ASYNC_CTS_FLOW) {
2519 if (tty->hw_stopped) {
2520 if (status) {
2521 tty->hw_stopped = 0;
2522 uport->ops->start_tx(uport);
2523 uart_write_wakeup(uport);
2524 }
2525 } else {
2526 if (!status) {
2527 tty->hw_stopped = 1;
2528 uport->ops->stop_tx(uport);
2529 }
2530 }
2531 }
2532}
2533EXPORT_SYMBOL_GPL(uart_handle_cts_change);
2534
2535void uart_insert_char(struct uart_port *port, unsigned int status,
2536 unsigned int overrun, unsigned int ch, unsigned int flag)
2537{
2538 struct tty_struct *tty = port->state->port.tty;
2539
2540 if ((status & port->ignore_status_mask & ~overrun) == 0)
2541 tty_insert_flip_char(tty, ch, flag);
2542
2543 /*
2544 * Overrun is special. Since it's reported immediately,
2545 * it doesn't affect the current character.
2546 */
2547 if (status & ~port->ignore_status_mask & overrun)
2548 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
2549}
2550EXPORT_SYMBOL_GPL(uart_insert_char);
2551
2470EXPORT_SYMBOL(uart_write_wakeup); 2552EXPORT_SYMBOL(uart_write_wakeup);
2471EXPORT_SYMBOL(uart_register_driver); 2553EXPORT_SYMBOL(uart_register_driver);
2472EXPORT_SYMBOL(uart_unregister_driver); 2554EXPORT_SYMBOL(uart_unregister_driver);