aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mos7840.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-22 06:09:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 16:03:22 -0400
commit95da310e66ee8090119596c70ca8432e57f9a97f (patch)
tree7f18c30e9c9ad4d7d53df6453fa338be06f09a85 /drivers/usb/serial/mos7840.c
parent1aa3692da57c773e5c76de55c5c4a953962d360e (diff)
usb_serial: API all change
USB serial likes to use port->tty back pointers for the real work it does and to do so without any actual locking. Unfortunately when you consider hangup events, hangup/parallel reopen or even worse hangup followed by parallel close events the tty->port and port->tty pointers are not guaranteed to be the same as port->tty is the active tty while tty->port is the port the tty may or may not still be attached to. So rework the entire API to pass the tty struct. For console cases we need to pass both for now. This shows up multiple drivers that immediately crash with USB console some of which have been fixed in the process. Longer term we need a proper tty as console abstraction Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/mos7840.c')
-rw-r--r--drivers/usb/serial/mos7840.c165
1 files changed, 66 insertions, 99 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 78f2f6db494d..2b1fded6619d 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -710,7 +710,7 @@ static void mos7840_bulk_in_callback(struct urb *urb)
710 dbg("%s", "Entering ........... \n"); 710 dbg("%s", "Entering ........... \n");
711 711
712 if (urb->actual_length) { 712 if (urb->actual_length) {
713 tty = mos7840_port->port->tty; 713 tty = mos7840_port->port->port.tty;
714 if (tty) { 714 if (tty) {
715 tty_buffer_request_room(tty, urb->actual_length); 715 tty_buffer_request_room(tty, urb->actual_length);
716 tty_insert_flip_string(tty, data, urb->actual_length); 716 tty_insert_flip_string(tty, data, urb->actual_length);
@@ -774,7 +774,7 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
774 774
775 dbg("%s \n", "Entering ........."); 775 dbg("%s \n", "Entering .........");
776 776
777 tty = mos7840_port->port->tty; 777 tty = mos7840_port->port->port.tty;
778 778
779 if (tty && mos7840_port->open) 779 if (tty && mos7840_port->open)
780 tty_wakeup(tty); 780 tty_wakeup(tty);
@@ -804,7 +804,8 @@ static int mos7840_serial_probe(struct usb_serial *serial,
804 * Otherwise we return a negative error number. 804 * Otherwise we return a negative error number.
805 *****************************************************************************/ 805 *****************************************************************************/
806 806
807static int mos7840_open(struct usb_serial_port *port, struct file *filp) 807static int mos7840_open(struct tty_struct *tty,
808 struct usb_serial_port *port, struct file *filp)
808{ 809{
809 int response; 810 int response;
810 int j; 811 int j;
@@ -1008,8 +1009,8 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1008 * the data through,otherwise it is scheduled, and with * 1009 * the data through,otherwise it is scheduled, and with *
1009 * high data rates (like with OHCI) data can get lost. */ 1010 * high data rates (like with OHCI) data can get lost. */
1010 1011
1011 if (port->tty) 1012 if (tty)
1012 port->tty->low_latency = 1; 1013 tty->low_latency = 1;
1013/* Check to see if we've set up our endpoint info yet * 1014/* Check to see if we've set up our endpoint info yet *
1014 * (can't set it up in mos7840_startup as the structures * 1015 * (can't set it up in mos7840_startup as the structures *
1015 * were not set up at that time.) */ 1016 * were not set up at that time.) */
@@ -1104,11 +1105,12 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
1104 * been written, but hasn't made it out the port yet) 1105 * been written, but hasn't made it out the port yet)
1105 * If successful, we return the number of bytes left to be written in the 1106 * If successful, we return the number of bytes left to be written in the
1106 * system, 1107 * system,
1107 * Otherwise we return a negative error number. 1108 * Otherwise we return zero.
1108 *****************************************************************************/ 1109 *****************************************************************************/
1109 1110
1110static int mos7840_chars_in_buffer(struct usb_serial_port *port) 1111static int mos7840_chars_in_buffer(struct tty_struct *tty)
1111{ 1112{
1113 struct usb_serial_port *port = tty->driver_data;
1112 int i; 1114 int i;
1113 int chars = 0; 1115 int chars = 0;
1114 unsigned long flags; 1116 unsigned long flags;
@@ -1118,21 +1120,19 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1118 1120
1119 if (mos7840_port_paranoia_check(port, __func__)) { 1121 if (mos7840_port_paranoia_check(port, __func__)) {
1120 dbg("%s", "Invalid port \n"); 1122 dbg("%s", "Invalid port \n");
1121 return -1; 1123 return 0;
1122 } 1124 }
1123 1125
1124 mos7840_port = mos7840_get_port_private(port); 1126 mos7840_port = mos7840_get_port_private(port);
1125 if (mos7840_port == NULL) { 1127 if (mos7840_port == NULL) {
1126 dbg("%s \n", "mos7840_break:leaving ..........."); 1128 dbg("%s \n", "mos7840_break:leaving ...........");
1127 return -1; 1129 return 0;
1128 } 1130 }
1129 1131
1130 spin_lock_irqsave(&mos7840_port->pool_lock,flags); 1132 spin_lock_irqsave(&mos7840_port->pool_lock,flags);
1131 for (i = 0; i < NUM_URBS; ++i) { 1133 for (i = 0; i < NUM_URBS; ++i)
1132 if (mos7840_port->busy[i]) { 1134 if (mos7840_port->busy[i])
1133 chars += URB_TRANSFER_BUFFER_SIZE; 1135 chars += URB_TRANSFER_BUFFER_SIZE;
1134 }
1135 }
1136 spin_unlock_irqrestore(&mos7840_port->pool_lock,flags); 1136 spin_unlock_irqrestore(&mos7840_port->pool_lock,flags);
1137 dbg("%s - returns %d", __func__, chars); 1137 dbg("%s - returns %d", __func__, chars);
1138 return chars; 1138 return chars;
@@ -1149,7 +1149,8 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1149 * 3. A timeout of 3 seconds without activity has expired 1149 * 3. A timeout of 3 seconds without activity has expired
1150 * 1150 *
1151 ************************************************************************/ 1151 ************************************************************************/
1152static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port) 1152static void mos7840_block_until_tx_empty(struct tty_struct *tty,
1153 struct moschip_port *mos7840_port)
1153{ 1154{
1154 int timeout = HZ / 10; 1155 int timeout = HZ / 10;
1155 int wait = 30; 1156 int wait = 30;
@@ -1157,7 +1158,7 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
1157 1158
1158 while (1) { 1159 while (1) {
1159 1160
1160 count = mos7840_chars_in_buffer(mos7840_port->port); 1161 count = mos7840_chars_in_buffer(tty);
1161 1162
1162 /* Check for Buffer status */ 1163 /* Check for Buffer status */
1163 if (count <= 0) { 1164 if (count <= 0) {
@@ -1185,7 +1186,8 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
1185 * this function is called by the tty driver when a port is closed 1186 * this function is called by the tty driver when a port is closed
1186 *****************************************************************************/ 1187 *****************************************************************************/
1187 1188
1188static void mos7840_close(struct usb_serial_port *port, struct file *filp) 1189static void mos7840_close(struct tty_struct *tty,
1190 struct usb_serial_port *port, struct file *filp)
1189{ 1191{
1190 struct usb_serial *serial; 1192 struct usb_serial *serial;
1191 struct moschip_port *mos7840_port; 1193 struct moschip_port *mos7840_port;
@@ -1226,20 +1228,17 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1226 } 1228 }
1227 } 1229 }
1228 1230
1229 if (serial->dev) { 1231 if (serial->dev)
1230 /* flush and block until tx is empty */ 1232 /* flush and block until tx is empty */
1231 mos7840_block_until_tx_empty(mos7840_port); 1233 mos7840_block_until_tx_empty(tty, mos7840_port);
1232 }
1233 1234
1234 /* While closing port, shutdown all bulk read, write * 1235 /* While closing port, shutdown all bulk read, write *
1235 * and interrupt read if they exists */ 1236 * and interrupt read if they exists */
1236 if (serial->dev) { 1237 if (serial->dev) {
1237
1238 if (mos7840_port->write_urb) { 1238 if (mos7840_port->write_urb) {
1239 dbg("%s", "Shutdown bulk write\n"); 1239 dbg("%s", "Shutdown bulk write\n");
1240 usb_kill_urb(mos7840_port->write_urb); 1240 usb_kill_urb(mos7840_port->write_urb);
1241 } 1241 }
1242
1243 if (mos7840_port->read_urb) { 1242 if (mos7840_port->read_urb) {
1244 dbg("%s", "Shutdown bulk read\n"); 1243 dbg("%s", "Shutdown bulk read\n");
1245 usb_kill_urb(mos7840_port->read_urb); 1244 usb_kill_urb(mos7840_port->read_urb);
@@ -1247,11 +1246,10 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1247 if ((&mos7840_port->control_urb)) { 1246 if ((&mos7840_port->control_urb)) {
1248 dbg("%s", "Shutdown control read\n"); 1247 dbg("%s", "Shutdown control read\n");
1249 // usb_kill_urb (mos7840_port->control_urb); 1248 // usb_kill_urb (mos7840_port->control_urb);
1250
1251 } 1249 }
1252 } 1250 }
1253// if(mos7840_port->ctrl_buf != NULL) 1251// if(mos7840_port->ctrl_buf != NULL)
1254// kfree(mos7840_port->ctrl_buf); 1252// kfree(mos7840_port->ctrl_buf);
1255 port0->open_ports--; 1253 port0->open_ports--;
1256 dbg("mos7840_num_open_ports in close%d:in port%d\n", 1254 dbg("mos7840_num_open_ports in close%d:in port%d\n",
1257 port0->open_ports, port->number); 1255 port0->open_ports, port->number);
@@ -1293,15 +1291,15 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1293 * 1291 *
1294 ************************************************************************/ 1292 ************************************************************************/
1295 1293
1296static void mos7840_block_until_chase_response(struct moschip_port 1294static void mos7840_block_until_chase_response(struct tty_struct *tty,
1297 *mos7840_port) 1295 struct moschip_port *mos7840_port)
1298{ 1296{
1299 int timeout = 1 * HZ; 1297 int timeout = 1 * HZ;
1300 int wait = 10; 1298 int wait = 10;
1301 int count; 1299 int count;
1302 1300
1303 while (1) { 1301 while (1) {
1304 count = mos7840_chars_in_buffer(mos7840_port->port); 1302 count = mos7840_chars_in_buffer(tty);
1305 1303
1306 /* Check for Buffer status */ 1304 /* Check for Buffer status */
1307 if (count <= 0) { 1305 if (count <= 0) {
@@ -1328,8 +1326,9 @@ static void mos7840_block_until_chase_response(struct moschip_port
1328 * mos7840_break 1326 * mos7840_break
1329 * this function sends a break to the port 1327 * this function sends a break to the port
1330 *****************************************************************************/ 1328 *****************************************************************************/
1331static void mos7840_break(struct usb_serial_port *port, int break_state) 1329static void mos7840_break(struct tty_struct *tty, int break_state)
1332{ 1330{
1331 struct usb_serial_port *port = tty->driver_data;
1333 unsigned char data; 1332 unsigned char data;
1334 struct usb_serial *serial; 1333 struct usb_serial *serial;
1335 struct moschip_port *mos7840_port; 1334 struct moschip_port *mos7840_port;
@@ -1354,17 +1353,14 @@ static void mos7840_break(struct usb_serial_port *port, int break_state)
1354 return; 1353 return;
1355 } 1354 }
1356 1355
1357 if (serial->dev) { 1356 if (serial->dev)
1358
1359 /* flush and block until tx is empty */ 1357 /* flush and block until tx is empty */
1360 mos7840_block_until_chase_response(mos7840_port); 1358 mos7840_block_until_chase_response(tty, mos7840_port);
1361 }
1362 1359
1363 if (break_state == -1) { 1360 if (break_state == -1)
1364 data = mos7840_port->shadowLCR | LCR_SET_BREAK; 1361 data = mos7840_port->shadowLCR | LCR_SET_BREAK;
1365 } else { 1362 else
1366 data = mos7840_port->shadowLCR & ~LCR_SET_BREAK; 1363 data = mos7840_port->shadowLCR & ~LCR_SET_BREAK;
1367 }
1368 1364
1369 mos7840_port->shadowLCR = data; 1365 mos7840_port->shadowLCR = data;
1370 dbg("mcs7840_break mos7840_port->shadowLCR is %x\n", 1366 dbg("mcs7840_break mos7840_port->shadowLCR is %x\n",
@@ -1383,8 +1379,9 @@ static void mos7840_break(struct usb_serial_port *port, int break_state)
1383 * Otherwise we return a negative error number. 1379 * Otherwise we return a negative error number.
1384 *****************************************************************************/ 1380 *****************************************************************************/
1385 1381
1386static int mos7840_write_room(struct usb_serial_port *port) 1382static int mos7840_write_room(struct tty_struct *tty)
1387{ 1383{
1384 struct usb_serial_port *port = tty->driver_data;
1388 int i; 1385 int i;
1389 int room = 0; 1386 int room = 0;
1390 unsigned long flags; 1387 unsigned long flags;
@@ -1426,7 +1423,7 @@ static int mos7840_write_room(struct usb_serial_port *port)
1426 * return a negative error number. 1423 * return a negative error number.
1427 *****************************************************************************/ 1424 *****************************************************************************/
1428 1425
1429static int mos7840_write(struct usb_serial_port *port, 1426static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1430 const unsigned char *data, int count) 1427 const unsigned char *data, int count)
1431{ 1428{
1432 int status; 1429 int status;
@@ -1555,8 +1552,7 @@ static int mos7840_write(struct usb_serial_port *port,
1555 mos7840_port->icount.tx += transfer_size; 1552 mos7840_port->icount.tx += transfer_size;
1556 smp_wmb(); 1553 smp_wmb();
1557 dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx); 1554 dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx);
1558 exit: 1555exit:
1559
1560 return bytes_sent; 1556 return bytes_sent;
1561 1557
1562} 1558}
@@ -1567,10 +1563,10 @@ static int mos7840_write(struct usb_serial_port *port,
1567 * being read from the port. 1563 * being read from the port.
1568 *****************************************************************************/ 1564 *****************************************************************************/
1569 1565
1570static void mos7840_throttle(struct usb_serial_port *port) 1566static void mos7840_throttle(struct tty_struct *tty)
1571{ 1567{
1568 struct usb_serial_port *port = tty->driver_data;
1572 struct moschip_port *mos7840_port; 1569 struct moschip_port *mos7840_port;
1573 struct tty_struct *tty;
1574 int status; 1570 int status;
1575 1571
1576 if (mos7840_port_paranoia_check(port, __func__)) { 1572 if (mos7840_port_paranoia_check(port, __func__)) {
@@ -1592,32 +1588,21 @@ static void mos7840_throttle(struct usb_serial_port *port)
1592 1588
1593 dbg("%s", "Entering .......... \n"); 1589 dbg("%s", "Entering .......... \n");
1594 1590
1595 tty = port->tty;
1596 if (!tty) {
1597 dbg("%s - no tty available", __func__);
1598 return;
1599 }
1600
1601 /* if we are implementing XON/XOFF, send the stop character */ 1591 /* if we are implementing XON/XOFF, send the stop character */
1602 if (I_IXOFF(tty)) { 1592 if (I_IXOFF(tty)) {
1603 unsigned char stop_char = STOP_CHAR(tty); 1593 unsigned char stop_char = STOP_CHAR(tty);
1604 status = mos7840_write(port, &stop_char, 1); 1594 status = mos7840_write(tty, port, &stop_char, 1);
1605 if (status <= 0) { 1595 if (status <= 0)
1606 return; 1596 return;
1607 }
1608 } 1597 }
1609
1610 /* if we are implementing RTS/CTS, toggle that line */ 1598 /* if we are implementing RTS/CTS, toggle that line */
1611 if (tty->termios->c_cflag & CRTSCTS) { 1599 if (tty->termios->c_cflag & CRTSCTS) {
1612 mos7840_port->shadowMCR &= ~MCR_RTS; 1600 mos7840_port->shadowMCR &= ~MCR_RTS;
1613 status = 0; 1601 status = 0;
1614 status = 1602 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1615 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1616 mos7840_port->shadowMCR); 1603 mos7840_port->shadowMCR);
1617 1604 if (status < 0)
1618 if (status < 0) {
1619 return; 1605 return;
1620 }
1621 } 1606 }
1622 1607
1623 return; 1608 return;
@@ -1628,9 +1613,9 @@ static void mos7840_throttle(struct usb_serial_port *port)
1628 * this function is called by the tty driver when it wants to resume the data 1613 * this function is called by the tty driver when it wants to resume the data
1629 * being read from the port (called after SerialThrottle is called) 1614 * being read from the port (called after SerialThrottle is called)
1630 *****************************************************************************/ 1615 *****************************************************************************/
1631static void mos7840_unthrottle(struct usb_serial_port *port) 1616static void mos7840_unthrottle(struct tty_struct *tty)
1632{ 1617{
1633 struct tty_struct *tty; 1618 struct usb_serial_port *port = tty->driver_data;
1634 int status; 1619 int status;
1635 struct moschip_port *mos7840_port = mos7840_get_port_private(port); 1620 struct moschip_port *mos7840_port = mos7840_get_port_private(port);
1636 1621
@@ -1649,38 +1634,28 @@ static void mos7840_unthrottle(struct usb_serial_port *port)
1649 1634
1650 dbg("%s", "Entering .......... \n"); 1635 dbg("%s", "Entering .......... \n");
1651 1636
1652 tty = port->tty;
1653 if (!tty) {
1654 dbg("%s - no tty available", __func__);
1655 return;
1656 }
1657
1658 /* if we are implementing XON/XOFF, send the start character */ 1637 /* if we are implementing XON/XOFF, send the start character */
1659 if (I_IXOFF(tty)) { 1638 if (I_IXOFF(tty)) {
1660 unsigned char start_char = START_CHAR(tty); 1639 unsigned char start_char = START_CHAR(tty);
1661 status = mos7840_write(port, &start_char, 1); 1640 status = mos7840_write(tty, port, &start_char, 1);
1662 if (status <= 0) { 1641 if (status <= 0)
1663 return; 1642 return;
1664 }
1665 } 1643 }
1666 1644
1667 /* if we are implementing RTS/CTS, toggle that line */ 1645 /* if we are implementing RTS/CTS, toggle that line */
1668 if (tty->termios->c_cflag & CRTSCTS) { 1646 if (tty->termios->c_cflag & CRTSCTS) {
1669 mos7840_port->shadowMCR |= MCR_RTS; 1647 mos7840_port->shadowMCR |= MCR_RTS;
1670 status = 0; 1648 status = 0;
1671 status = 1649 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1672 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1673 mos7840_port->shadowMCR); 1650 mos7840_port->shadowMCR);
1674 if (status < 0) { 1651 if (status < 0)
1675 return; 1652 return;
1676 }
1677 } 1653 }
1678
1679 return;
1680} 1654}
1681 1655
1682static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file) 1656static int mos7840_tiocmget(struct tty_struct *tty, struct file *file)
1683{ 1657{
1658 struct usb_serial_port *port = tty->driver_data;
1684 struct moschip_port *mos7840_port; 1659 struct moschip_port *mos7840_port;
1685 unsigned int result; 1660 unsigned int result;
1686 __u16 msr; 1661 __u16 msr;
@@ -1708,9 +1683,10 @@ static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file)
1708 return result; 1683 return result;
1709} 1684}
1710 1685
1711static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file, 1686static int mos7840_tiocmset(struct tty_struct *tty, struct file *file,
1712 unsigned int set, unsigned int clear) 1687 unsigned int set, unsigned int clear)
1713{ 1688{
1689 struct usb_serial_port *port = tty->driver_data;
1714 struct moschip_port *mos7840_port; 1690 struct moschip_port *mos7840_port;
1715 unsigned int mcr; 1691 unsigned int mcr;
1716 int status; 1692 int status;
@@ -1949,10 +1925,9 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1949 * the specified new settings. 1925 * the specified new settings.
1950 *****************************************************************************/ 1926 *****************************************************************************/
1951 1927
1952static void mos7840_change_port_settings(struct moschip_port *mos7840_port, 1928static void mos7840_change_port_settings(struct tty_struct *tty,
1953 struct ktermios *old_termios) 1929 struct moschip_port *mos7840_port, struct ktermios *old_termios)
1954{ 1930{
1955 struct tty_struct *tty;
1956 int baud; 1931 int baud;
1957 unsigned cflag; 1932 unsigned cflag;
1958 unsigned iflag; 1933 unsigned iflag;
@@ -1988,8 +1963,6 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
1988 return; 1963 return;
1989 } 1964 }
1990 1965
1991 tty = mos7840_port->port->tty;
1992
1993 dbg("%s", "Entering .......... \n"); 1966 dbg("%s", "Entering .......... \n");
1994 1967
1995 lData = LCR_BITS_8; 1968 lData = LCR_BITS_8;
@@ -2131,14 +2104,14 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
2131 * the termios structure 2104 * the termios structure
2132 *****************************************************************************/ 2105 *****************************************************************************/
2133 2106
2134static void mos7840_set_termios(struct usb_serial_port *port, 2107static void mos7840_set_termios(struct tty_struct *tty,
2108 struct usb_serial_port *port,
2135 struct ktermios *old_termios) 2109 struct ktermios *old_termios)
2136{ 2110{
2137 int status; 2111 int status;
2138 unsigned int cflag; 2112 unsigned int cflag;
2139 struct usb_serial *serial; 2113 struct usb_serial *serial;
2140 struct moschip_port *mos7840_port; 2114 struct moschip_port *mos7840_port;
2141 struct tty_struct *tty;
2142 dbg("mos7840_set_termios: START\n"); 2115 dbg("mos7840_set_termios: START\n");
2143 if (mos7840_port_paranoia_check(port, __func__)) { 2116 if (mos7840_port_paranoia_check(port, __func__)) {
2144 dbg("%s", "Invalid port \n"); 2117 dbg("%s", "Invalid port \n");
@@ -2157,8 +2130,6 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2157 if (mos7840_port == NULL) 2130 if (mos7840_port == NULL)
2158 return; 2131 return;
2159 2132
2160 tty = port->tty;
2161
2162 if (!mos7840_port->open) { 2133 if (!mos7840_port->open) {
2163 dbg("%s - port not opened", __func__); 2134 dbg("%s - port not opened", __func__);
2164 return; 2135 return;
@@ -2176,7 +2147,7 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2176 2147
2177 /* change the port settings to the new ones specified */ 2148 /* change the port settings to the new ones specified */
2178 2149
2179 mos7840_change_port_settings(mos7840_port, old_termios); 2150 mos7840_change_port_settings(tty, mos7840_port, old_termios);
2180 2151
2181 if (!mos7840_port->read_urb) { 2152 if (!mos7840_port->read_urb) {
2182 dbg("%s", "URB KILLED !!!!!\n"); 2153 dbg("%s", "URB KILLED !!!!!\n");
@@ -2205,13 +2176,13 @@ static void mos7840_set_termios(struct usb_serial_port *port,
2205 * allows an RS485 driver to be written in user space. 2176 * allows an RS485 driver to be written in user space.
2206 *****************************************************************************/ 2177 *****************************************************************************/
2207 2178
2208static int mos7840_get_lsr_info(struct moschip_port *mos7840_port, 2179static int mos7840_get_lsr_info(struct tty_struct *tty,
2209 unsigned int __user *value) 2180 unsigned int __user *value)
2210{ 2181{
2211 int count; 2182 int count;
2212 unsigned int result = 0; 2183 unsigned int result = 0;
2213 2184
2214 count = mos7840_chars_in_buffer(mos7840_port->port); 2185 count = mos7840_chars_in_buffer(tty);
2215 if (count == 0) { 2186 if (count == 0) {
2216 dbg("%s -- Empty", __func__); 2187 dbg("%s -- Empty", __func__);
2217 result = TIOCSER_TEMT; 2188 result = TIOCSER_TEMT;
@@ -2227,6 +2198,8 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2227 * function to set modem info 2198 * function to set modem info
2228 *****************************************************************************/ 2199 *****************************************************************************/
2229 2200
2201/* FIXME: Should be using the model control hooks */
2202
2230static int mos7840_set_modem_info(struct moschip_port *mos7840_port, 2203static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2231 unsigned int cmd, unsigned int __user *value) 2204 unsigned int cmd, unsigned int __user *value)
2232{ 2205{
@@ -2304,9 +2277,8 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2304 __u16 msr; 2277 __u16 msr;
2305 unsigned int mcr = mos7840_port->shadowMCR; 2278 unsigned int mcr = mos7840_port->shadowMCR;
2306 int status = 0; 2279 int status = 0;
2307 status = 2280 status = mos7840_get_uart_reg(mos7840_port->port,
2308 mos7840_get_uart_reg(mos7840_port->port, MODEM_STATUS_REGISTER, 2281 MODEM_STATUS_REGISTER, &msr);
2309 &msr);
2310 result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */ 2282 result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */
2311 |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */ 2283 |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */
2312 |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */ 2284 |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */
@@ -2359,12 +2331,12 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2359 * this function handles any ioctl calls to the driver 2331 * this function handles any ioctl calls to the driver
2360 *****************************************************************************/ 2332 *****************************************************************************/
2361 2333
2362static int mos7840_ioctl(struct usb_serial_port *port, struct file *file, 2334static int mos7840_ioctl(struct tty_struct *tty, struct file *file,
2363 unsigned int cmd, unsigned long arg) 2335 unsigned int cmd, unsigned long arg)
2364{ 2336{
2337 struct usb_serial_port *port = tty->driver_data;
2365 void __user *argp = (void __user *)arg; 2338 void __user *argp = (void __user *)arg;
2366 struct moschip_port *mos7840_port; 2339 struct moschip_port *mos7840_port;
2367 struct tty_struct *tty;
2368 2340
2369 struct async_icount cnow; 2341 struct async_icount cnow;
2370 struct async_icount cprev; 2342 struct async_icount cprev;
@@ -2381,8 +2353,6 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2381 if (mos7840_port == NULL) 2353 if (mos7840_port == NULL)
2382 return -1; 2354 return -1;
2383 2355
2384 tty = mos7840_port->port->tty;
2385
2386 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 2356 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
2387 2357
2388 switch (cmd) { 2358 switch (cmd) {
@@ -2390,9 +2360,10 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2390 2360
2391 case TIOCSERGETLSR: 2361 case TIOCSERGETLSR:
2392 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 2362 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
2393 return mos7840_get_lsr_info(mos7840_port, argp); 2363 return mos7840_get_lsr_info(tty, argp);
2394 return 0; 2364 return 0;
2395 2365
2366 /* FIXME: use the modem hooks and remove this */
2396 case TIOCMBIS: 2367 case TIOCMBIS:
2397 case TIOCMBIC: 2368 case TIOCMBIC:
2398 case TIOCMSET: 2369 case TIOCMSET:
@@ -2463,13 +2434,9 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2463 if (copy_to_user(argp, &icount, sizeof(icount))) 2434 if (copy_to_user(argp, &icount, sizeof(icount)))
2464 return -EFAULT; 2435 return -EFAULT;
2465 return 0; 2436 return 0;
2466
2467 case TIOCEXBAUD:
2468 return 0;
2469 default: 2437 default:
2470 break; 2438 break;
2471 } 2439 }
2472
2473 return -ENOIOCTLCMD; 2440 return -ENOIOCTLCMD;
2474} 2441}
2475 2442