diff options
author | Alan Cox <alan@redhat.com> | 2008-07-16 16:56:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-20 20:12:37 -0400 |
commit | 8fb06c771399b8d51d724756411108e9abe2a85a (patch) | |
tree | 8f1bfa4d03c545def4968141420c727074d89da2 /drivers/char/synclink_gt.c | |
parent | f8ae47641611fcdf175ab8bbe89054731b16971d (diff) |
synclink: use tty_port
Switch the synclink ports to use the new tty_port structure
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/synclink_gt.c')
-rw-r--r-- | drivers/char/synclink_gt.c | 201 |
1 files changed, 97 insertions, 104 deletions
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index e473778cd6fa..fc71d9819165 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -244,11 +244,11 @@ struct _input_signal_events { | |||
244 | */ | 244 | */ |
245 | struct slgt_info { | 245 | struct slgt_info { |
246 | void *if_ptr; /* General purpose pointer (used by SPPP) */ | 246 | void *if_ptr; /* General purpose pointer (used by SPPP) */ |
247 | struct tty_port port; | ||
247 | 248 | ||
248 | struct slgt_info *next_device; /* device list link */ | 249 | struct slgt_info *next_device; /* device list link */ |
249 | 250 | ||
250 | int magic; | 251 | int magic; |
251 | int flags; | ||
252 | 252 | ||
253 | char device_name[25]; | 253 | char device_name[25]; |
254 | struct pci_dev *pdev; | 254 | struct pci_dev *pdev; |
@@ -260,23 +260,17 @@ struct slgt_info { | |||
260 | /* array of pointers to port contexts on this adapter */ | 260 | /* array of pointers to port contexts on this adapter */ |
261 | struct slgt_info *port_array[SLGT_MAX_PORTS]; | 261 | struct slgt_info *port_array[SLGT_MAX_PORTS]; |
262 | 262 | ||
263 | int count; /* count of opens */ | ||
264 | int line; /* tty line instance number */ | 263 | int line; /* tty line instance number */ |
265 | unsigned short close_delay; | 264 | unsigned short close_delay; |
266 | unsigned short closing_wait; /* time to wait before closing */ | 265 | unsigned short closing_wait; /* time to wait before closing */ |
267 | 266 | ||
268 | struct mgsl_icount icount; | 267 | struct mgsl_icount icount; |
269 | 268 | ||
270 | struct tty_struct *tty; | ||
271 | int timeout; | 269 | int timeout; |
272 | int x_char; /* xon/xoff character */ | 270 | int x_char; /* xon/xoff character */ |
273 | int blocked_open; /* # of blocked opens */ | ||
274 | unsigned int read_status_mask; | 271 | unsigned int read_status_mask; |
275 | unsigned int ignore_status_mask; | 272 | unsigned int ignore_status_mask; |
276 | 273 | ||
277 | wait_queue_head_t open_wait; | ||
278 | wait_queue_head_t close_wait; | ||
279 | |||
280 | wait_queue_head_t status_event_wait_q; | 274 | wait_queue_head_t status_event_wait_q; |
281 | wait_queue_head_t event_wait_q; | 275 | wait_queue_head_t event_wait_q; |
282 | struct timer_list tx_timer; | 276 | struct timer_list tx_timer; |
@@ -672,20 +666,20 @@ static int open(struct tty_struct *tty, struct file *filp) | |||
672 | } | 666 | } |
673 | 667 | ||
674 | tty->driver_data = info; | 668 | tty->driver_data = info; |
675 | info->tty = tty; | 669 | info->port.tty = tty; |
676 | 670 | ||
677 | DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->count)); | 671 | DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count)); |
678 | 672 | ||
679 | /* If port is closing, signal caller to try again */ | 673 | /* If port is closing, signal caller to try again */ |
680 | if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ | 674 | if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){ |
681 | if (info->flags & ASYNC_CLOSING) | 675 | if (info->port.flags & ASYNC_CLOSING) |
682 | interruptible_sleep_on(&info->close_wait); | 676 | interruptible_sleep_on(&info->port.close_wait); |
683 | retval = ((info->flags & ASYNC_HUP_NOTIFY) ? | 677 | retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ? |
684 | -EAGAIN : -ERESTARTSYS); | 678 | -EAGAIN : -ERESTARTSYS); |
685 | goto cleanup; | 679 | goto cleanup; |
686 | } | 680 | } |
687 | 681 | ||
688 | info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 682 | info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
689 | 683 | ||
690 | spin_lock_irqsave(&info->netlock, flags); | 684 | spin_lock_irqsave(&info->netlock, flags); |
691 | if (info->netcount) { | 685 | if (info->netcount) { |
@@ -693,10 +687,10 @@ static int open(struct tty_struct *tty, struct file *filp) | |||
693 | spin_unlock_irqrestore(&info->netlock, flags); | 687 | spin_unlock_irqrestore(&info->netlock, flags); |
694 | goto cleanup; | 688 | goto cleanup; |
695 | } | 689 | } |
696 | info->count++; | 690 | info->port.count++; |
697 | spin_unlock_irqrestore(&info->netlock, flags); | 691 | spin_unlock_irqrestore(&info->netlock, flags); |
698 | 692 | ||
699 | if (info->count == 1) { | 693 | if (info->port.count == 1) { |
700 | /* 1st open on this device, init hardware */ | 694 | /* 1st open on this device, init hardware */ |
701 | retval = startup(info); | 695 | retval = startup(info); |
702 | if (retval < 0) | 696 | if (retval < 0) |
@@ -714,9 +708,9 @@ static int open(struct tty_struct *tty, struct file *filp) | |||
714 | cleanup: | 708 | cleanup: |
715 | if (retval) { | 709 | if (retval) { |
716 | if (tty->count == 1) | 710 | if (tty->count == 1) |
717 | info->tty = NULL; /* tty layer will release tty struct */ | 711 | info->port.tty = NULL; /* tty layer will release tty struct */ |
718 | if(info->count) | 712 | if(info->port.count) |
719 | info->count--; | 713 | info->port.count--; |
720 | } | 714 | } |
721 | 715 | ||
722 | DBGINFO(("%s open rc=%d\n", info->device_name, retval)); | 716 | DBGINFO(("%s open rc=%d\n", info->device_name, retval)); |
@@ -729,32 +723,32 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
729 | 723 | ||
730 | if (sanity_check(info, tty->name, "close")) | 724 | if (sanity_check(info, tty->name, "close")) |
731 | return; | 725 | return; |
732 | DBGINFO(("%s close entry, count=%d\n", info->device_name, info->count)); | 726 | DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count)); |
733 | 727 | ||
734 | if (!info->count) | 728 | if (!info->port.count) |
735 | return; | 729 | return; |
736 | 730 | ||
737 | if (tty_hung_up_p(filp)) | 731 | if (tty_hung_up_p(filp)) |
738 | goto cleanup; | 732 | goto cleanup; |
739 | 733 | ||
740 | if ((tty->count == 1) && (info->count != 1)) { | 734 | if ((tty->count == 1) && (info->port.count != 1)) { |
741 | /* | 735 | /* |
742 | * tty->count is 1 and the tty structure will be freed. | 736 | * tty->count is 1 and the tty structure will be freed. |
743 | * info->count should be one in this case. | 737 | * info->port.count should be one in this case. |
744 | * if it's not, correct it so that the port is shutdown. | 738 | * if it's not, correct it so that the port is shutdown. |
745 | */ | 739 | */ |
746 | DBGERR(("%s close: bad refcount; tty->count=1, " | 740 | DBGERR(("%s close: bad refcount; tty->count=1, " |
747 | "info->count=%d\n", info->device_name, info->count)); | 741 | "info->port.count=%d\n", info->device_name, info->port.count)); |
748 | info->count = 1; | 742 | info->port.count = 1; |
749 | } | 743 | } |
750 | 744 | ||
751 | info->count--; | 745 | info->port.count--; |
752 | 746 | ||
753 | /* if at least one open remaining, leave hardware active */ | 747 | /* if at least one open remaining, leave hardware active */ |
754 | if (info->count) | 748 | if (info->port.count) |
755 | goto cleanup; | 749 | goto cleanup; |
756 | 750 | ||
757 | info->flags |= ASYNC_CLOSING; | 751 | info->port.flags |= ASYNC_CLOSING; |
758 | 752 | ||
759 | /* set tty->closing to notify line discipline to | 753 | /* set tty->closing to notify line discipline to |
760 | * only process XON/XOFF characters. Only the N_TTY | 754 | * only process XON/XOFF characters. Only the N_TTY |
@@ -769,7 +763,7 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
769 | tty_wait_until_sent(tty, info->closing_wait); | 763 | tty_wait_until_sent(tty, info->closing_wait); |
770 | } | 764 | } |
771 | 765 | ||
772 | if (info->flags & ASYNC_INITIALIZED) | 766 | if (info->port.flags & ASYNC_INITIALIZED) |
773 | wait_until_sent(tty, info->timeout); | 767 | wait_until_sent(tty, info->timeout); |
774 | flush_buffer(tty); | 768 | flush_buffer(tty); |
775 | tty_ldisc_flush(tty); | 769 | tty_ldisc_flush(tty); |
@@ -777,21 +771,21 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
777 | shutdown(info); | 771 | shutdown(info); |
778 | 772 | ||
779 | tty->closing = 0; | 773 | tty->closing = 0; |
780 | info->tty = NULL; | 774 | info->port.tty = NULL; |
781 | 775 | ||
782 | if (info->blocked_open) { | 776 | if (info->port.blocked_open) { |
783 | if (info->close_delay) { | 777 | if (info->close_delay) { |
784 | msleep_interruptible(jiffies_to_msecs(info->close_delay)); | 778 | msleep_interruptible(jiffies_to_msecs(info->close_delay)); |
785 | } | 779 | } |
786 | wake_up_interruptible(&info->open_wait); | 780 | wake_up_interruptible(&info->port.open_wait); |
787 | } | 781 | } |
788 | 782 | ||
789 | info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | 783 | info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); |
790 | 784 | ||
791 | wake_up_interruptible(&info->close_wait); | 785 | wake_up_interruptible(&info->port.close_wait); |
792 | 786 | ||
793 | cleanup: | 787 | cleanup: |
794 | DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->count)); | 788 | DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count)); |
795 | } | 789 | } |
796 | 790 | ||
797 | static void hangup(struct tty_struct *tty) | 791 | static void hangup(struct tty_struct *tty) |
@@ -805,11 +799,11 @@ static void hangup(struct tty_struct *tty) | |||
805 | flush_buffer(tty); | 799 | flush_buffer(tty); |
806 | shutdown(info); | 800 | shutdown(info); |
807 | 801 | ||
808 | info->count = 0; | 802 | info->port.count = 0; |
809 | info->flags &= ~ASYNC_NORMAL_ACTIVE; | 803 | info->port.flags &= ~ASYNC_NORMAL_ACTIVE; |
810 | info->tty = NULL; | 804 | info->port.tty = NULL; |
811 | 805 | ||
812 | wake_up_interruptible(&info->open_wait); | 806 | wake_up_interruptible(&info->port.open_wait); |
813 | } | 807 | } |
814 | 808 | ||
815 | static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) | 809 | static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) |
@@ -959,7 +953,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout) | |||
959 | if (sanity_check(info, tty->name, "wait_until_sent")) | 953 | if (sanity_check(info, tty->name, "wait_until_sent")) |
960 | return; | 954 | return; |
961 | DBGINFO(("%s wait_until_sent entry\n", info->device_name)); | 955 | DBGINFO(("%s wait_until_sent entry\n", info->device_name)); |
962 | if (!(info->flags & ASYNC_INITIALIZED)) | 956 | if (!(info->port.flags & ASYNC_INITIALIZED)) |
963 | goto exit; | 957 | goto exit; |
964 | 958 | ||
965 | orig_jiffies = jiffies; | 959 | orig_jiffies = jiffies; |
@@ -1500,7 +1494,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding, | |||
1500 | unsigned short new_crctype; | 1494 | unsigned short new_crctype; |
1501 | 1495 | ||
1502 | /* return error if TTY interface open */ | 1496 | /* return error if TTY interface open */ |
1503 | if (info->count) | 1497 | if (info->port.count) |
1504 | return -EBUSY; | 1498 | return -EBUSY; |
1505 | 1499 | ||
1506 | DBGINFO(("%s hdlcdev_attach\n", info->device_name)); | 1500 | DBGINFO(("%s hdlcdev_attach\n", info->device_name)); |
@@ -1600,7 +1594,7 @@ static int hdlcdev_open(struct net_device *dev) | |||
1600 | 1594 | ||
1601 | /* arbitrate between network and tty opens */ | 1595 | /* arbitrate between network and tty opens */ |
1602 | spin_lock_irqsave(&info->netlock, flags); | 1596 | spin_lock_irqsave(&info->netlock, flags); |
1603 | if (info->count != 0 || info->netcount != 0) { | 1597 | if (info->port.count != 0 || info->netcount != 0) { |
1604 | DBGINFO(("%s hdlc_open busy\n", dev->name)); | 1598 | DBGINFO(("%s hdlc_open busy\n", dev->name)); |
1605 | spin_unlock_irqrestore(&info->netlock, flags); | 1599 | spin_unlock_irqrestore(&info->netlock, flags); |
1606 | return -EBUSY; | 1600 | return -EBUSY; |
@@ -1685,7 +1679,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
1685 | DBGINFO(("%s hdlcdev_ioctl\n", dev->name)); | 1679 | DBGINFO(("%s hdlcdev_ioctl\n", dev->name)); |
1686 | 1680 | ||
1687 | /* return error if TTY interface open */ | 1681 | /* return error if TTY interface open */ |
1688 | if (info->count) | 1682 | if (info->port.count) |
1689 | return -EBUSY; | 1683 | return -EBUSY; |
1690 | 1684 | ||
1691 | if (cmd != SIOCWANDEV) | 1685 | if (cmd != SIOCWANDEV) |
@@ -1906,7 +1900,7 @@ static void hdlcdev_exit(struct slgt_info *info) | |||
1906 | */ | 1900 | */ |
1907 | static void rx_async(struct slgt_info *info) | 1901 | static void rx_async(struct slgt_info *info) |
1908 | { | 1902 | { |
1909 | struct tty_struct *tty = info->tty; | 1903 | struct tty_struct *tty = info->port.tty; |
1910 | struct mgsl_icount *icount = &info->icount; | 1904 | struct mgsl_icount *icount = &info->icount; |
1911 | unsigned int start, end; | 1905 | unsigned int start, end; |
1912 | unsigned char *p; | 1906 | unsigned char *p; |
@@ -2057,7 +2051,7 @@ static void bh_handler(struct work_struct *work) | |||
2057 | 2051 | ||
2058 | static void bh_transmit(struct slgt_info *info) | 2052 | static void bh_transmit(struct slgt_info *info) |
2059 | { | 2053 | { |
2060 | struct tty_struct *tty = info->tty; | 2054 | struct tty_struct *tty = info->port.tty; |
2061 | 2055 | ||
2062 | DBGBH(("%s bh_transmit\n", info->device_name)); | 2056 | DBGBH(("%s bh_transmit\n", info->device_name)); |
2063 | if (tty) | 2057 | if (tty) |
@@ -2103,17 +2097,17 @@ static void cts_change(struct slgt_info *info, unsigned short status) | |||
2103 | wake_up_interruptible(&info->event_wait_q); | 2097 | wake_up_interruptible(&info->event_wait_q); |
2104 | info->pending_bh |= BH_STATUS; | 2098 | info->pending_bh |= BH_STATUS; |
2105 | 2099 | ||
2106 | if (info->flags & ASYNC_CTS_FLOW) { | 2100 | if (info->port.flags & ASYNC_CTS_FLOW) { |
2107 | if (info->tty) { | 2101 | if (info->port.tty) { |
2108 | if (info->tty->hw_stopped) { | 2102 | if (info->port.tty->hw_stopped) { |
2109 | if (info->signals & SerialSignal_CTS) { | 2103 | if (info->signals & SerialSignal_CTS) { |
2110 | info->tty->hw_stopped = 0; | 2104 | info->port.tty->hw_stopped = 0; |
2111 | info->pending_bh |= BH_TRANSMIT; | 2105 | info->pending_bh |= BH_TRANSMIT; |
2112 | return; | 2106 | return; |
2113 | } | 2107 | } |
2114 | } else { | 2108 | } else { |
2115 | if (!(info->signals & SerialSignal_CTS)) | 2109 | if (!(info->signals & SerialSignal_CTS)) |
2116 | info->tty->hw_stopped = 1; | 2110 | info->port.tty->hw_stopped = 1; |
2117 | } | 2111 | } |
2118 | } | 2112 | } |
2119 | } | 2113 | } |
@@ -2146,12 +2140,12 @@ static void dcd_change(struct slgt_info *info, unsigned short status) | |||
2146 | wake_up_interruptible(&info->event_wait_q); | 2140 | wake_up_interruptible(&info->event_wait_q); |
2147 | info->pending_bh |= BH_STATUS; | 2141 | info->pending_bh |= BH_STATUS; |
2148 | 2142 | ||
2149 | if (info->flags & ASYNC_CHECK_CD) { | 2143 | if (info->port.flags & ASYNC_CHECK_CD) { |
2150 | if (info->signals & SerialSignal_DCD) | 2144 | if (info->signals & SerialSignal_DCD) |
2151 | wake_up_interruptible(&info->open_wait); | 2145 | wake_up_interruptible(&info->port.open_wait); |
2152 | else { | 2146 | else { |
2153 | if (info->tty) | 2147 | if (info->port.tty) |
2154 | tty_hangup(info->tty); | 2148 | tty_hangup(info->port.tty); |
2155 | } | 2149 | } |
2156 | } | 2150 | } |
2157 | } | 2151 | } |
@@ -2194,12 +2188,12 @@ static void isr_serial(struct slgt_info *info) | |||
2194 | if ((status & IRQ_RXBREAK) && (status & RXBREAK)) { | 2188 | if ((status & IRQ_RXBREAK) && (status & RXBREAK)) { |
2195 | info->icount.brk++; | 2189 | info->icount.brk++; |
2196 | /* process break detection if tty control allows */ | 2190 | /* process break detection if tty control allows */ |
2197 | if (info->tty) { | 2191 | if (info->port.tty) { |
2198 | if (!(status & info->ignore_status_mask)) { | 2192 | if (!(status & info->ignore_status_mask)) { |
2199 | if (info->read_status_mask & MASK_BREAK) { | 2193 | if (info->read_status_mask & MASK_BREAK) { |
2200 | tty_insert_flip_char(info->tty, 0, TTY_BREAK); | 2194 | tty_insert_flip_char(info->port.tty, 0, TTY_BREAK); |
2201 | if (info->flags & ASYNC_SAK) | 2195 | if (info->port.flags & ASYNC_SAK) |
2202 | do_SAK(info->tty); | 2196 | do_SAK(info->port.tty); |
2203 | } | 2197 | } |
2204 | } | 2198 | } |
2205 | } | 2199 | } |
@@ -2319,7 +2313,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status) | |||
2319 | else | 2313 | else |
2320 | #endif | 2314 | #endif |
2321 | { | 2315 | { |
2322 | if (info->tty && (info->tty->stopped || info->tty->hw_stopped)) { | 2316 | if (info->port.tty && (info->port.tty->stopped || info->port.tty->hw_stopped)) { |
2323 | tx_stop(info); | 2317 | tx_stop(info); |
2324 | return; | 2318 | return; |
2325 | } | 2319 | } |
@@ -2395,7 +2389,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id) | |||
2395 | for(i=0; i < info->port_count ; i++) { | 2389 | for(i=0; i < info->port_count ; i++) { |
2396 | struct slgt_info *port = info->port_array[i]; | 2390 | struct slgt_info *port = info->port_array[i]; |
2397 | 2391 | ||
2398 | if (port && (port->count || port->netcount) && | 2392 | if (port && (port->port.count || port->netcount) && |
2399 | port->pending_bh && !port->bh_running && | 2393 | port->pending_bh && !port->bh_running && |
2400 | !port->bh_requested) { | 2394 | !port->bh_requested) { |
2401 | DBGISR(("%s bh queued\n", port->device_name)); | 2395 | DBGISR(("%s bh queued\n", port->device_name)); |
@@ -2414,7 +2408,7 @@ static int startup(struct slgt_info *info) | |||
2414 | { | 2408 | { |
2415 | DBGINFO(("%s startup\n", info->device_name)); | 2409 | DBGINFO(("%s startup\n", info->device_name)); |
2416 | 2410 | ||
2417 | if (info->flags & ASYNC_INITIALIZED) | 2411 | if (info->port.flags & ASYNC_INITIALIZED) |
2418 | return 0; | 2412 | return 0; |
2419 | 2413 | ||
2420 | if (!info->tx_buf) { | 2414 | if (!info->tx_buf) { |
@@ -2432,10 +2426,10 @@ static int startup(struct slgt_info *info) | |||
2432 | /* program hardware for current parameters */ | 2426 | /* program hardware for current parameters */ |
2433 | change_params(info); | 2427 | change_params(info); |
2434 | 2428 | ||
2435 | if (info->tty) | 2429 | if (info->port.tty) |
2436 | clear_bit(TTY_IO_ERROR, &info->tty->flags); | 2430 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); |
2437 | 2431 | ||
2438 | info->flags |= ASYNC_INITIALIZED; | 2432 | info->port.flags |= ASYNC_INITIALIZED; |
2439 | 2433 | ||
2440 | return 0; | 2434 | return 0; |
2441 | } | 2435 | } |
@@ -2447,7 +2441,7 @@ static void shutdown(struct slgt_info *info) | |||
2447 | { | 2441 | { |
2448 | unsigned long flags; | 2442 | unsigned long flags; |
2449 | 2443 | ||
2450 | if (!(info->flags & ASYNC_INITIALIZED)) | 2444 | if (!(info->port.flags & ASYNC_INITIALIZED)) |
2451 | return; | 2445 | return; |
2452 | 2446 | ||
2453 | DBGINFO(("%s shutdown\n", info->device_name)); | 2447 | DBGINFO(("%s shutdown\n", info->device_name)); |
@@ -2470,7 +2464,7 @@ static void shutdown(struct slgt_info *info) | |||
2470 | 2464 | ||
2471 | slgt_irq_off(info, IRQ_ALL | IRQ_MASTER); | 2465 | slgt_irq_off(info, IRQ_ALL | IRQ_MASTER); |
2472 | 2466 | ||
2473 | if (!info->tty || info->tty->termios->c_cflag & HUPCL) { | 2467 | if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) { |
2474 | info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS); | 2468 | info->signals &= ~(SerialSignal_DTR + SerialSignal_RTS); |
2475 | set_signals(info); | 2469 | set_signals(info); |
2476 | } | 2470 | } |
@@ -2479,10 +2473,10 @@ static void shutdown(struct slgt_info *info) | |||
2479 | 2473 | ||
2480 | spin_unlock_irqrestore(&info->lock,flags); | 2474 | spin_unlock_irqrestore(&info->lock,flags); |
2481 | 2475 | ||
2482 | if (info->tty) | 2476 | if (info->port.tty) |
2483 | set_bit(TTY_IO_ERROR, &info->tty->flags); | 2477 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); |
2484 | 2478 | ||
2485 | info->flags &= ~ASYNC_INITIALIZED; | 2479 | info->port.flags &= ~ASYNC_INITIALIZED; |
2486 | } | 2480 | } |
2487 | 2481 | ||
2488 | static void program_hw(struct slgt_info *info) | 2482 | static void program_hw(struct slgt_info *info) |
@@ -2511,7 +2505,7 @@ static void program_hw(struct slgt_info *info) | |||
2511 | get_signals(info); | 2505 | get_signals(info); |
2512 | 2506 | ||
2513 | if (info->netcount || | 2507 | if (info->netcount || |
2514 | (info->tty && info->tty->termios->c_cflag & CREAD)) | 2508 | (info->port.tty && info->port.tty->termios->c_cflag & CREAD)) |
2515 | rx_start(info); | 2509 | rx_start(info); |
2516 | 2510 | ||
2517 | spin_unlock_irqrestore(&info->lock,flags); | 2511 | spin_unlock_irqrestore(&info->lock,flags); |
@@ -2525,11 +2519,11 @@ static void change_params(struct slgt_info *info) | |||
2525 | unsigned cflag; | 2519 | unsigned cflag; |
2526 | int bits_per_char; | 2520 | int bits_per_char; |
2527 | 2521 | ||
2528 | if (!info->tty || !info->tty->termios) | 2522 | if (!info->port.tty || !info->port.tty->termios) |
2529 | return; | 2523 | return; |
2530 | DBGINFO(("%s change_params\n", info->device_name)); | 2524 | DBGINFO(("%s change_params\n", info->device_name)); |
2531 | 2525 | ||
2532 | cflag = info->tty->termios->c_cflag; | 2526 | cflag = info->port.tty->termios->c_cflag; |
2533 | 2527 | ||
2534 | /* if B0 rate (hangup) specified then negate DTR and RTS */ | 2528 | /* if B0 rate (hangup) specified then negate DTR and RTS */ |
2535 | /* otherwise assert DTR and RTS */ | 2529 | /* otherwise assert DTR and RTS */ |
@@ -2561,7 +2555,7 @@ static void change_params(struct slgt_info *info) | |||
2561 | bits_per_char = info->params.data_bits + | 2555 | bits_per_char = info->params.data_bits + |
2562 | info->params.stop_bits + 1; | 2556 | info->params.stop_bits + 1; |
2563 | 2557 | ||
2564 | info->params.data_rate = tty_get_baud_rate(info->tty); | 2558 | info->params.data_rate = tty_get_baud_rate(info->port.tty); |
2565 | 2559 | ||
2566 | if (info->params.data_rate) { | 2560 | if (info->params.data_rate) { |
2567 | info->timeout = (32*HZ*bits_per_char) / | 2561 | info->timeout = (32*HZ*bits_per_char) / |
@@ -2570,30 +2564,30 @@ static void change_params(struct slgt_info *info) | |||
2570 | info->timeout += HZ/50; /* Add .02 seconds of slop */ | 2564 | info->timeout += HZ/50; /* Add .02 seconds of slop */ |
2571 | 2565 | ||
2572 | if (cflag & CRTSCTS) | 2566 | if (cflag & CRTSCTS) |
2573 | info->flags |= ASYNC_CTS_FLOW; | 2567 | info->port.flags |= ASYNC_CTS_FLOW; |
2574 | else | 2568 | else |
2575 | info->flags &= ~ASYNC_CTS_FLOW; | 2569 | info->port.flags &= ~ASYNC_CTS_FLOW; |
2576 | 2570 | ||
2577 | if (cflag & CLOCAL) | 2571 | if (cflag & CLOCAL) |
2578 | info->flags &= ~ASYNC_CHECK_CD; | 2572 | info->port.flags &= ~ASYNC_CHECK_CD; |
2579 | else | 2573 | else |
2580 | info->flags |= ASYNC_CHECK_CD; | 2574 | info->port.flags |= ASYNC_CHECK_CD; |
2581 | 2575 | ||
2582 | /* process tty input control flags */ | 2576 | /* process tty input control flags */ |
2583 | 2577 | ||
2584 | info->read_status_mask = IRQ_RXOVER; | 2578 | info->read_status_mask = IRQ_RXOVER; |
2585 | if (I_INPCK(info->tty)) | 2579 | if (I_INPCK(info->port.tty)) |
2586 | info->read_status_mask |= MASK_PARITY | MASK_FRAMING; | 2580 | info->read_status_mask |= MASK_PARITY | MASK_FRAMING; |
2587 | if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) | 2581 | if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty)) |
2588 | info->read_status_mask |= MASK_BREAK; | 2582 | info->read_status_mask |= MASK_BREAK; |
2589 | if (I_IGNPAR(info->tty)) | 2583 | if (I_IGNPAR(info->port.tty)) |
2590 | info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING; | 2584 | info->ignore_status_mask |= MASK_PARITY | MASK_FRAMING; |
2591 | if (I_IGNBRK(info->tty)) { | 2585 | if (I_IGNBRK(info->port.tty)) { |
2592 | info->ignore_status_mask |= MASK_BREAK; | 2586 | info->ignore_status_mask |= MASK_BREAK; |
2593 | /* If ignoring parity and break indicators, ignore | 2587 | /* If ignoring parity and break indicators, ignore |
2594 | * overruns too. (For real raw support). | 2588 | * overruns too. (For real raw support). |
2595 | */ | 2589 | */ |
2596 | if (I_IGNPAR(info->tty)) | 2590 | if (I_IGNPAR(info->port.tty)) |
2597 | info->ignore_status_mask |= MASK_OVERRUN; | 2591 | info->ignore_status_mask |= MASK_OVERRUN; |
2598 | } | 2592 | } |
2599 | 2593 | ||
@@ -3144,7 +3138,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3144 | 3138 | ||
3145 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ | 3139 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ |
3146 | /* nonblock mode is set or port is not enabled */ | 3140 | /* nonblock mode is set or port is not enabled */ |
3147 | info->flags |= ASYNC_NORMAL_ACTIVE; | 3141 | info->port.flags |= ASYNC_NORMAL_ACTIVE; |
3148 | return 0; | 3142 | return 0; |
3149 | } | 3143 | } |
3150 | 3144 | ||
@@ -3153,21 +3147,21 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3153 | 3147 | ||
3154 | /* Wait for carrier detect and the line to become | 3148 | /* Wait for carrier detect and the line to become |
3155 | * free (i.e., not in use by the callout). While we are in | 3149 | * free (i.e., not in use by the callout). While we are in |
3156 | * this loop, info->count is dropped by one, so that | 3150 | * this loop, info->port.count is dropped by one, so that |
3157 | * close() knows when to free things. We restore it upon | 3151 | * close() knows when to free things. We restore it upon |
3158 | * exit, either normal or abnormal. | 3152 | * exit, either normal or abnormal. |
3159 | */ | 3153 | */ |
3160 | 3154 | ||
3161 | retval = 0; | 3155 | retval = 0; |
3162 | add_wait_queue(&info->open_wait, &wait); | 3156 | add_wait_queue(&info->port.open_wait, &wait); |
3163 | 3157 | ||
3164 | spin_lock_irqsave(&info->lock, flags); | 3158 | spin_lock_irqsave(&info->lock, flags); |
3165 | if (!tty_hung_up_p(filp)) { | 3159 | if (!tty_hung_up_p(filp)) { |
3166 | extra_count = true; | 3160 | extra_count = true; |
3167 | info->count--; | 3161 | info->port.count--; |
3168 | } | 3162 | } |
3169 | spin_unlock_irqrestore(&info->lock, flags); | 3163 | spin_unlock_irqrestore(&info->lock, flags); |
3170 | info->blocked_open++; | 3164 | info->port.blocked_open++; |
3171 | 3165 | ||
3172 | while (1) { | 3166 | while (1) { |
3173 | if ((tty->termios->c_cflag & CBAUD)) { | 3167 | if ((tty->termios->c_cflag & CBAUD)) { |
@@ -3179,8 +3173,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3179 | 3173 | ||
3180 | set_current_state(TASK_INTERRUPTIBLE); | 3174 | set_current_state(TASK_INTERRUPTIBLE); |
3181 | 3175 | ||
3182 | if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ | 3176 | if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){ |
3183 | retval = (info->flags & ASYNC_HUP_NOTIFY) ? | 3177 | retval = (info->port.flags & ASYNC_HUP_NOTIFY) ? |
3184 | -EAGAIN : -ERESTARTSYS; | 3178 | -EAGAIN : -ERESTARTSYS; |
3185 | break; | 3179 | break; |
3186 | } | 3180 | } |
@@ -3189,7 +3183,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3189 | get_signals(info); | 3183 | get_signals(info); |
3190 | spin_unlock_irqrestore(&info->lock,flags); | 3184 | spin_unlock_irqrestore(&info->lock,flags); |
3191 | 3185 | ||
3192 | if (!(info->flags & ASYNC_CLOSING) && | 3186 | if (!(info->port.flags & ASYNC_CLOSING) && |
3193 | (do_clocal || (info->signals & SerialSignal_DCD)) ) { | 3187 | (do_clocal || (info->signals & SerialSignal_DCD)) ) { |
3194 | break; | 3188 | break; |
3195 | } | 3189 | } |
@@ -3204,14 +3198,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3204 | } | 3198 | } |
3205 | 3199 | ||
3206 | set_current_state(TASK_RUNNING); | 3200 | set_current_state(TASK_RUNNING); |
3207 | remove_wait_queue(&info->open_wait, &wait); | 3201 | remove_wait_queue(&info->port.open_wait, &wait); |
3208 | 3202 | ||
3209 | if (extra_count) | 3203 | if (extra_count) |
3210 | info->count++; | 3204 | info->port.count++; |
3211 | info->blocked_open--; | 3205 | info->port.blocked_open--; |
3212 | 3206 | ||
3213 | if (!retval) | 3207 | if (!retval) |
3214 | info->flags |= ASYNC_NORMAL_ACTIVE; | 3208 | info->port.flags |= ASYNC_NORMAL_ACTIVE; |
3215 | 3209 | ||
3216 | DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval)); | 3210 | DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval)); |
3217 | return retval; | 3211 | return retval; |
@@ -3460,8 +3454,7 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev | |||
3460 | info->raw_rx_size = DMABUFSIZE; | 3454 | info->raw_rx_size = DMABUFSIZE; |
3461 | info->close_delay = 5*HZ/10; | 3455 | info->close_delay = 5*HZ/10; |
3462 | info->closing_wait = 30*HZ; | 3456 | info->closing_wait = 30*HZ; |
3463 | init_waitqueue_head(&info->open_wait); | 3457 | tty_port_init(&info->port); |
3464 | init_waitqueue_head(&info->close_wait); | ||
3465 | init_waitqueue_head(&info->status_event_wait_q); | 3458 | init_waitqueue_head(&info->status_event_wait_q); |
3466 | init_waitqueue_head(&info->event_wait_q); | 3459 | init_waitqueue_head(&info->event_wait_q); |
3467 | spin_lock_init(&info->netlock); | 3460 | spin_lock_init(&info->netlock); |
@@ -4505,7 +4498,7 @@ static bool rx_get_frame(struct slgt_info *info) | |||
4505 | unsigned short status; | 4498 | unsigned short status; |
4506 | unsigned int framesize = 0; | 4499 | unsigned int framesize = 0; |
4507 | unsigned long flags; | 4500 | unsigned long flags; |
4508 | struct tty_struct *tty = info->tty; | 4501 | struct tty_struct *tty = info->port.tty; |
4509 | unsigned char addr_field = 0xff; | 4502 | unsigned char addr_field = 0xff; |
4510 | unsigned int crc_size = 0; | 4503 | unsigned int crc_size = 0; |
4511 | 4504 | ||
@@ -4656,7 +4649,7 @@ static bool rx_get_buf(struct slgt_info *info) | |||
4656 | DBGDATA(info, info->rbufs[i].buf, count, "rx"); | 4649 | DBGDATA(info, info->rbufs[i].buf, count, "rx"); |
4657 | DBGINFO(("rx_get_buf size=%d\n", count)); | 4650 | DBGINFO(("rx_get_buf size=%d\n", count)); |
4658 | if (count) | 4651 | if (count) |
4659 | ldisc_receive_buf(info->tty, info->rbufs[i].buf, | 4652 | ldisc_receive_buf(info->port.tty, info->rbufs[i].buf, |
4660 | info->flag_buf, count); | 4653 | info->flag_buf, count); |
4661 | free_rbufs(info, i, i); | 4654 | free_rbufs(info, i, i); |
4662 | return true; | 4655 | return true; |
@@ -4765,11 +4758,11 @@ static int irq_test(struct slgt_info *info) | |||
4765 | { | 4758 | { |
4766 | unsigned long timeout; | 4759 | unsigned long timeout; |
4767 | unsigned long flags; | 4760 | unsigned long flags; |
4768 | struct tty_struct *oldtty = info->tty; | 4761 | struct tty_struct *oldtty = info->port.tty; |
4769 | u32 speed = info->params.data_rate; | 4762 | u32 speed = info->params.data_rate; |
4770 | 4763 | ||
4771 | info->params.data_rate = 921600; | 4764 | info->params.data_rate = 921600; |
4772 | info->tty = NULL; | 4765 | info->port.tty = NULL; |
4773 | 4766 | ||
4774 | spin_lock_irqsave(&info->lock, flags); | 4767 | spin_lock_irqsave(&info->lock, flags); |
4775 | async_mode(info); | 4768 | async_mode(info); |
@@ -4797,7 +4790,7 @@ static int irq_test(struct slgt_info *info) | |||
4797 | spin_unlock_irqrestore(&info->lock,flags); | 4790 | spin_unlock_irqrestore(&info->lock,flags); |
4798 | 4791 | ||
4799 | info->params.data_rate = speed; | 4792 | info->params.data_rate = speed; |
4800 | info->tty = oldtty; | 4793 | info->port.tty = oldtty; |
4801 | 4794 | ||
4802 | info->init_error = info->irq_occurred ? 0 : DiagStatus_IrqFailure; | 4795 | info->init_error = info->irq_occurred ? 0 : DiagStatus_IrqFailure; |
4803 | return info->irq_occurred ? 0 : -ENODEV; | 4796 | return info->irq_occurred ? 0 : -ENODEV; |
@@ -4837,7 +4830,7 @@ static int loopback_test(struct slgt_info *info) | |||
4837 | int rc = -ENODEV; | 4830 | int rc = -ENODEV; |
4838 | unsigned long flags; | 4831 | unsigned long flags; |
4839 | 4832 | ||
4840 | struct tty_struct *oldtty = info->tty; | 4833 | struct tty_struct *oldtty = info->port.tty; |
4841 | MGSL_PARAMS params; | 4834 | MGSL_PARAMS params; |
4842 | 4835 | ||
4843 | memcpy(¶ms, &info->params, sizeof(params)); | 4836 | memcpy(¶ms, &info->params, sizeof(params)); |
@@ -4845,7 +4838,7 @@ static int loopback_test(struct slgt_info *info) | |||
4845 | info->params.mode = MGSL_MODE_ASYNC; | 4838 | info->params.mode = MGSL_MODE_ASYNC; |
4846 | info->params.data_rate = 921600; | 4839 | info->params.data_rate = 921600; |
4847 | info->params.loopback = 1; | 4840 | info->params.loopback = 1; |
4848 | info->tty = NULL; | 4841 | info->port.tty = NULL; |
4849 | 4842 | ||
4850 | /* build and send transmit frame */ | 4843 | /* build and send transmit frame */ |
4851 | for (count = 0; count < TESTFRAMESIZE; ++count) | 4844 | for (count = 0; count < TESTFRAMESIZE; ++count) |
@@ -4883,7 +4876,7 @@ static int loopback_test(struct slgt_info *info) | |||
4883 | spin_unlock_irqrestore(&info->lock,flags); | 4876 | spin_unlock_irqrestore(&info->lock,flags); |
4884 | 4877 | ||
4885 | memcpy(&info->params, ¶ms, sizeof(info->params)); | 4878 | memcpy(&info->params, ¶ms, sizeof(info->params)); |
4886 | info->tty = oldtty; | 4879 | info->port.tty = oldtty; |
4887 | 4880 | ||
4888 | info->init_error = rc ? DiagStatus_DmaFailure : 0; | 4881 | info->init_error = rc ? DiagStatus_DmaFailure : 0; |
4889 | return rc; | 4882 | return rc; |