aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/mxser.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/mxser.c')
-rw-r--r--drivers/char/mxser.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index dbf8d52f31d0..5e28d39b9e81 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -48,7 +48,7 @@
48 48
49#include "mxser.h" 49#include "mxser.h"
50 50
51#define MXSER_VERSION "2.0.4" /* 1.12 */ 51#define MXSER_VERSION "2.0.5" /* 1.14 */
52#define MXSERMAJOR 174 52#define MXSERMAJOR 174
53 53
54#define MXSER_BOARDS 4 /* Max. boards */ 54#define MXSER_BOARDS 4 /* Max. boards */
@@ -69,6 +69,7 @@
69#define PCI_DEVICE_ID_POS104UL 0x1044 69#define PCI_DEVICE_ID_POS104UL 0x1044
70#define PCI_DEVICE_ID_CB108 0x1080 70#define PCI_DEVICE_ID_CB108 0x1080
71#define PCI_DEVICE_ID_CP102UF 0x1023 71#define PCI_DEVICE_ID_CP102UF 0x1023
72#define PCI_DEVICE_ID_CP112UL 0x1120
72#define PCI_DEVICE_ID_CB114 0x1142 73#define PCI_DEVICE_ID_CB114 0x1142
73#define PCI_DEVICE_ID_CP114UL 0x1143 74#define PCI_DEVICE_ID_CP114UL 0x1143
74#define PCI_DEVICE_ID_CB134I 0x1341 75#define PCI_DEVICE_ID_CB134I 0x1341
@@ -139,7 +140,8 @@ static const struct mxser_cardinfo mxser_cards[] = {
139 { "CP-138U series", 8, }, 140 { "CP-138U series", 8, },
140 { "POS-104UL series", 4, }, 141 { "POS-104UL series", 4, },
141 { "CP-114UL series", 4, }, 142 { "CP-114UL series", 4, },
142/*30*/ { "CP-102UF series", 2, } 143/*30*/ { "CP-102UF series", 2, },
144 { "CP-112UL series", 2, },
143}; 145};
144 146
145/* driver_data correspond to the lines in the structure above 147/* driver_data correspond to the lines in the structure above
@@ -170,6 +172,7 @@ static struct pci_device_id mxser_pcibrds[] = {
170 { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL), .driver_data = 28 }, 172 { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL), .driver_data = 28 },
171 { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL), .driver_data = 29 }, 173 { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL), .driver_data = 29 },
172 { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF), .driver_data = 30 }, 174 { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF), .driver_data = 30 },
175 { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP112UL), .driver_data = 31 },
173 { } 176 { }
174}; 177};
175MODULE_DEVICE_TABLE(pci, mxser_pcibrds); 178MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
@@ -258,7 +261,6 @@ struct mxser_port {
258 struct mxser_mon mon_data; 261 struct mxser_mon mon_data;
259 262
260 spinlock_t slock; 263 spinlock_t slock;
261 wait_queue_head_t delta_msr_wait;
262}; 264};
263 265
264struct mxser_board { 266struct mxser_board {
@@ -818,7 +820,7 @@ static void mxser_check_modem_status(struct tty_struct *tty,
818 if (status & UART_MSR_DCTS) 820 if (status & UART_MSR_DCTS)
819 port->icount.cts++; 821 port->icount.cts++;
820 port->mon_data.modem_status = status; 822 port->mon_data.modem_status = status;
821 wake_up_interruptible(&port->delta_msr_wait); 823 wake_up_interruptible(&port->port.delta_msr_wait);
822 824
823 if ((port->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { 825 if ((port->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
824 if (status & UART_MSR_DCD) 826 if (status & UART_MSR_DCD)
@@ -973,7 +975,7 @@ static void mxser_shutdown(struct tty_struct *tty)
973 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq 975 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
974 * here so the queue might never be waken up 976 * here so the queue might never be waken up
975 */ 977 */
976 wake_up_interruptible(&info->delta_msr_wait); 978 wake_up_interruptible(&info->port.delta_msr_wait);
977 979
978 /* 980 /*
979 * Free the IRQ, if necessary 981 * Free the IRQ, if necessary
@@ -1073,34 +1075,17 @@ static void mxser_flush_buffer(struct tty_struct *tty)
1073} 1075}
1074 1076
1075 1077
1076/* 1078static void mxser_close_port(struct tty_struct *tty, struct tty_port *port)
1077 * This routine is called when the serial port gets closed. First, we
1078 * wait for the last remaining data to be sent. Then, we unlink its
1079 * async structure from the interrupt chain if necessary, and we free
1080 * that IRQ if nothing is left in the chain.
1081 */
1082static void mxser_close(struct tty_struct *tty, struct file *filp)
1083{ 1079{
1084 struct mxser_port *info = tty->driver_data; 1080 struct mxser_port *info = container_of(port, struct mxser_port, port);
1085 struct tty_port *port = &info->port;
1086
1087 unsigned long timeout; 1081 unsigned long timeout;
1088
1089 if (tty->index == MXSER_PORTS)
1090 return;
1091 if (!info)
1092 return;
1093
1094 if (tty_port_close_start(port, tty, filp) == 0)
1095 return;
1096
1097 /* 1082 /*
1098 * Save the termios structure, since this port may have 1083 * Save the termios structure, since this port may have
1099 * separate termios for callout and dialin. 1084 * separate termios for callout and dialin.
1100 * 1085 *
1101 * FIXME: Can this go ? 1086 * FIXME: Can this go ?
1102 */ 1087 */
1103 if (info->port.flags & ASYNC_NORMAL_ACTIVE) 1088 if (port->flags & ASYNC_NORMAL_ACTIVE)
1104 info->normal_termios = *tty->termios; 1089 info->normal_termios = *tty->termios;
1105 /* 1090 /*
1106 * At this point we stop accepting input. To do this, we 1091 * At this point we stop accepting input. To do this, we
@@ -1112,7 +1097,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1112 if (info->board->chip_flag) 1097 if (info->board->chip_flag)
1113 info->IER &= ~MOXA_MUST_RECV_ISR; 1098 info->IER &= ~MOXA_MUST_RECV_ISR;
1114 1099
1115 if (info->port.flags & ASYNC_INITIALIZED) { 1100 if (port->flags & ASYNC_INITIALIZED) {
1116 outb(info->IER, info->ioaddr + UART_IER); 1101 outb(info->IER, info->ioaddr + UART_IER);
1117 /* 1102 /*
1118 * Before we drop DTR, make sure the UART transmitter 1103 * Before we drop DTR, make sure the UART transmitter
@@ -1127,8 +1112,26 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1127 } 1112 }
1128 } 1113 }
1129 mxser_shutdown(tty); 1114 mxser_shutdown(tty);
1130 mxser_flush_buffer(tty);
1131 1115
1116}
1117
1118/*
1119 * This routine is called when the serial port gets closed. First, we
1120 * wait for the last remaining data to be sent. Then, we unlink its
1121 * async structure from the interrupt chain if necessary, and we free
1122 * that IRQ if nothing is left in the chain.
1123 */
1124static void mxser_close(struct tty_struct *tty, struct file *filp)
1125{
1126 struct mxser_port *info = tty->driver_data;
1127 struct tty_port *port = &info->port;
1128
1129 if (tty->index == MXSER_PORTS)
1130 return;
1131 if (tty_port_close_start(port, tty, filp) == 0)
1132 return;
1133 mxser_close_port(tty, port);
1134 mxser_flush_buffer(tty);
1132 /* Right now the tty_port set is done outside of the close_end helper 1135 /* Right now the tty_port set is done outside of the close_end helper
1133 as we don't yet have everyone using refcounts */ 1136 as we don't yet have everyone using refcounts */
1134 tty_port_close_end(port, tty); 1137 tty_port_close_end(port, tty);
@@ -1761,7 +1764,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1761 cnow = info->icount; /* note the counters on entry */ 1764 cnow = info->icount; /* note the counters on entry */
1762 spin_unlock_irqrestore(&info->slock, flags); 1765 spin_unlock_irqrestore(&info->slock, flags);
1763 1766
1764 return wait_event_interruptible(info->delta_msr_wait, 1767 return wait_event_interruptible(info->port.delta_msr_wait,
1765 mxser_cflags_changed(info, arg, &cnow)); 1768 mxser_cflags_changed(info, arg, &cnow));
1766 /* 1769 /*
1767 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1770 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
@@ -1803,7 +1806,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1803 1806
1804 lock_kernel(); 1807 lock_kernel();
1805 len = mxser_chars_in_buffer(tty); 1808 len = mxser_chars_in_buffer(tty);
1806 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT; 1809 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_THRE;
1807 len += (lsr ? 0 : 1); 1810 len += (lsr ? 0 : 1);
1808 unlock_kernel(); 1811 unlock_kernel();
1809 1812
@@ -2413,7 +2416,6 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
2413 info->port.close_delay = 5 * HZ / 10; 2416 info->port.close_delay = 5 * HZ / 10;
2414 info->port.closing_wait = 30 * HZ; 2417 info->port.closing_wait = 30 * HZ;
2415 info->normal_termios = mxvar_sdriver->init_termios; 2418 info->normal_termios = mxvar_sdriver->init_termios;
2416 init_waitqueue_head(&info->delta_msr_wait);
2417 memset(&info->mon_data, 0, sizeof(struct mxser_mon)); 2419 memset(&info->mon_data, 0, sizeof(struct mxser_mon));
2418 info->err_shadow = 0; 2420 info->err_shadow = 0;
2419 spin_lock_init(&info->slock); 2421 spin_lock_init(&info->slock);