aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-16 16:55:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-20 20:12:36 -0400
commit52d417388d154f68f8ab753de03b1fba1814de81 (patch)
tree7d89c6954fb64fc64f0b64f37c951f79cc56a32b /drivers
parent7a4d29f426f17479395980ded8fa5e3bdd6d94e4 (diff)
epca: use tty_port
Switch the EPCA driver to include and begin using a tty_port structure Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/epca.c106
-rw-r--r--drivers/char/epca.h7
2 files changed, 54 insertions, 59 deletions
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index aa8e19f44b45..ac9995f6578b 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -432,7 +432,7 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
432 spin_unlock_irqrestore(&epca_lock, flags); 432 spin_unlock_irqrestore(&epca_lock, flags);
433 return; 433 return;
434 } 434 }
435 if (ch->count-- > 1) { 435 if (ch->port.count-- > 1) {
436 /* Begin channel is open more than once */ 436 /* Begin channel is open more than once */
437 /* 437 /*
438 * Return without doing anything. Someone might still 438 * Return without doing anything. Someone might still
@@ -442,19 +442,19 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
442 return; 442 return;
443 } 443 }
444 /* Port open only once go ahead with shutdown & reset */ 444 /* Port open only once go ahead with shutdown & reset */
445 BUG_ON(ch->count < 0); 445 BUG_ON(ch->port.count < 0);
446 446
447 /* 447 /*
448 * Let the rest of the driver know the channel is being closed. 448 * Let the rest of the driver know the channel is being closed.
449 * This becomes important if an open is attempted before close 449 * This becomes important if an open is attempted before close
450 * is finished. 450 * is finished.
451 */ 451 */
452 ch->asyncflags |= ASYNC_CLOSING; 452 ch->port.flags |= ASYNC_CLOSING;
453 tty->closing = 1; 453 tty->closing = 1;
454 454
455 spin_unlock_irqrestore(&epca_lock, flags); 455 spin_unlock_irqrestore(&epca_lock, flags);
456 456
457 if (ch->asyncflags & ASYNC_INITIALIZED) { 457 if (ch->port.flags & ASYNC_INITIALIZED) {
458 /* Setup an event to indicate when the 458 /* Setup an event to indicate when the
459 transmit buffer empties */ 459 transmit buffer empties */
460 setup_empty_event(tty, ch); 460 setup_empty_event(tty, ch);
@@ -469,17 +469,17 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
469 spin_lock_irqsave(&epca_lock, flags); 469 spin_lock_irqsave(&epca_lock, flags);
470 tty->closing = 0; 470 tty->closing = 0;
471 ch->event = 0; 471 ch->event = 0;
472 ch->tty = NULL; 472 ch->port.tty = NULL;
473 spin_unlock_irqrestore(&epca_lock, flags); 473 spin_unlock_irqrestore(&epca_lock, flags);
474 474
475 if (ch->blocked_open) { 475 if (ch->port.blocked_open) {
476 if (ch->close_delay) 476 if (ch->close_delay)
477 msleep_interruptible(jiffies_to_msecs(ch->close_delay)); 477 msleep_interruptible(jiffies_to_msecs(ch->close_delay));
478 wake_up_interruptible(&ch->open_wait); 478 wake_up_interruptible(&ch->port.open_wait);
479 } 479 }
480 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | 480 ch->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED |
481 ASYNC_CLOSING); 481 ASYNC_CLOSING);
482 wake_up_interruptible(&ch->close_wait); 482 wake_up_interruptible(&ch->port.close_wait);
483 } 483 }
484} 484}
485 485
@@ -489,7 +489,7 @@ static void shutdown(struct channel *ch)
489 struct tty_struct *tty; 489 struct tty_struct *tty;
490 struct board_chan __iomem *bc; 490 struct board_chan __iomem *bc;
491 491
492 if (!(ch->asyncflags & ASYNC_INITIALIZED)) 492 if (!(ch->port.flags & ASYNC_INITIALIZED))
493 return; 493 return;
494 494
495 spin_lock_irqsave(&epca_lock, flags); 495 spin_lock_irqsave(&epca_lock, flags);
@@ -504,7 +504,7 @@ static void shutdown(struct channel *ch)
504 */ 504 */
505 if (bc) 505 if (bc)
506 writeb(0, &bc->idata); 506 writeb(0, &bc->idata);
507 tty = ch->tty; 507 tty = ch->port.tty;
508 508
509 /* If we're a modem control device and HUPCL is on, drop RTS & DTR. */ 509 /* If we're a modem control device and HUPCL is on, drop RTS & DTR. */
510 if (tty->termios->c_cflag & HUPCL) { 510 if (tty->termios->c_cflag & HUPCL) {
@@ -518,7 +518,7 @@ static void shutdown(struct channel *ch)
518 * will have to reinitialized. Set a flag to indicate this. 518 * will have to reinitialized. Set a flag to indicate this.
519 */ 519 */
520 /* Prevent future Digi programmed interrupts from coming active */ 520 /* Prevent future Digi programmed interrupts from coming active */
521 ch->asyncflags &= ~ASYNC_INITIALIZED; 521 ch->port.flags &= ~ASYNC_INITIALIZED;
522 spin_unlock_irqrestore(&epca_lock, flags); 522 spin_unlock_irqrestore(&epca_lock, flags);
523} 523}
524 524
@@ -538,12 +538,12 @@ static void pc_hangup(struct tty_struct *tty)
538 shutdown(ch); 538 shutdown(ch);
539 539
540 spin_lock_irqsave(&epca_lock, flags); 540 spin_lock_irqsave(&epca_lock, flags);
541 ch->tty = NULL; 541 ch->port.tty = NULL;
542 ch->event = 0; 542 ch->event = 0;
543 ch->count = 0; 543 ch->port.count = 0;
544 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED); 544 ch->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED);
545 spin_unlock_irqrestore(&epca_lock, flags); 545 spin_unlock_irqrestore(&epca_lock, flags);
546 wake_up_interruptible(&ch->open_wait); 546 wake_up_interruptible(&ch->port.open_wait);
547 } 547 }
548} 548}
549 549
@@ -795,7 +795,7 @@ static int block_til_ready(struct tty_struct *tty,
795 unsigned long flags; 795 unsigned long flags;
796 796
797 if (tty_hung_up_p(filp)) { 797 if (tty_hung_up_p(filp)) {
798 if (ch->asyncflags & ASYNC_HUP_NOTIFY) 798 if (ch->port.flags & ASYNC_HUP_NOTIFY)
799 retval = -EAGAIN; 799 retval = -EAGAIN;
800 else 800 else
801 retval = -ERESTARTSYS; 801 retval = -ERESTARTSYS;
@@ -806,10 +806,10 @@ static int block_til_ready(struct tty_struct *tty,
806 * If the device is in the middle of being closed, then block until 806 * If the device is in the middle of being closed, then block until
807 * it's done, and then try again. 807 * it's done, and then try again.
808 */ 808 */
809 if (ch->asyncflags & ASYNC_CLOSING) { 809 if (ch->port.flags & ASYNC_CLOSING) {
810 interruptible_sleep_on(&ch->close_wait); 810 interruptible_sleep_on(&ch->port.close_wait);
811 811
812 if (ch->asyncflags & ASYNC_HUP_NOTIFY) 812 if (ch->port.flags & ASYNC_HUP_NOTIFY)
813 return -EAGAIN; 813 return -EAGAIN;
814 else 814 else
815 return -ERESTARTSYS; 815 return -ERESTARTSYS;
@@ -820,7 +820,7 @@ static int block_til_ready(struct tty_struct *tty,
820 * If non-blocking mode is set, then make the check up front 820 * If non-blocking mode is set, then make the check up front
821 * and then exit. 821 * and then exit.
822 */ 822 */
823 ch->asyncflags |= ASYNC_NORMAL_ACTIVE; 823 ch->port.flags |= ASYNC_NORMAL_ACTIVE;
824 return 0; 824 return 0;
825 } 825 }
826 if (tty->termios->c_cflag & CLOCAL) 826 if (tty->termios->c_cflag & CLOCAL)
@@ -828,24 +828,24 @@ static int block_til_ready(struct tty_struct *tty,
828 /* Block waiting for the carrier detect and the line to become free */ 828 /* Block waiting for the carrier detect and the line to become free */
829 829
830 retval = 0; 830 retval = 0;
831 add_wait_queue(&ch->open_wait, &wait); 831 add_wait_queue(&ch->port.open_wait, &wait);
832 832
833 spin_lock_irqsave(&epca_lock, flags); 833 spin_lock_irqsave(&epca_lock, flags);
834 /* We dec count so that pc_close will know when to free things */ 834 /* We dec count so that pc_close will know when to free things */
835 if (!tty_hung_up_p(filp)) 835 if (!tty_hung_up_p(filp))
836 ch->count--; 836 ch->port.count--;
837 ch->blocked_open++; 837 ch->port.blocked_open++;
838 while (1) { 838 while (1) {
839 set_current_state(TASK_INTERRUPTIBLE); 839 set_current_state(TASK_INTERRUPTIBLE);
840 if (tty_hung_up_p(filp) || 840 if (tty_hung_up_p(filp) ||
841 !(ch->asyncflags & ASYNC_INITIALIZED)) { 841 !(ch->port.flags & ASYNC_INITIALIZED)) {
842 if (ch->asyncflags & ASYNC_HUP_NOTIFY) 842 if (ch->port.flags & ASYNC_HUP_NOTIFY)
843 retval = -EAGAIN; 843 retval = -EAGAIN;
844 else 844 else
845 retval = -ERESTARTSYS; 845 retval = -ERESTARTSYS;
846 break; 846 break;
847 } 847 }
848 if (!(ch->asyncflags & ASYNC_CLOSING) && 848 if (!(ch->port.flags & ASYNC_CLOSING) &&
849 (do_clocal || (ch->imodem & ch->dcd))) 849 (do_clocal || (ch->imodem & ch->dcd)))
850 break; 850 break;
851 if (signal_pending(current)) { 851 if (signal_pending(current)) {
@@ -864,17 +864,17 @@ static int block_til_ready(struct tty_struct *tty,
864 } 864 }
865 865
866 __set_current_state(TASK_RUNNING); 866 __set_current_state(TASK_RUNNING);
867 remove_wait_queue(&ch->open_wait, &wait); 867 remove_wait_queue(&ch->port.open_wait, &wait);
868 if (!tty_hung_up_p(filp)) 868 if (!tty_hung_up_p(filp))
869 ch->count++; 869 ch->port.count++;
870 ch->blocked_open--; 870 ch->port.blocked_open--;
871 871
872 spin_unlock_irqrestore(&epca_lock, flags); 872 spin_unlock_irqrestore(&epca_lock, flags);
873 873
874 if (retval) 874 if (retval)
875 return retval; 875 return retval;
876 876
877 ch->asyncflags |= ASYNC_NORMAL_ACTIVE; 877 ch->port.flags |= ASYNC_NORMAL_ACTIVE;
878 return 0; 878 return 0;
879} 879}
880 880
@@ -933,7 +933,7 @@ static int pc_open(struct tty_struct *tty, struct file *filp)
933 * necessary because we do not wish to flush and shutdown the channel 933 * necessary because we do not wish to flush and shutdown the channel
934 * until the last app holding the channel open, closes it. 934 * until the last app holding the channel open, closes it.
935 */ 935 */
936 ch->count++; 936 ch->port.count++;
937 /* 937 /*
938 * Set a kernel structures pointer to our local channel structure. This 938 * Set a kernel structures pointer to our local channel structure. This
939 * way we can get to it when passed only a tty struct. 939 * way we can get to it when passed only a tty struct.
@@ -957,14 +957,14 @@ static int pc_open(struct tty_struct *tty, struct file *filp)
957 writew(head, &bc->rout); 957 writew(head, &bc->rout);
958 958
959 /* Set the channels associated tty structure */ 959 /* Set the channels associated tty structure */
960 ch->tty = tty; 960 ch->port.tty = tty;
961 961
962 /* 962 /*
963 * The below routine generally sets up parity, baud, flow control 963 * The below routine generally sets up parity, baud, flow control
964 * issues, etc.... It effect both control flags and input flags. 964 * issues, etc.... It effect both control flags and input flags.
965 */ 965 */
966 epcaparam(tty, ch); 966 epcaparam(tty, ch);
967 ch->asyncflags |= ASYNC_INITIALIZED; 967 ch->port.flags |= ASYNC_INITIALIZED;
968 memoff(ch); 968 memoff(ch);
969 spin_unlock_irqrestore(&epca_lock, flags); 969 spin_unlock_irqrestore(&epca_lock, flags);
970 970
@@ -976,7 +976,7 @@ static int pc_open(struct tty_struct *tty, struct file *filp)
976 * waiting for the line... 976 * waiting for the line...
977 */ 977 */
978 spin_lock_irqsave(&epca_lock, flags); 978 spin_lock_irqsave(&epca_lock, flags);
979 ch->tty = tty; 979 ch->port.tty = tty;
980 globalwinon(ch); 980 globalwinon(ch);
981 /* Enable Digi Data events */ 981 /* Enable Digi Data events */
982 writeb(1, &bc->idata); 982 writeb(1, &bc->idata);
@@ -1017,8 +1017,8 @@ static void __exit epca_module_exit(void)
1017 } 1017 }
1018 ch = card_ptr[crd]; 1018 ch = card_ptr[crd];
1019 for (count = 0; count < bd->numports; count++, ch++) { 1019 for (count = 0; count < bd->numports; count++, ch++) {
1020 if (ch && ch->tty) 1020 if (ch && ch->port.tty)
1021 tty_hangup(ch->tty); 1021 tty_hangup(ch->port.tty);
1022 } 1022 }
1023 } 1023 }
1024 pci_unregister_driver(&epca_driver); 1024 pci_unregister_driver(&epca_driver);
@@ -1427,7 +1427,7 @@ static void post_fep_init(unsigned int crd)
1427 ch->boardnum = crd; 1427 ch->boardnum = crd;
1428 ch->channelnum = i; 1428 ch->channelnum = i;
1429 ch->magic = EPCA_MAGIC; 1429 ch->magic = EPCA_MAGIC;
1430 ch->tty = NULL; 1430 ch->port.tty = NULL;
1431 1431
1432 if (shrinkmem) { 1432 if (shrinkmem) {
1433 fepcmd(ch, SETBUFFER, 32, 0, 0, 0); 1433 fepcmd(ch, SETBUFFER, 32, 0, 0, 0);
@@ -1510,10 +1510,10 @@ static void post_fep_init(unsigned int crd)
1510 ch->fepstopca = 0; 1510 ch->fepstopca = 0;
1511 1511
1512 ch->close_delay = 50; 1512 ch->close_delay = 50;
1513 ch->count = 0; 1513 ch->port.count = 0;
1514 ch->blocked_open = 0; 1514 ch->port.blocked_open = 0;
1515 init_waitqueue_head(&ch->open_wait); 1515 init_waitqueue_head(&ch->port.open_wait);
1516 init_waitqueue_head(&ch->close_wait); 1516 init_waitqueue_head(&ch->port.close_wait);
1517 1517
1518 spin_unlock_irqrestore(&epca_lock, flags); 1518 spin_unlock_irqrestore(&epca_lock, flags);
1519 } 1519 }
@@ -1633,15 +1633,15 @@ static void doevent(int crd)
1633 if (event & MODEMCHG_IND) { 1633 if (event & MODEMCHG_IND) {
1634 /* A modem signal change has been indicated */ 1634 /* A modem signal change has been indicated */
1635 ch->imodem = mstat; 1635 ch->imodem = mstat;
1636 if (ch->asyncflags & ASYNC_CHECK_CD) { 1636 if (ch->port.flags & ASYNC_CHECK_CD) {
1637 /* We are now receiving dcd */ 1637 /* We are now receiving dcd */
1638 if (mstat & ch->dcd) 1638 if (mstat & ch->dcd)
1639 wake_up_interruptible(&ch->open_wait); 1639 wake_up_interruptible(&ch->port.open_wait);
1640 else /* No dcd; hangup */ 1640 else /* No dcd; hangup */
1641 pc_sched_event(ch, EPCA_EVENT_HANGUP); 1641 pc_sched_event(ch, EPCA_EVENT_HANGUP);
1642 } 1642 }
1643 } 1643 }
1644 tty = ch->tty; 1644 tty = ch->port.tty;
1645 if (tty) { 1645 if (tty) {
1646 if (event & BREAK_IND) { 1646 if (event & BREAK_IND) {
1647 /* A break has been indicated */ 1647 /* A break has been indicated */
@@ -1880,9 +1880,9 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
1880 * that the driver will wait on carrier detect. 1880 * that the driver will wait on carrier detect.
1881 */ 1881 */
1882 if (ts->c_cflag & CLOCAL) 1882 if (ts->c_cflag & CLOCAL)
1883 ch->asyncflags &= ~ASYNC_CHECK_CD; 1883 ch->port.flags &= ~ASYNC_CHECK_CD;
1884 else 1884 else
1885 ch->asyncflags |= ASYNC_CHECK_CD; 1885 ch->port.flags |= ASYNC_CHECK_CD;
1886 mval = ch->m_dtr | ch->m_rts; 1886 mval = ch->m_dtr | ch->m_rts;
1887 } /* End CBAUD not detected */ 1887 } /* End CBAUD not detected */
1888 iflag = termios2digi_i(ch, ts->c_iflag); 1888 iflag = termios2digi_i(ch, ts->c_iflag);
@@ -1972,7 +1972,7 @@ static void receive_data(struct channel *ch)
1972 globalwinon(ch); 1972 globalwinon(ch);
1973 if (ch->statusflags & RXSTOPPED) 1973 if (ch->statusflags & RXSTOPPED)
1974 return; 1974 return;
1975 tty = ch->tty; 1975 tty = ch->port.tty;
1976 if (tty) 1976 if (tty)
1977 ts = tty->termios; 1977 ts = tty->termios;
1978 bc = ch->brdchan; 1978 bc = ch->brdchan;
@@ -2032,7 +2032,7 @@ static void receive_data(struct channel *ch)
2032 globalwinon(ch); 2032 globalwinon(ch);
2033 writew(tail, &bc->rout); 2033 writew(tail, &bc->rout);
2034 /* Must be called with global data */ 2034 /* Must be called with global data */
2035 tty_schedule_flip(ch->tty); 2035 tty_schedule_flip(ch->port.tty);
2036} 2036}
2037 2037
2038static int info_ioctl(struct tty_struct *tty, struct file *file, 2038static int info_ioctl(struct tty_struct *tty, struct file *file,
@@ -2376,7 +2376,7 @@ static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
2376 2376
2377 if (!(old_termios->c_cflag & CLOCAL) && 2377 if (!(old_termios->c_cflag & CLOCAL) &&
2378 (tty->termios->c_cflag & CLOCAL)) 2378 (tty->termios->c_cflag & CLOCAL))
2379 wake_up_interruptible(&ch->open_wait); 2379 wake_up_interruptible(&ch->port.open_wait);
2380 2380
2381 } /* End if channel valid */ 2381 } /* End if channel valid */
2382} 2382}
@@ -2386,13 +2386,13 @@ static void do_softint(struct work_struct *work)
2386 struct channel *ch = container_of(work, struct channel, tqueue); 2386 struct channel *ch = container_of(work, struct channel, tqueue);
2387 /* Called in response to a modem change event */ 2387 /* Called in response to a modem change event */
2388 if (ch && ch->magic == EPCA_MAGIC) { 2388 if (ch && ch->magic == EPCA_MAGIC) {
2389 struct tty_struct *tty = ch->tty; 2389 struct tty_struct *tty = ch->port.tty;
2390 2390
2391 if (tty && tty->driver_data) { 2391 if (tty && tty->driver_data) {
2392 if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { 2392 if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) {
2393 tty_hangup(tty); 2393 tty_hangup(tty);
2394 wake_up_interruptible(&ch->open_wait); 2394 wake_up_interruptible(&ch->port.open_wait);
2395 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; 2395 ch->port.flags &= ~ASYNC_NORMAL_ACTIVE;
2396 } 2396 }
2397 } 2397 }
2398 } 2398 }
diff --git a/drivers/char/epca.h b/drivers/char/epca.h
index 3c77c02b5d65..d414bf2dbf7c 100644
--- a/drivers/char/epca.h
+++ b/drivers/char/epca.h
@@ -84,6 +84,7 @@ static char *board_desc[] =
84struct channel 84struct channel
85{ 85{
86 long magic; 86 long magic;
87 struct tty_port port;
87 unsigned char boardnum; 88 unsigned char boardnum;
88 unsigned char channelnum; 89 unsigned char channelnum;
89 unsigned char omodem; /* FEP output modem status */ 90 unsigned char omodem; /* FEP output modem status */
@@ -117,10 +118,7 @@ struct channel
117 unsigned short rxbufhead; 118 unsigned short rxbufhead;
118 unsigned short rxbufsize; 119 unsigned short rxbufsize;
119 int close_delay; 120 int close_delay;
120 int count;
121 int blocked_open;
122 unsigned long event; 121 unsigned long event;
123 int asyncflags;
124 uint dev; 122 uint dev;
125 unsigned long statusflags; 123 unsigned long statusflags;
126 unsigned long c_iflag; 124 unsigned long c_iflag;
@@ -132,9 +130,6 @@ struct channel
132 struct board_info *board; 130 struct board_info *board;
133 struct board_chan __iomem *brdchan; 131 struct board_chan __iomem *brdchan;
134 struct digi_struct digiext; 132 struct digi_struct digiext;
135 struct tty_struct *tty;
136 wait_queue_head_t open_wait;
137 wait_queue_head_t close_wait;
138 struct work_struct tqueue; 133 struct work_struct tqueue;
139 struct global_data __iomem *mailbox; 134 struct global_data __iomem *mailbox;
140}; 135};