Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SERIAL] Make uart_port flags a bitwise type

Same reasoning as commit 747c8a55946ed037bf7d62454c3c599c02af2262
but this time we're making uart_port flags a bitwise type - not
all of these flags correspond with the old ASYNC_ flags, so there
is the possibility for bugs if the wrong ASYNC_* constants are
used. Always use UPF_* constants for uart_port->flags.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Russell King and committed by
Russell King
0077d45e 27ae7a74

+31 -27
+7 -5
drivers/serial/serial_core.c
··· 332 332 struct termios *old, unsigned int min, unsigned int max) 333 333 { 334 334 unsigned int try, baud, altbaud = 38400; 335 - unsigned int flags = port->flags & UPF_SPD_MASK; 335 + upf_t flags = port->flags & UPF_SPD_MASK; 336 336 337 337 if (flags == UPF_SPD_HI) 338 338 altbaud = 57600; ··· 615 615 struct serial_struct new_serial; 616 616 struct uart_port *port = state->port; 617 617 unsigned long new_port; 618 - unsigned int change_irq, change_port, old_flags, closing_wait; 618 + unsigned int change_irq, change_port, closing_wait; 619 619 unsigned int old_custom_divisor, close_delay; 620 + upf_t old_flags, new_flags; 620 621 int retval = 0; 621 622 622 623 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) ··· 656 655 new_serial.type != port->type; 657 656 658 657 old_flags = port->flags; 658 + new_flags = new_serial.flags; 659 659 old_custom_divisor = port->custom_divisor; 660 660 661 661 if (!capable(CAP_SYS_ADMIN)) { ··· 666 664 (close_delay != state->close_delay) || 667 665 (closing_wait != state->closing_wait) || 668 666 (new_serial.xmit_fifo_size != port->fifosize) || 669 - (((new_serial.flags ^ old_flags) & ~UPF_USR_MASK) != 0)) 667 + (((new_flags ^ old_flags) & ~UPF_USR_MASK) != 0)) 670 668 goto exit; 671 669 port->flags = ((port->flags & ~UPF_USR_MASK) | 672 - (new_serial.flags & UPF_USR_MASK)); 670 + (new_flags & UPF_USR_MASK)); 673 671 port->custom_divisor = new_serial.custom_divisor; 674 672 goto check_and_exit; 675 673 } ··· 766 764 port->irq = new_serial.irq; 767 765 port->uartclk = new_serial.baud_base * 16; 768 766 port->flags = (port->flags & ~UPF_CHANGE_MASK) | 769 - (new_serial.flags & UPF_CHANGE_MASK); 767 + (new_flags & UPF_CHANGE_MASK); 770 768 port->custom_divisor = new_serial.custom_divisor; 771 769 state->close_delay = close_delay; 772 770 state->closing_wait = closing_wait;
+1 -1
include/linux/serial_8250.h
··· 26 26 unsigned char regshift; /* register shift */ 27 27 unsigned char iotype; /* UPIO_* */ 28 28 unsigned char hub6; 29 - unsigned int flags; /* UPF_* flags */ 29 + upf_t flags; /* UPF_* flags */ 30 30 }; 31 31 32 32 /*
+23 -21
include/linux/serial_core.h
··· 203 203 __u32 buf_overrun; 204 204 }; 205 205 206 + typedef unsigned int __bitwise__ upf_t; 207 + 206 208 struct uart_port { 207 209 spinlock_t lock; /* port lock */ 208 210 unsigned int iobase; /* in/out[bwl] */ ··· 232 230 unsigned long sysrq; /* sysrq timeout */ 233 231 #endif 234 232 235 - unsigned int flags; 233 + upf_t flags; 236 234 237 - #define UPF_FOURPORT (1 << 1) 238 - #define UPF_SAK (1 << 2) 239 - #define UPF_SPD_MASK (0x1030) 240 - #define UPF_SPD_HI (0x0010) 241 - #define UPF_SPD_VHI (0x0020) 242 - #define UPF_SPD_CUST (0x0030) 243 - #define UPF_SPD_SHI (0x1000) 244 - #define UPF_SPD_WARP (0x1010) 245 - #define UPF_SKIP_TEST (1 << 6) 246 - #define UPF_AUTO_IRQ (1 << 7) 247 - #define UPF_HARDPPS_CD (1 << 11) 248 - #define UPF_LOW_LATENCY (1 << 13) 249 - #define UPF_BUGGY_UART (1 << 14) 250 - #define UPF_MAGIC_MULTIPLIER (1 << 16) 251 - #define UPF_CONS_FLOW (1 << 23) 252 - #define UPF_SHARE_IRQ (1 << 24) 253 - #define UPF_BOOT_AUTOCONF (1 << 28) 254 - #define UPF_IOREMAP (1 << 31) 235 + #define UPF_FOURPORT ((__force upf_t) (1 << 1)) 236 + #define UPF_SAK ((__force upf_t) (1 << 2)) 237 + #define UPF_SPD_MASK ((__force upf_t) (0x1030)) 238 + #define UPF_SPD_HI ((__force upf_t) (0x0010)) 239 + #define UPF_SPD_VHI ((__force upf_t) (0x0020)) 240 + #define UPF_SPD_CUST ((__force upf_t) (0x0030)) 241 + #define UPF_SPD_SHI ((__force upf_t) (0x1000)) 242 + #define UPF_SPD_WARP ((__force upf_t) (0x1010)) 243 + #define UPF_SKIP_TEST ((__force upf_t) (1 << 6)) 244 + #define UPF_AUTO_IRQ ((__force upf_t) (1 << 7)) 245 + #define UPF_HARDPPS_CD ((__force upf_t) (1 << 11)) 246 + #define UPF_LOW_LATENCY ((__force upf_t) (1 << 13)) 247 + #define UPF_BUGGY_UART ((__force upf_t) (1 << 14)) 248 + #define UPF_MAGIC_MULTIPLIER ((__force upf_t) (1 << 16)) 249 + #define UPF_CONS_FLOW ((__force upf_t) (1 << 23)) 250 + #define UPF_SHARE_IRQ ((__force upf_t) (1 << 24)) 251 + #define UPF_BOOT_AUTOCONF ((__force upf_t) (1 << 28)) 252 + #define UPF_IOREMAP ((__force upf_t) (1 << 31)) 255 253 256 - #define UPF_CHANGE_MASK (0x17fff) 257 - #define UPF_USR_MASK (UPF_SPD_MASK|UPF_LOW_LATENCY) 254 + #define UPF_CHANGE_MASK ((__force upf_t) (0x17fff)) 255 + #define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY)) 258 256 259 257 unsigned int mctrl; /* current modem ctrl settings */ 260 258 unsigned int timeout; /* character-based timeout */