Commit 904326ec authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman

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: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7c8ab967
...@@ -160,21 +160,33 @@ struct uart_port { ...@@ -160,21 +160,33 @@ struct uart_port {
/* flags must be updated while holding port mutex */ /* flags must be updated while holding port mutex */
upf_t flags; upf_t flags;
#define UPF_FOURPORT ((__force upf_t) (1 << 1)) /*
#define UPF_SAK ((__force upf_t) (1 << 2)) * These flags must be equivalent to the flags defined in
#define UPF_SPD_MASK ((__force upf_t) (0x1030)) * include/uapi/linux/tty_flags.h which are the userspace definitions
#define UPF_SPD_HI ((__force upf_t) (0x0010)) * assigned from the serial_struct flags in uart_set_info()
#define UPF_SPD_VHI ((__force upf_t) (0x0020)) * [for bit definitions in the UPF_CHANGE_MASK]
#define UPF_SPD_CUST ((__force upf_t) (0x0030)) *
#define UPF_SPD_SHI ((__force upf_t) (0x1000)) * Bits [0..UPF_LAST_USER] are userspace defined/visible/changeable
#define UPF_SPD_WARP ((__force upf_t) (0x1010)) * except bit 15 (UPF_NO_TXEN_TEST) which is masked off.
#define UPF_SKIP_TEST ((__force upf_t) (1 << 6)) * The remaining bits are serial-core specific and not modifiable by
#define UPF_AUTO_IRQ ((__force upf_t) (1 << 7)) * userspace.
#define UPF_HARDPPS_CD ((__force upf_t) (1 << 11)) */
#define UPF_LOW_LATENCY ((__force upf_t) (1 << 13)) #define UPF_FOURPORT ((__force upf_t) ASYNC_FOURPORT /* 1 */ )
#define UPF_BUGGY_UART ((__force upf_t) (1 << 14)) #define UPF_SAK ((__force upf_t) ASYNC_SAK /* 2 */ )
#define UPF_SPD_HI ((__force upf_t) ASYNC_SPD_HI /* 4 */ )
#define UPF_SPD_VHI ((__force upf_t) ASYNC_SPD_VHI /* 5 */ )
#define UPF_SPD_CUST ((__force upf_t) ASYNC_SPD_CUST /* 0x0030 */ )
#define UPF_SPD_WARP ((__force upf_t) ASYNC_SPD_WARP /* 0x1010 */ )
#define UPF_SPD_MASK ((__force upf_t) ASYNC_SPD_MASK /* 0x1030 */ )
#define UPF_SKIP_TEST ((__force upf_t) ASYNC_SKIP_TEST /* 6 */ )
#define UPF_AUTO_IRQ ((__force upf_t) ASYNC_AUTO_IRQ /* 7 */ )
#define UPF_HARDPPS_CD ((__force upf_t) ASYNC_HARDPPS_CD /* 11 */ )
#define UPF_SPD_SHI ((__force upf_t) ASYNC_SPD_SHI /* 12 */ )
#define UPF_LOW_LATENCY ((__force upf_t) ASYNC_LOW_LATENCY /* 13 */ )
#define UPF_BUGGY_UART ((__force upf_t) ASYNC_BUGGY_UART /* 14 */ )
#define UPF_NO_TXEN_TEST ((__force upf_t) (1 << 15)) #define UPF_NO_TXEN_TEST ((__force upf_t) (1 << 15))
#define UPF_MAGIC_MULTIPLIER ((__force upf_t) (1 << 16)) #define UPF_MAGIC_MULTIPLIER ((__force upf_t) ASYNC_MAGIC_MULTIPLIER /* 16 */ )
/* Port has hardware-assisted h/w flow control (iow, auto-RTS *not* auto-CTS) */ /* Port has hardware-assisted h/w flow control (iow, auto-RTS *not* auto-CTS) */
#define UPF_HARD_FLOW ((__force upf_t) (1 << 21)) #define UPF_HARD_FLOW ((__force upf_t) (1 << 21))
/* Port has hardware-assisted s/w flow control */ /* Port has hardware-assisted s/w flow control */
...@@ -190,9 +202,14 @@ struct uart_port { ...@@ -190,9 +202,14 @@ struct uart_port {
#define UPF_DEAD ((__force upf_t) (1 << 30)) #define UPF_DEAD ((__force upf_t) (1 << 30))
#define UPF_IOREMAP ((__force upf_t) (1 << 31)) #define UPF_IOREMAP ((__force upf_t) (1 << 31))
#define UPF_CHANGE_MASK ((__force upf_t) (0x17fff)) #define __UPF_CHANGE_MASK 0x17fff
#define UPF_CHANGE_MASK ((__force upf_t) __UPF_CHANGE_MASK)
#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY)) #define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))
#if __UPF_CHANGE_MASK > ASYNC_FLAGS
#error Change mask not equivalent to userspace-visible bit defines
#endif
/* status must be updated while holding port lock */ /* status must be updated while holding port lock */
upstat_t status; upstat_t status;
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
* shared by the tty_port flags structures. * shared by the tty_port flags structures.
* *
* Define ASYNCB_* for convenient use with {test,set,clear}_bit. * Define ASYNCB_* for convenient use with {test,set,clear}_bit.
*
* Bits [0..ASYNCB_LAST_USER] are userspace defined/visible/changeable
*/ */
#define ASYNCB_HUP_NOTIFY 0 /* Notify getty on hangups and closes #define ASYNCB_HUP_NOTIFY 0 /* Notify getty on hangups and closes
* on the callout port */ * on the callout port */
...@@ -26,7 +28,8 @@ ...@@ -26,7 +28,8 @@
#define ASYNCB_BUGGY_UART 14 /* This is a buggy UART, skip some safety #define ASYNCB_BUGGY_UART 14 /* This is a buggy UART, skip some safety
* checks. Note: can be dangerous! */ * checks. Note: can be dangerous! */
#define ASYNCB_AUTOPROBE 15 /* Port was autoprobed by PCI or PNP code */ #define ASYNCB_AUTOPROBE 15 /* Port was autoprobed by PCI or PNP code */
#define ASYNCB_LAST_USER 15 #define ASYNCB_MAGIC_MULTIPLIER 16 /* Use special CLK or divisor */
#define ASYNCB_LAST_USER 16
/* Internal flags used only by kernel */ /* Internal flags used only by kernel */
#define ASYNCB_INITIALIZED 31 /* Serial port was initialized */ #define ASYNCB_INITIALIZED 31 /* Serial port was initialized */
...@@ -57,6 +60,7 @@ ...@@ -57,6 +60,7 @@
#define ASYNC_LOW_LATENCY (1U << ASYNCB_LOW_LATENCY) #define ASYNC_LOW_LATENCY (1U << ASYNCB_LOW_LATENCY)
#define ASYNC_BUGGY_UART (1U << ASYNCB_BUGGY_UART) #define ASYNC_BUGGY_UART (1U << ASYNCB_BUGGY_UART)
#define ASYNC_AUTOPROBE (1U << ASYNCB_AUTOPROBE) #define ASYNC_AUTOPROBE (1U << ASYNCB_AUTOPROBE)
#define ASYNC_MAGIC_MULTIPLIER (1U << ASYNCB_MAGIC_MULTIPLIER)
#define ASYNC_FLAGS ((1U << (ASYNCB_LAST_USER + 1)) - 1) #define ASYNC_FLAGS ((1U << (ASYNCB_LAST_USER + 1)) - 1)
#define ASYNC_USR_MASK (ASYNC_SPD_MASK|ASYNC_CALLOUT_NOHUP| \ #define ASYNC_USR_MASK (ASYNC_SPD_MASK|ASYNC_CALLOUT_NOHUP| \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment