aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/amiserial.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:24 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:30:50 -0500
commit87758791c99715433841f1c054b49166506513e4 (patch)
treea0ba9a0e5dea44992557fcd681077ee8ededb085 /drivers/tty/amiserial.c
parent5e99d5458729b0eb763ca83a2fbb95f6276c4243 (diff)
TTY: amiserial/simserial, use tty_port
Add tty_port to serial_state and start using common tty port members from tty_port in amiserial and simserial. The rest will follow one by one. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/amiserial.c')
-rw-r--r--drivers/tty/amiserial.c63
1 files changed, 31 insertions, 32 deletions
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 5b87744748d5..71d3331d6e84 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -234,7 +234,7 @@ static void receive_chars(struct serial_state *info)
234{ 234{
235 int status; 235 int status;
236 int serdatr; 236 int serdatr;
237 struct tty_struct *tty = info->tty; 237 struct tty_struct *tty = info->tport.tty;
238 unsigned char ch, flag; 238 unsigned char ch, flag;
239 struct async_icount *icount; 239 struct async_icount *icount;
240 int oe = 0; 240 int oe = 0;
@@ -331,8 +331,8 @@ static void transmit_chars(struct serial_state *info)
331 return; 331 return;
332 } 332 }
333 if (info->xmit.head == info->xmit.tail 333 if (info->xmit.head == info->xmit.tail
334 || info->tty->stopped 334 || info->tport.tty->stopped
335 || info->tty->hw_stopped) { 335 || info->tport.tty->hw_stopped) {
336 info->IER &= ~UART_IER_THRI; 336 info->IER &= ~UART_IER_THRI;
337 custom.intena = IF_TBE; 337 custom.intena = IF_TBE;
338 mb(); 338 mb();
@@ -347,7 +347,7 @@ static void transmit_chars(struct serial_state *info)
347 if (CIRC_CNT(info->xmit.head, 347 if (CIRC_CNT(info->xmit.head,
348 info->xmit.tail, 348 info->xmit.tail,
349 SERIAL_XMIT_SIZE) < WAKEUP_CHARS) 349 SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
350 tty_wakeup(info->tty); 350 tty_wakeup(info->tport.tty);
351 351
352#ifdef SERIAL_DEBUG_INTR 352#ifdef SERIAL_DEBUG_INTR
353 printk("THRE..."); 353 printk("THRE...");
@@ -384,7 +384,7 @@ static void check_modem_status(struct serial_state *info)
384 } 384 }
385 if (dstatus & SER_CTS) 385 if (dstatus & SER_CTS)
386 icount->cts++; 386 icount->cts++;
387 wake_up_interruptible(&info->delta_msr_wait); 387 wake_up_interruptible(&info->tport.delta_msr_wait);
388 } 388 }
389 389
390 if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) { 390 if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
@@ -393,29 +393,29 @@ static void check_modem_status(struct serial_state *info)
393 (!(status & SER_DCD)) ? "on" : "off"); 393 (!(status & SER_DCD)) ? "on" : "off");
394#endif 394#endif
395 if (!(status & SER_DCD)) 395 if (!(status & SER_DCD))
396 wake_up_interruptible(&info->open_wait); 396 wake_up_interruptible(&info->tport.open_wait);
397 else { 397 else {
398#ifdef SERIAL_DEBUG_OPEN 398#ifdef SERIAL_DEBUG_OPEN
399 printk("doing serial hangup..."); 399 printk("doing serial hangup...");
400#endif 400#endif
401 if (info->tty) 401 if (info->tport.tty)
402 tty_hangup(info->tty); 402 tty_hangup(info->tport.tty);
403 } 403 }
404 } 404 }
405 if (info->flags & ASYNC_CTS_FLOW) { 405 if (info->flags & ASYNC_CTS_FLOW) {
406 if (info->tty->hw_stopped) { 406 if (info->tport.tty->hw_stopped) {
407 if (!(status & SER_CTS)) { 407 if (!(status & SER_CTS)) {
408#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) 408#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
409 printk("CTS tx start..."); 409 printk("CTS tx start...");
410#endif 410#endif
411 info->tty->hw_stopped = 0; 411 info->tport.tty->hw_stopped = 0;
412 info->IER |= UART_IER_THRI; 412 info->IER |= UART_IER_THRI;
413 custom.intena = IF_SETCLR | IF_TBE; 413 custom.intena = IF_SETCLR | IF_TBE;
414 mb(); 414 mb();
415 /* set a pending Tx Interrupt, transmitter should restart now */ 415 /* set a pending Tx Interrupt, transmitter should restart now */
416 custom.intreq = IF_SETCLR | IF_TBE; 416 custom.intreq = IF_SETCLR | IF_TBE;
417 mb(); 417 mb();
418 tty_wakeup(info->tty); 418 tty_wakeup(info->tport.tty);
419 return; 419 return;
420 } 420 }
421 } else { 421 } else {
@@ -423,7 +423,7 @@ static void check_modem_status(struct serial_state *info)
423#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) 423#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
424 printk("CTS tx stop..."); 424 printk("CTS tx stop...");
425#endif 425#endif
426 info->tty->hw_stopped = 1; 426 info->tport.tty->hw_stopped = 1;
427 info->IER &= ~UART_IER_THRI; 427 info->IER &= ~UART_IER_THRI;
428 /* disable Tx interrupt and remove any pending interrupts */ 428 /* disable Tx interrupt and remove any pending interrupts */
429 custom.intena = IF_TBE; 429 custom.intena = IF_TBE;
@@ -456,7 +456,7 @@ static irqreturn_t ser_rx_int(int irq, void *dev_id)
456 printk("ser_rx_int..."); 456 printk("ser_rx_int...");
457#endif 457#endif
458 458
459 if (!info->tty) 459 if (!info->tport.tty)
460 return IRQ_NONE; 460 return IRQ_NONE;
461 461
462 receive_chars(info); 462 receive_chars(info);
@@ -475,7 +475,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
475 printk("ser_tx_int..."); 475 printk("ser_tx_int...");
476#endif 476#endif
477 477
478 if (!info->tty) 478 if (!info->tport.tty)
479 return IRQ_NONE; 479 return IRQ_NONE;
480 480
481 transmit_chars(info); 481 transmit_chars(info);
@@ -607,7 +607,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
607 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq 607 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
608 * here so the queue might never be waken up 608 * here so the queue might never be waken up
609 */ 609 */
610 wake_up_interruptible(&info->delta_msr_wait); 610 wake_up_interruptible(&info->tport.delta_msr_wait);
611 611
612 /* 612 /*
613 * Free the IRQ, if necessary 613 * Free the IRQ, if necessary
@@ -1274,7 +1274,7 @@ static int rs_ioctl(struct tty_struct *tty,
1274 cprev = info->icount; 1274 cprev = info->icount;
1275 local_irq_restore(flags); 1275 local_irq_restore(flags);
1276 while (1) { 1276 while (1) {
1277 interruptible_sleep_on(&info->delta_msr_wait); 1277 interruptible_sleep_on(&info->tport.delta_msr_wait);
1278 /* see if a signal did it */ 1278 /* see if a signal did it */
1279 if (signal_pending(current)) 1279 if (signal_pending(current))
1280 return -ERESTARTSYS; 1280 return -ERESTARTSYS;
@@ -1442,15 +1442,15 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1442 1442
1443 tty_ldisc_flush(tty); 1443 tty_ldisc_flush(tty);
1444 tty->closing = 0; 1444 tty->closing = 0;
1445 state->tty = NULL; 1445 state->tport.tty = NULL;
1446 if (state->blocked_open) { 1446 if (state->tport.blocked_open) {
1447 if (state->close_delay) { 1447 if (state->close_delay) {
1448 msleep_interruptible(jiffies_to_msecs(state->close_delay)); 1448 msleep_interruptible(jiffies_to_msecs(state->close_delay));
1449 } 1449 }
1450 wake_up_interruptible(&state->open_wait); 1450 wake_up_interruptible(&state->tport.open_wait);
1451 } 1451 }
1452 state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1452 state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1453 wake_up_interruptible(&state->close_wait); 1453 wake_up_interruptible(&state->tport.close_wait);
1454 local_irq_restore(flags); 1454 local_irq_restore(flags);
1455} 1455}
1456 1456
@@ -1531,8 +1531,8 @@ static void rs_hangup(struct tty_struct *tty)
1531 shutdown(tty, info); 1531 shutdown(tty, info);
1532 info->count = 0; 1532 info->count = 0;
1533 info->flags &= ~ASYNC_NORMAL_ACTIVE; 1533 info->flags &= ~ASYNC_NORMAL_ACTIVE;
1534 info->tty = NULL; 1534 info->tport.tty = NULL;
1535 wake_up_interruptible(&info->open_wait); 1535 wake_up_interruptible(&info->tport.open_wait);
1536} 1536}
1537 1537
1538/* 1538/*
@@ -1559,7 +1559,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1559 if (tty_hung_up_p(filp) || 1559 if (tty_hung_up_p(filp) ||
1560 (info->flags & ASYNC_CLOSING)) { 1560 (info->flags & ASYNC_CLOSING)) {
1561 if (info->flags & ASYNC_CLOSING) 1561 if (info->flags & ASYNC_CLOSING)
1562 interruptible_sleep_on(&info->close_wait); 1562 interruptible_sleep_on(&info->tport.close_wait);
1563#ifdef SERIAL_DO_RESTART 1563#ifdef SERIAL_DO_RESTART
1564 return ((info->flags & ASYNC_HUP_NOTIFY) ? 1564 return ((info->flags & ASYNC_HUP_NOTIFY) ?
1565 -EAGAIN : -ERESTARTSYS); 1565 -EAGAIN : -ERESTARTSYS);
@@ -1589,7 +1589,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1589 * exit, either normal or abnormal. 1589 * exit, either normal or abnormal.
1590 */ 1590 */
1591 retval = 0; 1591 retval = 0;
1592 add_wait_queue(&info->open_wait, &wait); 1592 add_wait_queue(&info->tport.open_wait, &wait);
1593#ifdef SERIAL_DEBUG_OPEN 1593#ifdef SERIAL_DEBUG_OPEN
1594 printk("block_til_ready before block: ttys%d, count = %d\n", 1594 printk("block_til_ready before block: ttys%d, count = %d\n",
1595 info->line, info->count); 1595 info->line, info->count);
@@ -1600,7 +1600,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1600 info->count--; 1600 info->count--;
1601 } 1601 }
1602 local_irq_restore(flags); 1602 local_irq_restore(flags);
1603 info->blocked_open++; 1603 info->tport.blocked_open++;
1604 while (1) { 1604 while (1) {
1605 local_irq_save(flags); 1605 local_irq_save(flags);
1606 if (tty->termios->c_cflag & CBAUD) 1606 if (tty->termios->c_cflag & CBAUD)
@@ -1635,10 +1635,10 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1635 tty_lock(); 1635 tty_lock();
1636 } 1636 }
1637 __set_current_state(TASK_RUNNING); 1637 __set_current_state(TASK_RUNNING);
1638 remove_wait_queue(&info->open_wait, &wait); 1638 remove_wait_queue(&info->tport.open_wait, &wait);
1639 if (extra_count) 1639 if (extra_count)
1640 info->count++; 1640 info->count++;
1641 info->blocked_open--; 1641 info->tport.blocked_open--;
1642#ifdef SERIAL_DEBUG_OPEN 1642#ifdef SERIAL_DEBUG_OPEN
1643 printk("block_til_ready after blocking: ttys%d, count = %d\n", 1643 printk("block_til_ready after blocking: ttys%d, count = %d\n",
1644 info->line, info->count); 1644 info->line, info->count);
@@ -1661,8 +1661,9 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
1661 int retval; 1661 int retval;
1662 1662
1663 info->count++; 1663 info->count++;
1664 info->tty = tty; 1664 info->tport.tty = tty;
1665 tty->driver_data = info; 1665 tty->driver_data = info;
1666 tty->port = &info->tport;
1666 if (serial_paranoia_check(info, tty->name, "rs_open")) 1667 if (serial_paranoia_check(info, tty->name, "rs_open"))
1667 return -ENODEV; 1668 return -ENODEV;
1668 1669
@@ -1677,7 +1678,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
1677 if (tty_hung_up_p(filp) || 1678 if (tty_hung_up_p(filp) ||
1678 (info->flags & ASYNC_CLOSING)) { 1679 (info->flags & ASYNC_CLOSING)) {
1679 if (info->flags & ASYNC_CLOSING) 1680 if (info->flags & ASYNC_CLOSING)
1680 interruptible_sleep_on(&info->close_wait); 1681 interruptible_sleep_on(&info->tport.close_wait);
1681#ifdef SERIAL_DO_RESTART 1682#ifdef SERIAL_DO_RESTART
1682 return ((info->flags & ASYNC_HUP_NOTIFY) ? 1683 return ((info->flags & ASYNC_HUP_NOTIFY) ?
1683 -EAGAIN : -ERESTARTSYS); 1684 -EAGAIN : -ERESTARTSYS);
@@ -1869,9 +1870,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
1869 state->icount.rx = state->icount.tx = 0; 1870 state->icount.rx = state->icount.tx = 0;
1870 state->icount.frame = state->icount.parity = 0; 1871 state->icount.frame = state->icount.parity = 0;
1871 state->icount.overrun = state->icount.brk = 0; 1872 state->icount.overrun = state->icount.brk = 0;
1872 init_waitqueue_head(&state->open_wait); 1873 tty_port_init(&state->tport);
1873 init_waitqueue_head(&state->close_wait);
1874 init_waitqueue_head(&state->delta_msr_wait);
1875 1874
1876 printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n", 1875 printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n",
1877 state->line); 1876 state->line);