aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2006-01-21 18:03:28 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-01-21 18:03:28 -0500
commit0077d45e46fe2af3aaee5813c99268afcd0e7c0e (patch)
tree3de13b52930e350f93523fb3c84c0b8fb4a7e7fb
parent27ae7a7435634820e7f7e2b922d8119f79cfc6e4 (diff)
[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>
-rw-r--r--drivers/serial/serial_core.c12
-rw-r--r--include/linux/serial_8250.h2
-rw-r--r--include/linux/serial_core.h48
3 files changed, 33 insertions, 29 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 74142b731527..0717abfdae06 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -332,7 +332,7 @@ uart_get_baud_rate(struct uart_port *port, struct termios *termios,
332 struct termios *old, unsigned int min, unsigned int max) 332 struct termios *old, unsigned int min, unsigned int max)
333{ 333{
334 unsigned int try, baud, altbaud = 38400; 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 if (flags == UPF_SPD_HI) 337 if (flags == UPF_SPD_HI)
338 altbaud = 57600; 338 altbaud = 57600;
@@ -615,8 +615,9 @@ static int uart_set_info(struct uart_state *state,
615 struct serial_struct new_serial; 615 struct serial_struct new_serial;
616 struct uart_port *port = state->port; 616 struct uart_port *port = state->port;
617 unsigned long new_port; 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 unsigned int old_custom_divisor, close_delay; 619 unsigned int old_custom_divisor, close_delay;
620 upf_t old_flags, new_flags;
620 int retval = 0; 621 int retval = 0;
621 622
622 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) 623 if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
@@ -655,6 +656,7 @@ static int uart_set_info(struct uart_state *state,
655 new_serial.type != port->type; 656 new_serial.type != port->type;
656 657
657 old_flags = port->flags; 658 old_flags = port->flags;
659 new_flags = new_serial.flags;
658 old_custom_divisor = port->custom_divisor; 660 old_custom_divisor = port->custom_divisor;
659 661
660 if (!capable(CAP_SYS_ADMIN)) { 662 if (!capable(CAP_SYS_ADMIN)) {
@@ -664,10 +666,10 @@ static int uart_set_info(struct uart_state *state,
664 (close_delay != state->close_delay) || 666 (close_delay != state->close_delay) ||
665 (closing_wait != state->closing_wait) || 667 (closing_wait != state->closing_wait) ||
666 (new_serial.xmit_fifo_size != port->fifosize) || 668 (new_serial.xmit_fifo_size != port->fifosize) ||
667 (((new_serial.flags ^ old_flags) & ~UPF_USR_MASK) != 0)) 669 (((new_flags ^ old_flags) & ~UPF_USR_MASK) != 0))
668 goto exit; 670 goto exit;
669 port->flags = ((port->flags & ~UPF_USR_MASK) | 671 port->flags = ((port->flags & ~UPF_USR_MASK) |
670 (new_serial.flags & UPF_USR_MASK)); 672 (new_flags & UPF_USR_MASK));
671 port->custom_divisor = new_serial.custom_divisor; 673 port->custom_divisor = new_serial.custom_divisor;
672 goto check_and_exit; 674 goto check_and_exit;
673 } 675 }
@@ -764,7 +766,7 @@ static int uart_set_info(struct uart_state *state,
764 port->irq = new_serial.irq; 766 port->irq = new_serial.irq;
765 port->uartclk = new_serial.baud_base * 16; 767 port->uartclk = new_serial.baud_base * 16;
766 port->flags = (port->flags & ~UPF_CHANGE_MASK) | 768 port->flags = (port->flags & ~UPF_CHANGE_MASK) |
767 (new_serial.flags & UPF_CHANGE_MASK); 769 (new_flags & UPF_CHANGE_MASK);
768 port->custom_divisor = new_serial.custom_divisor; 770 port->custom_divisor = new_serial.custom_divisor;
769 state->close_delay = close_delay; 771 state->close_delay = close_delay;
770 state->closing_wait = closing_wait; 772 state->closing_wait = closing_wait;
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index cee302aefdb7..73b464f0926a 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -26,7 +26,7 @@ struct plat_serial8250_port {
26 unsigned char regshift; /* register shift */ 26 unsigned char regshift; /* register shift */
27 unsigned char iotype; /* UPIO_* */ 27 unsigned char iotype; /* UPIO_* */
28 unsigned char hub6; 28 unsigned char hub6;
29 unsigned int flags; /* UPF_* flags */ 29 upf_t flags; /* UPF_* flags */
30}; 30};
31 31
32/* 32/*
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 1a8cd0169c9a..4041122dabfc 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -203,6 +203,8 @@ struct uart_icount {
203 __u32 buf_overrun; 203 __u32 buf_overrun;
204}; 204};
205 205
206typedef unsigned int __bitwise__ upf_t;
207
206struct uart_port { 208struct uart_port {
207 spinlock_t lock; /* port lock */ 209 spinlock_t lock; /* port lock */
208 unsigned int iobase; /* in/out[bwl] */ 210 unsigned int iobase; /* in/out[bwl] */
@@ -230,29 +232,29 @@ struct uart_port {
230 unsigned long sysrq; /* sysrq timeout */ 232 unsigned long sysrq; /* sysrq timeout */
231#endif 233#endif
232 234
233 unsigned int flags; 235 upf_t flags;
234 236
235#define UPF_FOURPORT (1 << 1) 237#define UPF_FOURPORT ((__force upf_t) (1 << 1))
236#define UPF_SAK (1 << 2) 238#define UPF_SAK ((__force upf_t) (1 << 2))
237#define UPF_SPD_MASK (0x1030) 239#define UPF_SPD_MASK ((__force upf_t) (0x1030))
238#define UPF_SPD_HI (0x0010) 240#define UPF_SPD_HI ((__force upf_t) (0x0010))
239#define UPF_SPD_VHI (0x0020) 241#define UPF_SPD_VHI ((__force upf_t) (0x0020))
240#define UPF_SPD_CUST (0x0030) 242#define UPF_SPD_CUST ((__force upf_t) (0x0030))
241#define UPF_SPD_SHI (0x1000) 243#define UPF_SPD_SHI ((__force upf_t) (0x1000))
242#define UPF_SPD_WARP (0x1010) 244#define UPF_SPD_WARP ((__force upf_t) (0x1010))
243#define UPF_SKIP_TEST (1 << 6) 245#define UPF_SKIP_TEST ((__force upf_t) (1 << 6))
244#define UPF_AUTO_IRQ (1 << 7) 246#define UPF_AUTO_IRQ ((__force upf_t) (1 << 7))
245#define UPF_HARDPPS_CD (1 << 11) 247#define UPF_HARDPPS_CD ((__force upf_t) (1 << 11))
246#define UPF_LOW_LATENCY (1 << 13) 248#define UPF_LOW_LATENCY ((__force upf_t) (1 << 13))
247#define UPF_BUGGY_UART (1 << 14) 249#define UPF_BUGGY_UART ((__force upf_t) (1 << 14))
248#define UPF_MAGIC_MULTIPLIER (1 << 16) 250#define UPF_MAGIC_MULTIPLIER ((__force upf_t) (1 << 16))
249#define UPF_CONS_FLOW (1 << 23) 251#define UPF_CONS_FLOW ((__force upf_t) (1 << 23))
250#define UPF_SHARE_IRQ (1 << 24) 252#define UPF_SHARE_IRQ ((__force upf_t) (1 << 24))
251#define UPF_BOOT_AUTOCONF (1 << 28) 253#define UPF_BOOT_AUTOCONF ((__force upf_t) (1 << 28))
252#define UPF_IOREMAP (1 << 31) 254#define UPF_IOREMAP ((__force upf_t) (1 << 31))
253 255
254#define UPF_CHANGE_MASK (0x17fff) 256#define UPF_CHANGE_MASK ((__force upf_t) (0x17fff))
255#define UPF_USR_MASK (UPF_SPD_MASK|UPF_LOW_LATENCY) 257#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY))
256 258
257 unsigned int mctrl; /* current modem ctrl settings */ 259 unsigned int mctrl; /* current modem ctrl settings */
258 unsigned int timeout; /* character-based timeout */ 260 unsigned int timeout; /* character-based timeout */