USB: mos7840: switch to generic get_icount implementation

Switch to the generic get_icount implementation.

Note that the interrupt counters will no longer be reset at open which
is in accordance with which how the other drivers work.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Johan Hovold 2013-03-21 12:37:16 +01:00 committed by Greg Kroah-Hartman
parent c9fac85345
commit 8c1a07ff7f

View file

@ -220,7 +220,6 @@ struct moschip_port {
char open_ports; char open_ports;
wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */
int delta_msr_cond; int delta_msr_cond;
struct async_icount icount;
struct usb_serial_port *port; /* loop back to the owner of this object */ struct usb_serial_port *port; /* loop back to the owner of this object */
/* Offsets */ /* Offsets */
@ -399,11 +398,10 @@ static void mos7840_handle_new_msr(struct moschip_port *port, __u8 new_msr)
struct moschip_port *mos7840_port; struct moschip_port *mos7840_port;
struct async_icount *icount; struct async_icount *icount;
mos7840_port = port; mos7840_port = port;
icount = &mos7840_port->icount;
if (new_msr & if (new_msr &
(MOS_MSR_DELTA_CTS | MOS_MSR_DELTA_DSR | MOS_MSR_DELTA_RI | (MOS_MSR_DELTA_CTS | MOS_MSR_DELTA_DSR | MOS_MSR_DELTA_RI |
MOS_MSR_DELTA_CD)) { MOS_MSR_DELTA_CD)) {
icount = &mos7840_port->icount; icount = &mos7840_port->port->icount;
/* update input line counters */ /* update input line counters */
if (new_msr & MOS_MSR_DELTA_CTS) if (new_msr & MOS_MSR_DELTA_CTS)
@ -434,7 +432,7 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
} }
/* update input line counters */ /* update input line counters */
icount = &port->icount; icount = &port->port->icount;
if (new_lsr & SERIAL_LSR_BI) if (new_lsr & SERIAL_LSR_BI)
icount->brk++; icount->brk++;
if (new_lsr & SERIAL_LSR_OE) if (new_lsr & SERIAL_LSR_OE)
@ -761,8 +759,8 @@ static void mos7840_bulk_in_callback(struct urb *urb)
struct tty_port *tport = &mos7840_port->port->port; struct tty_port *tport = &mos7840_port->port->port;
tty_insert_flip_string(tport, data, urb->actual_length); tty_insert_flip_string(tport, data, urb->actual_length);
tty_flip_buffer_push(tport); tty_flip_buffer_push(tport);
mos7840_port->icount.rx += urb->actual_length; port->icount.rx += urb->actual_length;
dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx); dev_dbg(&port->dev, "icount.rx is %d:\n", port->icount.rx);
} }
if (!mos7840_port->read_urb) { if (!mos7840_port->read_urb) {
@ -1113,17 +1111,12 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
/* initialize our wait queues */ /* initialize our wait queues */
init_waitqueue_head(&mos7840_port->wait_chase); init_waitqueue_head(&mos7840_port->wait_chase);
/* initialize our icount structure */
memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount));
/* initialize our port settings */ /* initialize our port settings */
/* Must set to enable ints! */ /* Must set to enable ints! */
mos7840_port->shadowMCR = MCR_MASTER_IE; mos7840_port->shadowMCR = MCR_MASTER_IE;
/* send a open port command */ /* send a open port command */
mos7840_port->open = 1; mos7840_port->open = 1;
/* mos7840_change_port_settings(mos7840_port,old_termios); */ /* mos7840_change_port_settings(mos7840_port,old_termios); */
mos7840_port->icount.tx = 0;
mos7840_port->icount.rx = 0;
return 0; return 0;
} }
@ -1489,8 +1482,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
goto exit; goto exit;
} }
bytes_sent = transfer_size; bytes_sent = transfer_size;
mos7840_port->icount.tx += transfer_size; port->icount.tx += transfer_size;
dev_dbg(&port->dev, "mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx); dev_dbg(&port->dev, "icount.tx is %d:\n", port->icount.tx);
exit: exit:
return bytes_sent; return bytes_sent;
@ -2109,37 +2102,6 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
return 0; return 0;
} }
static int mos7840_get_icount(struct tty_struct *tty,
struct serial_icounter_struct *icount)
{
struct usb_serial_port *port = tty->driver_data;
struct moschip_port *mos7840_port;
struct async_icount cnow;
unsigned long flags;
mos7840_port = mos7840_get_port_private(port);
spin_lock_irqsave(&port->lock, flags);
cnow = mos7840_port->icount;
spin_unlock_irqrestore(&port->lock, flags);
icount->cts = cnow.cts;
icount->dsr = cnow.dsr;
icount->rng = cnow.rng;
icount->dcd = cnow.dcd;
icount->rx = cnow.rx;
icount->tx = cnow.tx;
icount->frame = cnow.frame;
icount->overrun = cnow.overrun;
icount->parity = cnow.parity;
icount->brk = cnow.brk;
icount->buf_overrun = cnow.buf_overrun;
dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n", __func__,
icount->rx, icount->tx);
return 0;
}
/***************************************************************************** /*****************************************************************************
* SerialIoctl * SerialIoctl
* this function handles any ioctl calls to the driver * this function handles any ioctl calls to the driver
@ -2183,7 +2145,7 @@ static int mos7840_ioctl(struct tty_struct *tty,
case TIOCMIWAIT: case TIOCMIWAIT:
dev_dbg(&port->dev, "%s TIOCMIWAIT\n", __func__); dev_dbg(&port->dev, "%s TIOCMIWAIT\n", __func__);
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
cprev = mos7840_port->icount; cprev = port->icount;
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
while (1) { while (1) {
/* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */
@ -2201,7 +2163,7 @@ static int mos7840_ioctl(struct tty_struct *tty,
return -EIO; return -EIO;
spin_lock_irqsave(&port->lock, flags); spin_lock_irqsave(&port->lock, flags);
cnow = mos7840_port->icount; cnow = port->icount;
spin_unlock_irqrestore(&port->lock, flags); spin_unlock_irqrestore(&port->lock, flags);
if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
@ -2565,7 +2527,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
.break_ctl = mos7840_break, .break_ctl = mos7840_break,
.tiocmget = mos7840_tiocmget, .tiocmget = mos7840_tiocmget,
.tiocmset = mos7840_tiocmset, .tiocmset = mos7840_tiocmset,
.get_icount = mos7840_get_icount, .get_icount = usb_serial_generic_get_icount,
.port_probe = mos7840_port_probe, .port_probe = mos7840_port_probe,
.port_remove = mos7840_port_remove, .port_remove = mos7840_port_remove,
.read_bulk_callback = mos7840_bulk_in_callback, .read_bulk_callback = mos7840_bulk_in_callback,