aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/io_ti.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/io_ti.c')
-rw-r--r--drivers/usb/serial/io_ti.c98
1 files changed, 17 insertions, 81 deletions
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 7777172206de..158bf4bc29cc 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -86,7 +86,7 @@ struct edgeport_port {
86 int baud_rate; 86 int baud_rate;
87 int close_pending; 87 int close_pending;
88 int lsr_event; 88 int lsr_event;
89 struct async_icount icount; 89
90 struct edgeport_serial *edge_serial; 90 struct edgeport_serial *edge_serial;
91 struct usb_serial_port *port; 91 struct usb_serial_port *port;
92 __u8 bUartMode; /* Port type, 0: RS232, etc. */ 92 __u8 bUartMode; /* Port type, 0: RS232, etc. */
@@ -206,7 +206,7 @@ static int restart_read(struct edgeport_port *edge_port);
206 206
207static void edge_set_termios(struct tty_struct *tty, 207static void edge_set_termios(struct tty_struct *tty,
208 struct usb_serial_port *port, struct ktermios *old_termios); 208 struct usb_serial_port *port, struct ktermios *old_termios);
209static void edge_send(struct tty_struct *tty); 209static void edge_send(struct usb_serial_port *port, struct tty_struct *tty);
210 210
211/* sysfs attributes */ 211/* sysfs attributes */
212static int edge_create_sysfs_attrs(struct usb_serial_port *port); 212static int edge_create_sysfs_attrs(struct usb_serial_port *port);
@@ -1445,7 +1445,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
1445 1445
1446 if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | 1446 if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR |
1447 EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { 1447 EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
1448 icount = &edge_port->icount; 1448 icount = &edge_port->port->icount;
1449 1449
1450 /* update input line counters */ 1450 /* update input line counters */
1451 if (msr & EDGEPORT_MSR_DELTA_CTS) 1451 if (msr & EDGEPORT_MSR_DELTA_CTS)
@@ -1456,7 +1456,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
1456 icount->dcd++; 1456 icount->dcd++;
1457 if (msr & EDGEPORT_MSR_DELTA_RI) 1457 if (msr & EDGEPORT_MSR_DELTA_RI)
1458 icount->rng++; 1458 icount->rng++;
1459 wake_up_interruptible(&edge_port->port->delta_msr_wait); 1459 wake_up_interruptible(&edge_port->port->port.delta_msr_wait);
1460 } 1460 }
1461 1461
1462 /* Save the new modem status */ 1462 /* Save the new modem status */
@@ -1498,7 +1498,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1498 edge_tty_recv(edge_port->port, &data, 1); 1498 edge_tty_recv(edge_port->port, &data, 1);
1499 1499
1500 /* update input line counters */ 1500 /* update input line counters */
1501 icount = &edge_port->icount; 1501 icount = &edge_port->port->icount;
1502 if (new_lsr & LSR_BREAK) 1502 if (new_lsr & LSR_BREAK)
1503 icount->brk++; 1503 icount->brk++;
1504 if (new_lsr & LSR_OVER_ERR) 1504 if (new_lsr & LSR_OVER_ERR)
@@ -1657,7 +1657,7 @@ static void edge_bulk_in_callback(struct urb *urb)
1657 else 1657 else
1658 edge_tty_recv(edge_port->port, data, 1658 edge_tty_recv(edge_port->port, data,
1659 urb->actual_length); 1659 urb->actual_length);
1660 edge_port->icount.rx += urb->actual_length; 1660 edge_port->port->icount.rx += urb->actual_length;
1661 } 1661 }
1662 1662
1663exit: 1663exit:
@@ -1712,7 +1712,7 @@ static void edge_bulk_out_callback(struct urb *urb)
1712 1712
1713 /* send any buffered data */ 1713 /* send any buffered data */
1714 tty = tty_port_tty_get(&port->port); 1714 tty = tty_port_tty_get(&port->port);
1715 edge_send(tty); 1715 edge_send(port, tty);
1716 tty_kref_put(tty); 1716 tty_kref_put(tty);
1717} 1717}
1718 1718
@@ -1750,8 +1750,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
1750 1750
1751 dev = port->serial->dev; 1751 dev = port->serial->dev;
1752 1752
1753 memset(&(edge_port->icount), 0x00, sizeof(edge_port->icount));
1754
1755 /* turn off loopback */ 1753 /* turn off loopback */
1756 status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0); 1754 status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0);
1757 if (status) { 1755 if (status) {
@@ -1909,21 +1907,10 @@ static void edge_close(struct usb_serial_port *port)
1909 kfifo_reset_out(&edge_port->write_fifo); 1907 kfifo_reset_out(&edge_port->write_fifo);
1910 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1908 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1911 1909
1912 /* assuming we can still talk to the device,
1913 * send a close port command to it */
1914 dev_dbg(&port->dev, "%s - send umpc_close_port\n", __func__); 1910 dev_dbg(&port->dev, "%s - send umpc_close_port\n", __func__);
1915 port_number = port->number - port->serial->minor; 1911 port_number = port->number - port->serial->minor;
1916 1912 send_cmd(serial->dev, UMPC_CLOSE_PORT,
1917 mutex_lock(&serial->disc_mutex); 1913 (__u8)(UMPM_UART1_PORT + port_number), 0, NULL, 0);
1918 if (!serial->disconnected) {
1919 send_cmd(serial->dev,
1920 UMPC_CLOSE_PORT,
1921 (__u8)(UMPM_UART1_PORT + port_number),
1922 0,
1923 NULL,
1924 0);
1925 }
1926 mutex_unlock(&serial->disc_mutex);
1927 1914
1928 mutex_lock(&edge_serial->es_lock); 1915 mutex_lock(&edge_serial->es_lock);
1929 --edge_port->edge_serial->num_ports_open; 1916 --edge_port->edge_serial->num_ports_open;
@@ -1953,14 +1940,13 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
1953 1940
1954 count = kfifo_in_locked(&edge_port->write_fifo, data, count, 1941 count = kfifo_in_locked(&edge_port->write_fifo, data, count,
1955 &edge_port->ep_lock); 1942 &edge_port->ep_lock);
1956 edge_send(tty); 1943 edge_send(port, tty);
1957 1944
1958 return count; 1945 return count;
1959} 1946}
1960 1947
1961static void edge_send(struct tty_struct *tty) 1948static void edge_send(struct usb_serial_port *port, struct tty_struct *tty)
1962{ 1949{
1963 struct usb_serial_port *port = tty->driver_data;
1964 int count, result; 1950 int count, result;
1965 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1951 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1966 unsigned long flags; 1952 unsigned long flags;
@@ -1999,7 +1985,7 @@ static void edge_send(struct tty_struct *tty)
1999 edge_port->ep_write_urb_in_use = 0; 1985 edge_port->ep_write_urb_in_use = 0;
2000 /* TODO: reschedule edge_send */ 1986 /* TODO: reschedule edge_send */
2001 } else 1987 } else
2002 edge_port->icount.tx += count; 1988 edge_port->port->icount.tx += count;
2003 1989
2004 /* wakeup any process waiting for writes to complete */ 1990 /* wakeup any process waiting for writes to complete */
2005 /* there is now more room in the buffer for new writes */ 1991 /* there is now more room in the buffer for new writes */
@@ -2360,27 +2346,6 @@ static int edge_tiocmget(struct tty_struct *tty)
2360 return result; 2346 return result;
2361} 2347}
2362 2348
2363static int edge_get_icount(struct tty_struct *tty,
2364 struct serial_icounter_struct *icount)
2365{
2366 struct usb_serial_port *port = tty->driver_data;
2367 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2368 struct async_icount *ic = &edge_port->icount;
2369
2370 icount->cts = ic->cts;
2371 icount->dsr = ic->dsr;
2372 icount->rng = ic->rng;
2373 icount->dcd = ic->dcd;
2374 icount->tx = ic->tx;
2375 icount->rx = ic->rx;
2376 icount->frame = ic->frame;
2377 icount->parity = ic->parity;
2378 icount->overrun = ic->overrun;
2379 icount->brk = ic->brk;
2380 icount->buf_overrun = ic->buf_overrun;
2381 return 0;
2382}
2383
2384static int get_serial_info(struct edgeport_port *edge_port, 2349static int get_serial_info(struct edgeport_port *edge_port,
2385 struct serial_struct __user *retinfo) 2350 struct serial_struct __user *retinfo)
2386{ 2351{
@@ -2392,7 +2357,7 @@ static int get_serial_info(struct edgeport_port *edge_port,
2392 2357
2393 cwait = edge_port->port->port.closing_wait; 2358 cwait = edge_port->port->port.closing_wait;
2394 if (cwait != ASYNC_CLOSING_WAIT_NONE) 2359 if (cwait != ASYNC_CLOSING_WAIT_NONE)
2395 cwait = jiffies_to_msecs(closing_wait) / 10; 2360 cwait = jiffies_to_msecs(cwait) / 10;
2396 2361
2397 memset(&tmp, 0, sizeof(tmp)); 2362 memset(&tmp, 0, sizeof(tmp));
2398 2363
@@ -2416,8 +2381,6 @@ static int edge_ioctl(struct tty_struct *tty,
2416{ 2381{
2417 struct usb_serial_port *port = tty->driver_data; 2382 struct usb_serial_port *port = tty->driver_data;
2418 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2383 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2419 struct async_icount cnow;
2420 struct async_icount cprev;
2421 2384
2422 dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd); 2385 dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd);
2423 2386
@@ -2426,32 +2389,6 @@ static int edge_ioctl(struct tty_struct *tty,
2426 dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__); 2389 dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__);
2427 return get_serial_info(edge_port, 2390 return get_serial_info(edge_port,
2428 (struct serial_struct __user *) arg); 2391 (struct serial_struct __user *) arg);
2429 case TIOCMIWAIT:
2430 dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__);
2431 cprev = edge_port->icount;
2432 while (1) {
2433 interruptible_sleep_on(&port->delta_msr_wait);
2434 /* see if a signal did it */
2435 if (signal_pending(current))
2436 return -ERESTARTSYS;
2437
2438 if (port->serial->disconnected)
2439 return -EIO;
2440
2441 cnow = edge_port->icount;
2442 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
2443 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
2444 return -EIO; /* no change => error */
2445 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
2446 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
2447 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
2448 ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
2449 return 0;
2450 }
2451 cprev = cnow;
2452 }
2453 /* not reached */
2454 break;
2455 } 2392 }
2456 return -ENOIOCTLCMD; 2393 return -ENOIOCTLCMD;
2457} 2394}
@@ -2463,8 +2400,6 @@ static void edge_break(struct tty_struct *tty, int break_state)
2463 int status; 2400 int status;
2464 int bv = 0; /* Off */ 2401 int bv = 0; /* Off */
2465 2402
2466 tty_wait_until_sent(tty, 0);
2467
2468 if (break_state == -1) 2403 if (break_state == -1)
2469 bv = 1; /* On */ 2404 bv = 1; /* On */
2470 status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); 2405 status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv);
@@ -2546,7 +2481,6 @@ static int edge_port_remove(struct usb_serial_port *port)
2546 struct edgeport_port *edge_port; 2481 struct edgeport_port *edge_port;
2547 2482
2548 edge_port = usb_get_serial_port_data(port); 2483 edge_port = usb_get_serial_port_data(port);
2549
2550 edge_remove_sysfs_attrs(port); 2484 edge_remove_sysfs_attrs(port);
2551 kfifo_free(&edge_port->write_fifo); 2485 kfifo_free(&edge_port->write_fifo);
2552 kfree(edge_port); 2486 kfree(edge_port);
@@ -2618,7 +2552,8 @@ static struct usb_serial_driver edgeport_1port_device = {
2618 .set_termios = edge_set_termios, 2552 .set_termios = edge_set_termios,
2619 .tiocmget = edge_tiocmget, 2553 .tiocmget = edge_tiocmget,
2620 .tiocmset = edge_tiocmset, 2554 .tiocmset = edge_tiocmset,
2621 .get_icount = edge_get_icount, 2555 .tiocmiwait = usb_serial_generic_tiocmiwait,
2556 .get_icount = usb_serial_generic_get_icount,
2622 .write = edge_write, 2557 .write = edge_write,
2623 .write_room = edge_write_room, 2558 .write_room = edge_write_room,
2624 .chars_in_buffer = edge_chars_in_buffer, 2559 .chars_in_buffer = edge_chars_in_buffer,
@@ -2649,7 +2584,8 @@ static struct usb_serial_driver edgeport_2port_device = {
2649 .set_termios = edge_set_termios, 2584 .set_termios = edge_set_termios,
2650 .tiocmget = edge_tiocmget, 2585 .tiocmget = edge_tiocmget,
2651 .tiocmset = edge_tiocmset, 2586 .tiocmset = edge_tiocmset,
2652 .get_icount = edge_get_icount, 2587 .tiocmiwait = usb_serial_generic_tiocmiwait,
2588 .get_icount = usb_serial_generic_get_icount,
2653 .write = edge_write, 2589 .write = edge_write,
2654 .write_room = edge_write_room, 2590 .write_room = edge_write_room,
2655 .chars_in_buffer = edge_chars_in_buffer, 2591 .chars_in_buffer = edge_chars_in_buffer,