aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/serial_core.h
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2014-09-10 15:06:24 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-23 21:19:35 -0700
commit299245a145b2ad4cfb4c5432eb1264299f55e7e0 (patch)
tree53eb54bc7cf744f3813c34c79769529d0df6c223 /include/linux/serial_core.h
parentserial: core: Document and assert lock requirements for irq helpers (diff)
downloadlinux-dev-299245a145b2ad4cfb4c5432eb1264299f55e7e0.tar.xz
linux-dev-299245a145b2ad4cfb4c5432eb1264299f55e7e0.zip
serial: core: Privatize modem status enable flags
The serial core uses the tty port flags, ASYNC_CTS_FLOW and ASYNC_CD_CHECK, to track whether CTS and DCD changes should be ignored or handled. However, the tty port flags are not safe for atomic bit operations and no lock provides serialized updates. Introduce the struct uart_port status field to track CTS and DCD enable states, and serialize access with uart port lock. Substitute uart_cts_enabled() helper for tty_port_cts_enabled(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/serial_core.h')
-rw-r--r--include/linux/serial_core.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 3bd7d55eebce..452c9cc9d717 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -112,6 +112,7 @@ struct uart_icount {
};
typedef unsigned int __bitwise__ upf_t;
+typedef unsigned int __bitwise__ upstat_t;
struct uart_port {
spinlock_t lock; /* port lock */
@@ -190,6 +191,12 @@ struct uart_port {
#define UPF_CHANGE_MASK ((__force upf_t) (0x17fff))
#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))
+ /* status must be updated while holding port lock */
+ upstat_t status;
+
+#define UPSTAT_CTS_ENABLE ((__force upstat_t) (1 << 0))
+#define UPSTAT_DCD_ENABLE ((__force upstat_t) (1 << 1))
+
unsigned int mctrl; /* current modem ctrl settings */
unsigned int timeout; /* character-based timeout */
unsigned int type; /* port type */
@@ -355,6 +362,11 @@ static inline int uart_tx_stopped(struct uart_port *port)
return 0;
}
+static inline bool uart_cts_enabled(struct uart_port *uport)
+{
+ return uport->status & UPSTAT_CTS_ENABLE;
+}
+
/*
* The following are helper functions for the low level drivers.
*/