aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/amiserial.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:46 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:50:01 -0500
commitf1166604f58e842a0bb5a639d6728ce6e2250495 (patch)
treeda7421946576b7071b5ef9df8095efd338f1d68e /drivers/tty/amiserial.c
parent6fe18d26b1c33d5cb748f8694ee1a59dc5578da4 (diff)
TTY: amiserial, provide carrier helpers
This is a preparation for a switch to tty_port_block_til_ready. We need amiga_carrier_raised and amiga_dtr_rts. The implementation is taken from startup, shutdown and current block_til_ready. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/amiserial.c')
-rw-r--r--drivers/tty/amiserial.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 613d6a3908d3..61d74613bd4d 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1623,10 +1623,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1623 local_irq_restore(flags); 1623 local_irq_restore(flags);
1624 port->blocked_open++; 1624 port->blocked_open++;
1625 while (1) { 1625 while (1) {
1626 local_irq_save(flags);
1627 if (tty->termios->c_cflag & CBAUD) 1626 if (tty->termios->c_cflag & CBAUD)
1628 rtsdtr_ctrl(SER_DTR|SER_RTS); 1627 tty_port_raise_dtr_rts(port);
1629 local_irq_restore(flags);
1630 set_current_state(TASK_INTERRUPTIBLE); 1628 set_current_state(TASK_INTERRUPTIBLE);
1631 if (tty_hung_up_p(filp) || 1629 if (tty_hung_up_p(filp) ||
1632 !(port->flags & ASYNC_INITIALIZED)) { 1630 !(port->flags & ASYNC_INITIALIZED)) {
@@ -1641,7 +1639,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1641 break; 1639 break;
1642 } 1640 }
1643 if (!(port->flags & ASYNC_CLOSING) && 1641 if (!(port->flags & ASYNC_CLOSING) &&
1644 (do_clocal || (!(ciab.pra & SER_DCD)) )) 1642 (do_clocal || tty_port_carrier_raised(port)))
1645 break; 1643 break;
1646 if (signal_pending(current)) { 1644 if (signal_pending(current)) {
1647 retval = -ERESTARTSYS; 1645 retval = -ERESTARTSYS;
@@ -1849,6 +1847,32 @@ static const struct tty_operations serial_ops = {
1849 .proc_fops = &rs_proc_fops, 1847 .proc_fops = &rs_proc_fops,
1850}; 1848};
1851 1849
1850static int amiga_carrier_raised(struct tty_port *port)
1851{
1852 return !(ciab.pra & SER_DCD);
1853}
1854
1855static void amiga_dtr_rts(struct tty_port *port, int raise)
1856{
1857 struct serial_state *info = container_of(port, struct serial_state,
1858 tport);
1859 unsigned long flags;
1860
1861 if (raise)
1862 info->MCR |= SER_DTR|SER_RTS;
1863 else
1864 info->MCR &= ~(SER_DTR|SER_RTS);
1865
1866 local_irq_save(flags);
1867 rtsdtr_ctrl(info->MCR);
1868 local_irq_restore(flags);
1869}
1870
1871static const struct tty_port_operations amiga_port_ops = {
1872 .carrier_raised = amiga_carrier_raised,
1873 .dtr_rts = amiga_dtr_rts,
1874};
1875
1852/* 1876/*
1853 * The serial driver boot-time initialization code! 1877 * The serial driver boot-time initialization code!
1854 */ 1878 */
@@ -1891,6 +1915,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
1891 state->icount.frame = state->icount.parity = 0; 1915 state->icount.frame = state->icount.parity = 0;
1892 state->icount.overrun = state->icount.brk = 0; 1916 state->icount.overrun = state->icount.brk = 0;
1893 tty_port_init(&state->tport); 1917 tty_port_init(&state->tport);
1918 state->tport.ops = &amiga_port_ops;
1894 1919
1895 printk(KERN_INFO "ttyS0 is the amiga builtin serial port\n"); 1920 printk(KERN_INFO "ttyS0 is the amiga builtin serial port\n");
1896 1921