Commit 52d417388d154f68f8ab753de03b1fba1814de81

Authored by Alan Cox
Committed by Linus Torvalds
1 parent 7a4d29f426

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>

Showing 2 changed files with 54 additions and 59 deletions Side-by-side Diff

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