aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--arch/ia64/hp/sim/simserial.c24
-rw-r--r--drivers/tty/amiserial.c63
-rw-r--r--include/linux/serialP.h7
3 files changed, 45 insertions, 49 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index a76a27ed3de0..614c091b203f 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -165,7 +165,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
165{ 165{
166 struct serial_state *info = dev_id; 166 struct serial_state *info = dev_id;
167 167
168 if (!info->tty) { 168 if (!info->tport.tty) {
169 printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info); 169 printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
170 return IRQ_NONE; 170 return IRQ_NONE;
171 } 171 }
@@ -173,7 +173,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
173 * pretty simple in our case, because we only get interrupts 173 * pretty simple in our case, because we only get interrupts
174 * on inbound traffic 174 * on inbound traffic
175 */ 175 */
176 receive_chars(info->tty); 176 receive_chars(info->tport.tty);
177 return IRQ_HANDLED; 177 return IRQ_HANDLED;
178} 178}
179 179
@@ -533,14 +533,14 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
533 shutdown(tty, info); 533 shutdown(tty, info);
534 rs_flush_buffer(tty); 534 rs_flush_buffer(tty);
535 tty_ldisc_flush(tty); 535 tty_ldisc_flush(tty);
536 info->tty = NULL; 536 info->tport.tty = NULL;
537 if (info->blocked_open) { 537 if (info->tport.blocked_open) {
538 if (info->close_delay) 538 if (info->close_delay)
539 schedule_timeout_interruptible(info->close_delay); 539 schedule_timeout_interruptible(info->close_delay);
540 wake_up_interruptible(&info->open_wait); 540 wake_up_interruptible(&info->tport.open_wait);
541 } 541 }
542 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 542 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
543 wake_up_interruptible(&info->close_wait); 543 wake_up_interruptible(&info->tport.close_wait);
544} 544}
545 545
546/* 546/*
@@ -569,8 +569,8 @@ static void rs_hangup(struct tty_struct *tty)
569 569
570 info->count = 0; 570 info->count = 0;
571 info->flags &= ~ASYNC_NORMAL_ACTIVE; 571 info->flags &= ~ASYNC_NORMAL_ACTIVE;
572 info->tty = NULL; 572 info->tport.tty = NULL;
573 wake_up_interruptible(&info->open_wait); 573 wake_up_interruptible(&info->tport.open_wait);
574} 574}
575 575
576 576
@@ -662,8 +662,9 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
662 unsigned long page; 662 unsigned long page;
663 663
664 info->count++; 664 info->count++;
665 info->tty = tty; 665 info->tport.tty = tty;
666 tty->driver_data = info; 666 tty->driver_data = info;
667 tty->port = &info->tport;
667 668
668#ifdef SIMSERIAL_DEBUG 669#ifdef SIMSERIAL_DEBUG
669 printk("rs_open %s, count = %d\n", tty->name, info->count); 670 printk("rs_open %s, count = %d\n", tty->name, info->count);
@@ -685,7 +686,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
685 */ 686 */
686 if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { 687 if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
687 if (info->flags & ASYNC_CLOSING) 688 if (info->flags & ASYNC_CLOSING)
688 interruptible_sleep_on(&info->close_wait); 689 interruptible_sleep_on(&info->tport.close_wait);
689#ifdef SERIAL_DO_RESTART 690#ifdef SERIAL_DO_RESTART
690 return ((info->flags & ASYNC_HUP_NOTIFY) ? 691 return ((info->flags & ASYNC_HUP_NOTIFY) ?
691 -EAGAIN : -ERESTARTSYS); 692 -EAGAIN : -ERESTARTSYS);
@@ -827,8 +828,7 @@ simrs_init (void)
827 * Let's have a little bit of fun ! 828 * Let's have a little bit of fun !
828 */ 829 */
829 for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) { 830 for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
830 init_waitqueue_head(&state->open_wait); 831 tty_port_init(&state->tport);
831 init_waitqueue_head(&state->close_wait);
832 832
833 if (state->type == PORT_UNKNOWN) continue; 833 if (state->type == PORT_UNKNOWN) continue;
834 834
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);
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index 984f5ba8da4e..32d45b869cbc 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -23,6 +23,7 @@
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/circ_buf.h> 25#include <linux/circ_buf.h>
26#include <linux/tty.h>
26#include <linux/wait.h> 27#include <linux/wait.h>
27 28
28struct serial_state { 29struct serial_state {
@@ -38,6 +39,7 @@ struct serial_state {
38 unsigned short close_delay; 39 unsigned short close_delay;
39 unsigned short closing_wait; /* time to wait before closing */ 40 unsigned short closing_wait; /* time to wait before closing */
40 struct async_icount icount; 41 struct async_icount icount;
42 struct tty_port tport;
41 43
42 /* amiserial */ 44 /* amiserial */
43 int read_status_mask; 45 int read_status_mask;
@@ -46,14 +48,9 @@ struct serial_state {
46 int quot; 48 int quot;
47 int IER; /* Interrupt Enable Register */ 49 int IER; /* Interrupt Enable Register */
48 int MCR; /* Modem control register */ 50 int MCR; /* Modem control register */
49 wait_queue_head_t delta_msr_wait;
50 /* simserial */ 51 /* simserial */
51 int x_char; /* xon/xoff character */ 52 int x_char; /* xon/xoff character */
52 int blocked_open; /* # of blocked opens */
53 struct circ_buf xmit; 53 struct circ_buf xmit;
54 wait_queue_head_t open_wait;
55 wait_queue_head_t close_wait;
56 struct tty_struct *tty;
57 /* /simserial */ 54 /* /simserial */
58 /* /amiserial */ 55 /* /amiserial */
59}; 56};