From 0587102cf9f427c185bfdeb2cef41e13ee0264b1 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 16 Sep 2010 18:21:52 +0100 Subject: tty: icount changeover for other main devices Again basically cut and paste Convert the main driver set to use the hooks for GICOUNT Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/char/cyclades.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'drivers/char/cyclades.c') diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 27aad94..4f152c2 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -2790,29 +2790,6 @@ cy_ioctl(struct tty_struct *tty, struct file *file, * NB: both 1->0 and 0->1 transitions are counted except for * RI where only 0->1 is counted. */ - case TIOCGICOUNT: { - struct serial_icounter_struct sic = { }; - - spin_lock_irqsave(&info->card->card_lock, flags); - cnow = info->icount; - spin_unlock_irqrestore(&info->card->card_lock, flags); - - sic.cts = cnow.cts; - sic.dsr = cnow.dsr; - sic.rng = cnow.rng; - sic.dcd = cnow.dcd; - sic.rx = cnow.rx; - sic.tx = cnow.tx; - sic.frame = cnow.frame; - sic.overrun = cnow.overrun; - sic.parity = cnow.parity; - sic.brk = cnow.brk; - sic.buf_overrun = cnow.buf_overrun; - - if (copy_to_user(argp, &sic, sizeof(sic))) - ret_val = -EFAULT; - break; - } default: ret_val = -ENOIOCTLCMD; } @@ -2823,6 +2800,31 @@ cy_ioctl(struct tty_struct *tty, struct file *file, return ret_val; } /* cy_ioctl */ +static int cy_get_icount(struct tty_struct *tty, + struct serial_icounter_struct *sic) +{ + struct cyclades_port *info = tty->driver_data; + struct cyclades_icount cnow; /* Used to snapshot */ + unsigned long flags; + + spin_lock_irqsave(&info->card->card_lock, flags); + cnow = info->icount; + spin_unlock_irqrestore(&info->card->card_lock, flags); + + sic->cts = cnow.cts; + sic->dsr = cnow.dsr; + sic->rng = cnow.rng; + sic->dcd = cnow.dcd; + sic->rx = cnow.rx; + sic->tx = cnow.tx; + sic->frame = cnow.frame; + sic->overrun = cnow.overrun; + sic->parity = cnow.parity; + sic->brk = cnow.brk; + sic->buf_overrun = cnow.buf_overrun; + return 0; +} + /* * This routine allows the tty driver to be notified when * device's termios settings have changed. Note that a @@ -4084,6 +4086,7 @@ static const struct tty_operations cy_ops = { .wait_until_sent = cy_wait_until_sent, .tiocmget = cy_tiocmget, .tiocmset = cy_tiocmset, + .get_icount = cy_get_icount, .proc_fops = &cyclades_proc_fops, }; -- cgit v1.1