aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2014-09-10 15:06:23 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-24 00:19:34 -0400
commit4d90bb147ef6b91f529a21b498ff2b5fdc6785b4 (patch)
treeb6ae1e41260d1591aeabc56bb54969ffb4061729 /drivers/tty
parent9a37110d20c95d1ebf6c04881177fe8f62831db2 (diff)
serial: core: Document and assert lock requirements for irq helpers
The serial core provides two helper functions, uart_handle_dcd_change() and uart_handle_cts_change(), for UART drivers to use at interrupt time. The serial core expects the UART driver to hold the uart port lock when calling these helpers to prevent state corruption. If lockdep enabled, trigger a warning if the uart port lock is not held when calling these helper functions. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/serial_core.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 5a78f6940760..f764de32b658 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2743,6 +2743,8 @@ EXPORT_SYMBOL(uart_match_port);
2743 * uart_handle_dcd_change - handle a change of carrier detect state 2743 * uart_handle_dcd_change - handle a change of carrier detect state
2744 * @uport: uart_port structure for the open port 2744 * @uport: uart_port structure for the open port
2745 * @status: new carrier detect status, nonzero if active 2745 * @status: new carrier detect status, nonzero if active
2746 *
2747 * Caller must hold uport->lock
2746 */ 2748 */
2747void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) 2749void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
2748{ 2750{
@@ -2750,6 +2752,8 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
2750 struct tty_struct *tty = port->tty; 2752 struct tty_struct *tty = port->tty;
2751 struct tty_ldisc *ld; 2753 struct tty_ldisc *ld;
2752 2754
2755 lockdep_assert_held_once(&uport->lock);
2756
2753 if (tty) { 2757 if (tty) {
2754 ld = tty_ldisc_ref(tty); 2758 ld = tty_ldisc_ref(tty);
2755 if (ld) { 2759 if (ld) {
@@ -2774,12 +2778,16 @@ EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
2774 * uart_handle_cts_change - handle a change of clear-to-send state 2778 * uart_handle_cts_change - handle a change of clear-to-send state
2775 * @uport: uart_port structure for the open port 2779 * @uport: uart_port structure for the open port
2776 * @status: new clear to send status, nonzero if active 2780 * @status: new clear to send status, nonzero if active
2781 *
2782 * Caller must hold uport->lock
2777 */ 2783 */
2778void uart_handle_cts_change(struct uart_port *uport, unsigned int status) 2784void uart_handle_cts_change(struct uart_port *uport, unsigned int status)
2779{ 2785{
2780 struct tty_port *port = &uport->state->port; 2786 struct tty_port *port = &uport->state->port;
2781 struct tty_struct *tty = port->tty; 2787 struct tty_struct *tty = port->tty;
2782 2788
2789 lockdep_assert_held_once(&uport->lock);
2790
2783 uport->icount.cts++; 2791 uport->icount.cts++;
2784 2792
2785 if (tty_port_cts_enabled(port)) { 2793 if (tty_port_cts_enabled(port)) {