tty: Make tiocgicount a handler
Dan Rosenberg noted that various drivers return the struct with uncleared fields. Instead of spending forever trying to stomp all the drivers that get it wrong (and every new driver) do the job in one place. This first patch adds the needed operations and hooks them up, including the needed USB midlayer and serial core plumbing. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
68707539df
commit
d281da7ff6
@@ -1074,10 +1074,10 @@ uart_wait_modem_status(struct uart_state *state, unsigned long arg)
|
||||
* NB: both 1->0 and 0->1 transitions are counted except for
|
||||
* RI where only 0->1 is counted.
|
||||
*/
|
||||
static int uart_get_count(struct uart_state *state,
|
||||
struct serial_icounter_struct __user *icnt)
|
||||
static int uart_get_icount(struct tty_struct *tty,
|
||||
struct serial_icounter_struct *icount)
|
||||
{
|
||||
struct serial_icounter_struct icount;
|
||||
struct uart_state *state = tty->driver_data;
|
||||
struct uart_icount cnow;
|
||||
struct uart_port *uport = state->uart_port;
|
||||
|
||||
@@ -1085,19 +1085,19 @@ static int uart_get_count(struct uart_state *state,
|
||||
memcpy(&cnow, &uport->icount, sizeof(struct uart_icount));
|
||||
spin_unlock_irq(&uport->lock);
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
return copy_to_user(icnt, &icount, sizeof(icount)) ? -EFAULT : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1150,10 +1150,6 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
|
||||
case TIOCMIWAIT:
|
||||
ret = uart_wait_modem_status(state, arg);
|
||||
break;
|
||||
|
||||
case TIOCGICOUNT:
|
||||
ret = uart_get_count(state, uarg);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret != -ENOIOCTLCMD)
|
||||
@@ -2295,6 +2291,7 @@ static const struct tty_operations uart_ops = {
|
||||
#endif
|
||||
.tiocmget = uart_tiocmget,
|
||||
.tiocmset = uart_tiocmset,
|
||||
.get_icount = uart_get_icount,
|
||||
#ifdef CONFIG_CONSOLE_POLL
|
||||
.poll_init = uart_poll_init,
|
||||
.poll_get_char = uart_poll_get_char,
|
||||
|
||||
Reference in New Issue
Block a user