diff options
author | Alan Cox <alan@redhat.com> | 2009-01-02 08:45:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 13:19:38 -0500 |
commit | 31f35939d1d9bcfb3099b32c67b896d2792603f9 (patch) | |
tree | 39b6ceaf0e7477e0357ff8235814f579adad3f28 /drivers/char/ser_a2232.c | |
parent | c9b3976e3fec266be25c5001a70aa0a890b6c476 (diff) |
tty_port: Add a port level carrier detect operation
This is the first step to generalising the various pieces of waiting logic
duplicated in all sorts of serial drivers.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/ser_a2232.c')
-rw-r--r-- | drivers/char/ser_a2232.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c index 7b0c35207d9..0c97f34df63 100644 --- a/drivers/char/ser_a2232.c +++ b/drivers/char/ser_a2232.c | |||
@@ -122,7 +122,7 @@ static void a2232_disable_tx_interrupts(void *ptr); | |||
122 | static void a2232_enable_tx_interrupts(void *ptr); | 122 | static void a2232_enable_tx_interrupts(void *ptr); |
123 | static void a2232_disable_rx_interrupts(void *ptr); | 123 | static void a2232_disable_rx_interrupts(void *ptr); |
124 | static void a2232_enable_rx_interrupts(void *ptr); | 124 | static void a2232_enable_rx_interrupts(void *ptr); |
125 | static int a2232_get_CD(void *ptr); | 125 | static int a2232_carrier_raised(struct tty_port *port); |
126 | static void a2232_shutdown_port(void *ptr); | 126 | static void a2232_shutdown_port(void *ptr); |
127 | static int a2232_set_real_termios(void *ptr); | 127 | static int a2232_set_real_termios(void *ptr); |
128 | static int a2232_chars_in_buffer(void *ptr); | 128 | static int a2232_chars_in_buffer(void *ptr); |
@@ -148,7 +148,6 @@ static struct real_driver a2232_real_driver = { | |||
148 | a2232_enable_tx_interrupts, | 148 | a2232_enable_tx_interrupts, |
149 | a2232_disable_rx_interrupts, | 149 | a2232_disable_rx_interrupts, |
150 | a2232_enable_rx_interrupts, | 150 | a2232_enable_rx_interrupts, |
151 | a2232_get_CD, | ||
152 | a2232_shutdown_port, | 151 | a2232_shutdown_port, |
153 | a2232_set_real_termios, | 152 | a2232_set_real_termios, |
154 | a2232_chars_in_buffer, | 153 | a2232_chars_in_buffer, |
@@ -260,9 +259,10 @@ static void a2232_enable_rx_interrupts(void *ptr) | |||
260 | port->disable_rx = 0; | 259 | port->disable_rx = 0; |
261 | } | 260 | } |
262 | 261 | ||
263 | static int a2232_get_CD(void *ptr) | 262 | static int a2232_carrier_raised(struct tty_port *port) |
264 | { | 263 | { |
265 | return ((struct a2232_port *) ptr)->cd_status; | 264 | struct a2232_port *ap = container_of(port, struct a2232_port, gs.port); |
265 | return ap->cd_status; | ||
266 | } | 266 | } |
267 | 267 | ||
268 | static void a2232_shutdown_port(void *ptr) | 268 | static void a2232_shutdown_port(void *ptr) |
@@ -638,6 +638,10 @@ int ch, err, n, p; | |||
638 | return IRQ_HANDLED; | 638 | return IRQ_HANDLED; |
639 | } | 639 | } |
640 | 640 | ||
641 | static const struct tty_port_operations a2232_port_ops = { | ||
642 | .carrier_raised = a2232_carrier_raised, | ||
643 | }; | ||
644 | |||
641 | static void a2232_init_portstructs(void) | 645 | static void a2232_init_portstructs(void) |
642 | { | 646 | { |
643 | struct a2232_port *port; | 647 | struct a2232_port *port; |
@@ -645,6 +649,8 @@ static void a2232_init_portstructs(void) | |||
645 | 649 | ||
646 | for (i = 0; i < MAX_A2232_BOARDS*NUMLINES; i++) { | 650 | for (i = 0; i < MAX_A2232_BOARDS*NUMLINES; i++) { |
647 | port = a2232_ports + i; | 651 | port = a2232_ports + i; |
652 | tty_port_init(&port->gs.port); | ||
653 | port->gs.port.ops = &a2232_port_ops; | ||
648 | port->which_a2232 = i/NUMLINES; | 654 | port->which_a2232 = i/NUMLINES; |
649 | port->which_port_on_a2232 = i%NUMLINES; | 655 | port->which_port_on_a2232 = i%NUMLINES; |
650 | port->disable_rx = port->throttle_input = port->cd_status = 0; | 656 | port->disable_rx = port->throttle_input = port->cd_status = 0; |
@@ -652,11 +658,6 @@ static void a2232_init_portstructs(void) | |||
652 | port->gs.close_delay = HZ/2; | 658 | port->gs.close_delay = HZ/2; |
653 | port->gs.closing_wait = 30 * HZ; | 659 | port->gs.closing_wait = 30 * HZ; |
654 | port->gs.rd = &a2232_real_driver; | 660 | port->gs.rd = &a2232_real_driver; |
655 | #ifdef NEW_WRITE_LOCKING | ||
656 | mutex_init(&(port->gs.port_write_mutex)); | ||
657 | #endif | ||
658 | init_waitqueue_head(&port->gs.port.open_wait); | ||
659 | init_waitqueue_head(&port->gs.port.close_wait); | ||
660 | } | 661 | } |
661 | } | 662 | } |
662 | 663 | ||