aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/io_edgeport.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/io_edgeport.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/io_edgeport.c')
-rw-r--r--drivers/usb/serial/io_edgeport.c175
1 files changed, 62 insertions, 113 deletions
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 2fd449bcfa35..29346d79df7b 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -206,18 +206,18 @@ static void edge_bulk_out_data_callback (struct urb *urb);
206static void edge_bulk_out_cmd_callback (struct urb *urb); 206static void edge_bulk_out_cmd_callback (struct urb *urb);
207 207
208/* function prototypes for the usbserial callbacks */ 208/* function prototypes for the usbserial callbacks */
209static int edge_open (struct usb_serial_port *port, struct file *filp); 209static int edge_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
210static void edge_close (struct usb_serial_port *port, struct file *filp); 210static void edge_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
211static int edge_write (struct usb_serial_port *port, const unsigned char *buf, int count); 211static int edge_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
212static int edge_write_room (struct usb_serial_port *port); 212static int edge_write_room (struct tty_struct *tty);
213static int edge_chars_in_buffer (struct usb_serial_port *port); 213static int edge_chars_in_buffer (struct tty_struct *tty);
214static void edge_throttle (struct usb_serial_port *port); 214static void edge_throttle (struct tty_struct *tty);
215static void edge_unthrottle (struct usb_serial_port *port); 215static void edge_unthrottle (struct tty_struct *tty);
216static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios); 216static void edge_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios);
217static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg); 217static int edge_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
218static void edge_break (struct usb_serial_port *port, int break_state); 218static void edge_break (struct tty_struct *tty, int break_state);
219static int edge_tiocmget (struct usb_serial_port *port, struct file *file); 219static int edge_tiocmget (struct tty_struct *tty, struct file *file);
220static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); 220static int edge_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear);
221static int edge_startup (struct usb_serial *serial); 221static int edge_startup (struct usb_serial *serial);
222static void edge_shutdown (struct usb_serial *serial); 222static void edge_shutdown (struct usb_serial *serial);
223 223
@@ -233,7 +233,8 @@ static void handle_new_lsr (struct edgeport_port *edge_port, __u8 lsrData, __u8
233static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param); 233static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param);
234static int calc_baud_rate_divisor (int baud_rate, int *divisor); 234static int calc_baud_rate_divisor (int baud_rate, int *divisor);
235static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate); 235static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate);
236static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios); 236static void change_port_settings (struct tty_struct *tty, struct edgeport_port *edge_port,
237 struct ktermios *old_termios);
237static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue); 238static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue);
238static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength); 239static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength);
239static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port); 240static void send_more_port_data (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port);
@@ -639,8 +640,8 @@ static void edge_interrupt_callback (struct urb *urb)
639 dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits); 640 dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits);
640 641
641 /* tell the tty driver that something has changed */ 642 /* tell the tty driver that something has changed */
642 if (edge_port->port->tty) 643 if (edge_port->port->port.tty)
643 tty_wakeup(edge_port->port->tty); 644 tty_wakeup(edge_port->port->port.tty);
644 645
645 // Since we have more credit, check if more data can be sent 646 // Since we have more credit, check if more data can be sent
646 send_more_port_data(edge_serial, edge_port); 647 send_more_port_data(edge_serial, edge_port);
@@ -737,7 +738,7 @@ static void edge_bulk_out_data_callback (struct urb *urb)
737 __func__, status); 738 __func__, status);
738 } 739 }
739 740
740 tty = edge_port->port->tty; 741 tty = edge_port->port->port.tty;
741 742
742 if (tty && edge_port->open) { 743 if (tty && edge_port->open) {
743 /* let the tty driver wakeup if it has a special write_wakeup function */ 744 /* let the tty driver wakeup if it has a special write_wakeup function */
@@ -781,7 +782,7 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
781 } 782 }
782 783
783 /* Get pointer to tty */ 784 /* Get pointer to tty */
784 tty = edge_port->port->tty; 785 tty = edge_port->port->port.tty;
785 786
786 /* tell the tty driver that something has changed */ 787 /* tell the tty driver that something has changed */
787 if (tty && edge_port->open) 788 if (tty && edge_port->open)
@@ -803,7 +804,8 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
803 * If successful, we return 0 804 * If successful, we return 0
804 * Otherwise we return a negative error number. 805 * Otherwise we return a negative error number.
805 *****************************************************************************/ 806 *****************************************************************************/
806static int edge_open (struct usb_serial_port *port, struct file * filp) 807static int edge_open(struct tty_struct *tty,
808 struct usb_serial_port *port, struct file * filp)
807{ 809{
808 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 810 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
809 struct usb_serial *serial; 811 struct usb_serial *serial;
@@ -815,16 +817,15 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
815 if (edge_port == NULL) 817 if (edge_port == NULL)
816 return -ENODEV; 818 return -ENODEV;
817 819
818 if (port->tty) 820 if (tty)
819 port->tty->low_latency = low_latency; 821 tty->low_latency = low_latency;
820 822
821 /* see if we've set up our endpoint info yet (can't set it up in edge_startup 823 /* see if we've set up our endpoint info yet (can't set it up in edge_startup
822 as the structures were not set up at that time.) */ 824 as the structures were not set up at that time.) */
823 serial = port->serial; 825 serial = port->serial;
824 edge_serial = usb_get_serial_data(serial); 826 edge_serial = usb_get_serial_data(serial);
825 if (edge_serial == NULL) { 827 if (edge_serial == NULL)
826 return -ENODEV; 828 return -ENODEV;
827 }
828 if (edge_serial->interrupt_in_buffer == NULL) { 829 if (edge_serial->interrupt_in_buffer == NULL) {
829 struct usb_serial_port *port0 = serial->port[0]; 830 struct usb_serial_port *port0 = serial->port[0];
830 831
@@ -908,7 +909,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
908 909
909 if (!edge_port->txfifo.fifo) { 910 if (!edge_port->txfifo.fifo) {
910 dbg("%s - no memory", __func__); 911 dbg("%s - no memory", __func__);
911 edge_close (port, filp); 912 edge_close (tty, port, filp);
912 return -ENOMEM; 913 return -ENOMEM;
913 } 914 }
914 915
@@ -918,7 +919,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
918 919
919 if (!edge_port->write_urb) { 920 if (!edge_port->write_urb) {
920 dbg("%s - no memory", __func__); 921 dbg("%s - no memory", __func__);
921 edge_close (port, filp); 922 edge_close (tty, port, filp);
922 return -ENOMEM; 923 return -ENOMEM;
923 } 924 }
924 925
@@ -1038,7 +1039,8 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
1038 * edge_close 1039 * edge_close
1039 * this function is called by the tty driver when a port is closed 1040 * this function is called by the tty driver when a port is closed
1040 *****************************************************************************/ 1041 *****************************************************************************/
1041static void edge_close (struct usb_serial_port *port, struct file * filp) 1042static void edge_close(struct tty_struct *tty,
1043 struct usb_serial_port *port, struct file * filp)
1042{ 1044{
1043 struct edgeport_serial *edge_serial; 1045 struct edgeport_serial *edge_serial;
1044 struct edgeport_port *edge_port; 1046 struct edgeport_port *edge_port;
@@ -1106,7 +1108,8 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1106 * If successful, we return the number of bytes written, otherwise we return 1108 * If successful, we return the number of bytes written, otherwise we return
1107 * a negative error number. 1109 * a negative error number.
1108 *****************************************************************************/ 1110 *****************************************************************************/
1109static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count) 1111static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
1112 const unsigned char *data, int count)
1110{ 1113{
1111 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1114 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1112 struct TxFifo *fifo; 1115 struct TxFifo *fifo;
@@ -1308,8 +1311,9 @@ exit_send:
1308 * (the txCredits), 1311 * (the txCredits),
1309 * Otherwise we return a negative error number. 1312 * Otherwise we return a negative error number.
1310 *****************************************************************************/ 1313 *****************************************************************************/
1311static int edge_write_room (struct usb_serial_port *port) 1314static int edge_write_room(struct tty_struct *tty)
1312{ 1315{
1316 struct usb_serial_port *port = tty->driver_data;
1313 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1317 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1314 int room; 1318 int room;
1315 unsigned long flags; 1319 unsigned long flags;
@@ -1347,8 +1351,9 @@ static int edge_write_room (struct usb_serial_port *port)
1347 * system, 1351 * system,
1348 * Otherwise we return a negative error number. 1352 * Otherwise we return a negative error number.
1349 *****************************************************************************/ 1353 *****************************************************************************/
1350static int edge_chars_in_buffer (struct usb_serial_port *port) 1354static int edge_chars_in_buffer(struct tty_struct *tty)
1351{ 1355{
1356 struct usb_serial_port *port = tty->driver_data;
1352 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1357 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1353 int num_chars; 1358 int num_chars;
1354 unsigned long flags; 1359 unsigned long flags;
@@ -1381,10 +1386,10 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
1381 * this function is called by the tty driver when it wants to stop the data 1386 * this function is called by the tty driver when it wants to stop the data
1382 * being read from the port. 1387 * being read from the port.
1383 *****************************************************************************/ 1388 *****************************************************************************/
1384static void edge_throttle (struct usb_serial_port *port) 1389static void edge_throttle(struct tty_struct *tty)
1385{ 1390{
1391 struct usb_serial_port *port = tty->driver_data;
1386 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1392 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1387 struct tty_struct *tty;
1388 int status; 1393 int status;
1389 1394
1390 dbg("%s - port %d", __func__, port->number); 1395 dbg("%s - port %d", __func__, port->number);
@@ -1397,16 +1402,10 @@ static void edge_throttle (struct usb_serial_port *port)
1397 return; 1402 return;
1398 } 1403 }
1399 1404
1400 tty = port->tty;
1401 if (!tty) {
1402 dbg ("%s - no tty available", __func__);
1403 return;
1404 }
1405
1406 /* if we are implementing XON/XOFF, send the stop character */ 1405 /* if we are implementing XON/XOFF, send the stop character */
1407 if (I_IXOFF(tty)) { 1406 if (I_IXOFF(tty)) {
1408 unsigned char stop_char = STOP_CHAR(tty); 1407 unsigned char stop_char = STOP_CHAR(tty);
1409 status = edge_write (port, &stop_char, 1); 1408 status = edge_write (tty, port, &stop_char, 1);
1410 if (status <= 0) { 1409 if (status <= 0) {
1411 return; 1410 return;
1412 } 1411 }
@@ -1430,10 +1429,10 @@ static void edge_throttle (struct usb_serial_port *port)
1430 * this function is called by the tty driver when it wants to resume the data 1429 * this function is called by the tty driver when it wants to resume the data
1431 * being read from the port (called after SerialThrottle is called) 1430 * being read from the port (called after SerialThrottle is called)
1432 *****************************************************************************/ 1431 *****************************************************************************/
1433static void edge_unthrottle (struct usb_serial_port *port) 1432static void edge_unthrottle(struct tty_struct *tty)
1434{ 1433{
1434 struct usb_serial_port *port = tty->driver_data;
1435 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1435 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1436 struct tty_struct *tty;
1437 int status; 1436 int status;
1438 1437
1439 dbg("%s - port %d", __func__, port->number); 1438 dbg("%s - port %d", __func__, port->number);
@@ -1446,31 +1445,18 @@ static void edge_unthrottle (struct usb_serial_port *port)
1446 return; 1445 return;
1447 } 1446 }
1448 1447
1449 tty = port->tty;
1450 if (!tty) {
1451 dbg ("%s - no tty available", __func__);
1452 return;
1453 }
1454
1455 /* if we are implementing XON/XOFF, send the start character */ 1448 /* if we are implementing XON/XOFF, send the start character */
1456 if (I_IXOFF(tty)) { 1449 if (I_IXOFF(tty)) {
1457 unsigned char start_char = START_CHAR(tty); 1450 unsigned char start_char = START_CHAR(tty);
1458 status = edge_write (port, &start_char, 1); 1451 status = edge_write(tty, port, &start_char, 1);
1459 if (status <= 0) { 1452 if (status <= 0)
1460 return; 1453 return;
1461 }
1462 } 1454 }
1463
1464 /* if we are implementing RTS/CTS, toggle that line */ 1455 /* if we are implementing RTS/CTS, toggle that line */
1465 if (tty->termios->c_cflag & CRTSCTS) { 1456 if (tty->termios->c_cflag & CRTSCTS) {
1466 edge_port->shadowMCR |= MCR_RTS; 1457 edge_port->shadowMCR |= MCR_RTS;
1467 status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR); 1458 send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
1468 if (status != 0) {
1469 return;
1470 }
1471 } 1459 }
1472
1473 return;
1474} 1460}
1475 1461
1476 1462
@@ -1478,11 +1464,10 @@ static void edge_unthrottle (struct usb_serial_port *port)
1478 * SerialSetTermios 1464 * SerialSetTermios
1479 * this function is called by the tty driver when it wants to change the termios structure 1465 * this function is called by the tty driver when it wants to change the termios structure
1480 *****************************************************************************/ 1466 *****************************************************************************/
1481static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) 1467static void edge_set_termios(struct tty_struct *tty,
1468 struct usb_serial_port *port, struct ktermios *old_termios)
1482{ 1469{
1483 /* FIXME: This function appears unused ?? */
1484 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1470 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1485 struct tty_struct *tty = port->tty;
1486 unsigned int cflag; 1471 unsigned int cflag;
1487 1472
1488 cflag = tty->termios->c_cflag; 1473 cflag = tty->termios->c_cflag;
@@ -1502,9 +1487,7 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old
1502 } 1487 }
1503 1488
1504 /* change the port settings to the new ones specified */ 1489 /* change the port settings to the new ones specified */
1505 change_port_settings (edge_port, old_termios); 1490 change_port_settings(tty, edge_port, old_termios);
1506
1507 return;
1508} 1491}
1509 1492
1510 1493
@@ -1536,25 +1519,9 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va
1536 return 0; 1519 return 0;
1537} 1520}
1538 1521
1539static int get_number_bytes_avail(struct edgeport_port *edge_port, unsigned int __user *value) 1522static int edge_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear)
1540{
1541 unsigned int result = 0;
1542 struct tty_struct *tty = edge_port->port->tty;
1543
1544 if (!tty)
1545 return -ENOIOCTLCMD;
1546
1547 result = tty->read_cnt;
1548
1549 dbg("%s(%d) = %d", __func__, edge_port->port->number, result);
1550 if (copy_to_user(value, &result, sizeof(int)))
1551 return -EFAULT;
1552 //return 0;
1553 return -ENOIOCTLCMD;
1554}
1555
1556static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear)
1557{ 1523{
1524 struct usb_serial_port *port = tty->driver_data;
1558 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1525 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1559 unsigned int mcr; 1526 unsigned int mcr;
1560 1527
@@ -1582,8 +1549,9 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
1582 return 0; 1549 return 0;
1583} 1550}
1584 1551
1585static int edge_tiocmget(struct usb_serial_port *port, struct file *file) 1552static int edge_tiocmget(struct tty_struct *tty, struct file *file)
1586{ 1553{
1554 struct usb_serial_port *port = tty->driver_data;
1587 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1555 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1588 unsigned int result = 0; 1556 unsigned int result = 0;
1589 unsigned int msr; 1557 unsigned int msr;
@@ -1624,9 +1592,6 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
1624 tmp.baud_base = 9600; 1592 tmp.baud_base = 9600;
1625 tmp.close_delay = 5*HZ; 1593 tmp.close_delay = 5*HZ;
1626 tmp.closing_wait = 30*HZ; 1594 tmp.closing_wait = 30*HZ;
1627// tmp.custom_divisor = state->custom_divisor;
1628// tmp.hub6 = state->hub6;
1629// tmp.io_type = state->io_type;
1630 1595
1631 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1596 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1632 return -EFAULT; 1597 return -EFAULT;
@@ -1639,8 +1604,10 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
1639 * SerialIoctl 1604 * SerialIoctl
1640 * this function handles any ioctl calls to the driver 1605 * this function handles any ioctl calls to the driver
1641 *****************************************************************************/ 1606 *****************************************************************************/
1642static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) 1607static int edge_ioctl(struct tty_struct *tty, struct file *file,
1608 unsigned int cmd, unsigned long arg)
1643{ 1609{
1610 struct usb_serial_port *port = tty->driver_data;
1644 DEFINE_WAIT(wait); 1611 DEFINE_WAIT(wait);
1645 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1612 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1646 struct async_icount cnow; 1613 struct async_icount cnow;
@@ -1650,25 +1617,14 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
1650 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 1617 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
1651 1618
1652 switch (cmd) { 1619 switch (cmd) {
1653 // return number of bytes available
1654 case TIOCINQ:
1655 dbg("%s (%d) TIOCINQ", __func__, port->number);
1656 return get_number_bytes_avail(edge_port, (unsigned int __user *) arg);
1657 break;
1658
1659 case TIOCSERGETLSR: 1620 case TIOCSERGETLSR:
1660 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 1621 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
1661 return get_lsr_info(edge_port, (unsigned int __user *) arg); 1622 return get_lsr_info(edge_port, (unsigned int __user *) arg);
1662 return 0;
1663 1623
1664 case TIOCGSERIAL: 1624 case TIOCGSERIAL:
1665 dbg("%s (%d) TIOCGSERIAL", __func__, port->number); 1625 dbg("%s (%d) TIOCGSERIAL", __func__, port->number);
1666 return get_serial_info(edge_port, (struct serial_struct __user *) arg); 1626 return get_serial_info(edge_port, (struct serial_struct __user *) arg);
1667 1627
1668 case TIOCSSERIAL:
1669 dbg("%s (%d) TIOCSSERIAL", __func__, port->number);
1670 break;
1671
1672 case TIOCMIWAIT: 1628 case TIOCMIWAIT:
1673 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 1629 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
1674 cprev = edge_port->icount; 1630 cprev = edge_port->icount;
@@ -1723,8 +1679,9 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
1723 * SerialBreak 1679 * SerialBreak
1724 * this function sends a break to the port 1680 * this function sends a break to the port
1725 *****************************************************************************/ 1681 *****************************************************************************/
1726static void edge_break (struct usb_serial_port *port, int break_state) 1682static void edge_break (struct tty_struct *tty, int break_state)
1727{ 1683{
1684 struct usb_serial_port *port = tty->driver_data;
1728 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1685 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1729 struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial); 1686 struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial);
1730 int status; 1687 int status;
@@ -1866,7 +1823,7 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
1866 port = edge_serial->serial->port[edge_serial->rxPort]; 1823 port = edge_serial->serial->port[edge_serial->rxPort];
1867 edge_port = usb_get_serial_port_data(port); 1824 edge_port = usb_get_serial_port_data(port);
1868 if (edge_port->open) { 1825 if (edge_port->open) {
1869 tty = edge_port->port->tty; 1826 tty = edge_port->port->port.tty;
1870 if (tty) { 1827 if (tty) {
1871 dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort); 1828 dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort);
1872 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); 1829 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
@@ -1941,8 +1898,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
1941 handle_new_msr (edge_port, byte2); 1898 handle_new_msr (edge_port, byte2);
1942 1899
1943 /* send the current line settings to the port so we are in sync with any further termios calls */ 1900 /* send the current line settings to the port so we are in sync with any further termios calls */
1944 if (edge_port->port->tty) 1901 /* FIXME: locking on tty */
1945 change_port_settings (edge_port, edge_port->port->tty->termios); 1902 if (edge_port->port->port.tty)
1903 change_port_settings(edge_port->port->port.tty, edge_port, edge_port->port->port.tty->termios);
1946 1904
1947 /* we have completed the open */ 1905 /* we have completed the open */
1948 edge_port->openPending = false; 1906 edge_port->openPending = false;
@@ -2078,8 +2036,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l
2078 } 2036 }
2079 2037
2080 /* Place LSR data byte into Rx buffer */ 2038 /* Place LSR data byte into Rx buffer */
2081 if (lsrData && edge_port->port->tty) 2039 if (lsrData && edge_port->port->port.tty)
2082 edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1); 2040 edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1);
2083 2041
2084 /* update input line counters */ 2042 /* update input line counters */
2085 icount = &edge_port->icount; 2043 icount = &edge_port->icount;
@@ -2473,13 +2431,11 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
2473 * This routine is called to set the UART on the device to match the specified 2431 * This routine is called to set the UART on the device to match the specified
2474 * new settings. 2432 * new settings.
2475 *****************************************************************************/ 2433 *****************************************************************************/
2476#ifndef CMSPAR 2434
2477#define CMSPAR 0 2435static void change_port_settings(struct tty_struct *tty,
2478#endif 2436 struct edgeport_port *edge_port, struct ktermios *old_termios)
2479static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios)
2480{ 2437{
2481 struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); 2438 struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
2482 struct tty_struct *tty;
2483 int baud; 2439 int baud;
2484 unsigned cflag; 2440 unsigned cflag;
2485 __u8 mask = 0xff; 2441 __u8 mask = 0xff;
@@ -2498,13 +2454,6 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
2498 return; 2454 return;
2499 } 2455 }
2500 2456
2501 tty = edge_port->port->tty;
2502 if ((!tty) ||
2503 (!tty->termios)) {
2504 dbg("%s - no tty structures", __func__);
2505 return;
2506 }
2507
2508 cflag = tty->termios->c_cflag; 2457 cflag = tty->termios->c_cflag;
2509 2458
2510 switch (cflag & CSIZE) { 2459 switch (cflag & CSIZE) {