aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2014-10-16 16:54:21 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-05 21:53:54 -0500
commit904326ecac022ebaeb39cdfb206fd3b6551cdfca (patch)
treebd1a7fffee63994925c233dfc3409bfc68566467 /include
parent7c8ab967e3cd1513cd79fd5edc404fb43c7f3a96 (diff)
tty,serial: Unify UPF_* and ASYNC_* flag definitions
The userspace-defined ASYNC_* flags in include/uapi/linux/tty_flags.h are the authoritative bit definitions for the serial_struct flags, and thus for any derivative values or fields. Although the serial core provides the TIOCSSERIAL and TIOCGSERIAL ioctls to set and retrieve these flags from userspace, it defines these bits independently, as UPF_* macros. Define the UPF_* macros which are userspace-modifiable directly from the ASYNC_* symbolic constants. Add compile-time test to ensure the bits changeable by TIOCSSERIAL match the defined range in the uapi header. Add ASYNCB_MAGIC_MULTIPLIER to the uapi header since this bit is programmable by userspace. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/serial_core.h47
-rw-r--r--include/uapi/linux/tty_flags.h6
2 files changed, 37 insertions, 16 deletions
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index bccf4bac22f5..ad9329669aba 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -160,21 +160,33 @@ struct uart_port {
160 /* flags must be updated while holding port mutex */ 160 /* flags must be updated while holding port mutex */
161 upf_t flags; 161 upf_t flags;
162 162
163#define UPF_FOURPORT ((__force upf_t) (1 << 1)) 163 /*
164#define UPF_SAK ((__force upf_t) (1 << 2)) 164 * These flags must be equivalent to the flags defined in
165#define UPF_SPD_MASK ((__force upf_t) (0x1030)) 165 * include/uapi/linux/tty_flags.h which are the userspace definitions
166#define UPF_SPD_HI ((__force upf_t) (0x0010)) 166 * assigned from the serial_struct flags in uart_set_info()
167#define UPF_SPD_VHI ((__force upf_t) (0x0020)) 167 * [for bit definitions in the UPF_CHANGE_MASK]
168#define UPF_SPD_CUST ((__force upf_t) (0x0030)) 168 *
169#define UPF_SPD_SHI ((__force upf_t) (0x1000)) 169 * Bits [0..UPF_LAST_USER] are userspace defined/visible/changeable
170#define UPF_SPD_WARP ((__force upf_t) (0x1010)) 170 * except bit 15 (UPF_NO_TXEN_TEST) which is masked off.
171#define UPF_SKIP_TEST ((__force upf_t) (1 << 6)) 171 * The remaining bits are serial-core specific and not modifiable by
172#define UPF_AUTO_IRQ ((__force upf_t) (1 << 7)) 172 * userspace.
173#define UPF_HARDPPS_CD ((__force upf_t) (1 << 11)) 173 */
174#define UPF_LOW_LATENCY ((__force upf_t) (1 << 13)) 174#define UPF_FOURPORT ((__force upf_t) ASYNC_FOURPORT /* 1 */ )
175#define UPF_BUGGY_UART ((__force upf_t) (1 << 14)) 175#define UPF_SAK ((__force upf_t) ASYNC_SAK /* 2 */ )
176#define UPF_SPD_HI ((__force upf_t) ASYNC_SPD_HI /* 4 */ )
177#define UPF_SPD_VHI ((__force upf_t) ASYNC_SPD_VHI /* 5 */ )
178#define UPF_SPD_CUST ((__force upf_t) ASYNC_SPD_CUST /* 0x0030 */ )
179#define UPF_SPD_WARP ((__force upf_t) ASYNC_SPD_WARP /* 0x1010 */ )
180#define UPF_SPD_MASK ((__force upf_t) ASYNC_SPD_MASK /* 0x1030 */ )
181#define UPF_SKIP_TEST ((__force upf_t) ASYNC_SKIP_TEST /* 6 */ )
182#define UPF_AUTO_IRQ ((__force upf_t) ASYNC_AUTO_IRQ /* 7 */ )
183#define UPF_HARDPPS_CD ((__force upf_t) ASYNC_HARDPPS_CD /* 11 */ )
184#define UPF_SPD_SHI ((__force upf_t) ASYNC_SPD_SHI /* 12 */ )
185#define UPF_LOW_LATENCY ((__force upf_t) ASYNC_LOW_LATENCY /* 13 */ )
186#define UPF_BUGGY_UART ((__force upf_t) ASYNC_BUGGY_UART /* 14 */ )
176#define UPF_NO_TXEN_TEST ((__force upf_t) (1 << 15)) 187#define UPF_NO_TXEN_TEST ((__force upf_t) (1 << 15))
177#define UPF_MAGIC_MULTIPLIER ((__force upf_t) (1 << 16)) 188#define UPF_MAGIC_MULTIPLIER ((__force upf_t) ASYNC_MAGIC_MULTIPLIER /* 16 */ )
189
178/* Port has hardware-assisted h/w flow control (iow, auto-RTS *not* auto-CTS) */ 190/* Port has hardware-assisted h/w flow control (iow, auto-RTS *not* auto-CTS) */
179#define UPF_HARD_FLOW ((__force upf_t) (1 << 21)) 191#define UPF_HARD_FLOW ((__force upf_t) (1 << 21))
180/* Port has hardware-assisted s/w flow control */ 192/* Port has hardware-assisted s/w flow control */
@@ -190,9 +202,14 @@ struct uart_port {
190#define UPF_DEAD ((__force upf_t) (1 << 30)) 202#define UPF_DEAD ((__force upf_t) (1 << 30))
191#define UPF_IOREMAP ((__force upf_t) (1 << 31)) 203#define UPF_IOREMAP ((__force upf_t) (1 << 31))
192 204
193#define UPF_CHANGE_MASK ((__force upf_t) (0x17fff)) 205#define __UPF_CHANGE_MASK 0x17fff
206#define UPF_CHANGE_MASK ((__force upf_t) __UPF_CHANGE_MASK)
194#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY)) 207#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))
195 208
209#if __UPF_CHANGE_MASK > ASYNC_FLAGS
210#error Change mask not equivalent to userspace-visible bit defines
211#endif
212
196 /* status must be updated while holding port lock */ 213 /* status must be updated while holding port lock */
197 upstat_t status; 214 upstat_t status;
198 215
diff --git a/include/uapi/linux/tty_flags.h b/include/uapi/linux/tty_flags.h
index eefcb483a2c0..7b516f7ee7e6 100644
--- a/include/uapi/linux/tty_flags.h
+++ b/include/uapi/linux/tty_flags.h
@@ -6,6 +6,8 @@
6 * shared by the tty_port flags structures. 6 * shared by the tty_port flags structures.
7 * 7 *
8 * Define ASYNCB_* for convenient use with {test,set,clear}_bit. 8 * Define ASYNCB_* for convenient use with {test,set,clear}_bit.
9 *
10 * Bits [0..ASYNCB_LAST_USER] are userspace defined/visible/changeable
9 */ 11 */
10#define ASYNCB_HUP_NOTIFY 0 /* Notify getty on hangups and closes 12#define ASYNCB_HUP_NOTIFY 0 /* Notify getty on hangups and closes
11 * on the callout port */ 13 * on the callout port */
@@ -26,7 +28,8 @@
26#define ASYNCB_BUGGY_UART 14 /* This is a buggy UART, skip some safety 28#define ASYNCB_BUGGY_UART 14 /* This is a buggy UART, skip some safety
27 * checks. Note: can be dangerous! */ 29 * checks. Note: can be dangerous! */
28#define ASYNCB_AUTOPROBE 15 /* Port was autoprobed by PCI or PNP code */ 30#define ASYNCB_AUTOPROBE 15 /* Port was autoprobed by PCI or PNP code */
29#define ASYNCB_LAST_USER 15 31#define ASYNCB_MAGIC_MULTIPLIER 16 /* Use special CLK or divisor */
32#define ASYNCB_LAST_USER 16
30 33
31/* Internal flags used only by kernel */ 34/* Internal flags used only by kernel */
32#define ASYNCB_INITIALIZED 31 /* Serial port was initialized */ 35#define ASYNCB_INITIALIZED 31 /* Serial port was initialized */
@@ -57,6 +60,7 @@
57#define ASYNC_LOW_LATENCY (1U << ASYNCB_LOW_LATENCY) 60#define ASYNC_LOW_LATENCY (1U << ASYNCB_LOW_LATENCY)
58#define ASYNC_BUGGY_UART (1U << ASYNCB_BUGGY_UART) 61#define ASYNC_BUGGY_UART (1U << ASYNCB_BUGGY_UART)
59#define ASYNC_AUTOPROBE (1U << ASYNCB_AUTOPROBE) 62#define ASYNC_AUTOPROBE (1U << ASYNCB_AUTOPROBE)
63#define ASYNC_MAGIC_MULTIPLIER (1U << ASYNCB_MAGIC_MULTIPLIER)
60 64
61#define ASYNC_FLAGS ((1U << (ASYNCB_LAST_USER + 1)) - 1) 65#define ASYNC_FLAGS ((1U << (ASYNCB_LAST_USER + 1)) - 1)
62#define ASYNC_USR_MASK (ASYNC_SPD_MASK|ASYNC_CALLOUT_NOHUP| \ 66#define ASYNC_USR_MASK (ASYNC_SPD_MASK|ASYNC_CALLOUT_NOHUP| \