aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2010-09-16 13:21:24 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 13:20:04 -0400
commitd281da7ff6f70efca0553c288bb883e8605b3862 (patch)
treeee6a46b33070159af51c07643cf99186f1ef3e03 /drivers/serial
parent68707539df1e9d12435e5d54ffedc7ded50fcd01 (diff)
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>
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/serial_core.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index bc6cddd10294..c4ea14670d44 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1074,10 +1074,10 @@ uart_wait_modem_status(struct uart_state *state, unsigned long arg)
1074 * NB: both 1->0 and 0->1 transitions are counted except for 1074 * NB: both 1->0 and 0->1 transitions are counted except for
1075 * RI where only 0->1 is counted. 1075 * RI where only 0->1 is counted.
1076 */ 1076 */
1077static int uart_get_count(struct uart_state *state, 1077static int uart_get_icount(struct tty_struct *tty,
1078 struct serial_icounter_struct __user *icnt) 1078 struct serial_icounter_struct *icount)
1079{ 1079{
1080 struct serial_icounter_struct icount; 1080 struct uart_state *state = tty->driver_data;
1081 struct uart_icount cnow; 1081 struct uart_icount cnow;
1082 struct uart_port *uport = state->uart_port; 1082 struct uart_port *uport = state->uart_port;
1083 1083
@@ -1085,19 +1085,19 @@ static int uart_get_count(struct uart_state *state,
1085 memcpy(&cnow, &uport->icount, sizeof(struct uart_icount)); 1085 memcpy(&cnow, &uport->icount, sizeof(struct uart_icount));
1086 spin_unlock_irq(&uport->lock); 1086 spin_unlock_irq(&uport->lock);
1087 1087
1088 icount.cts = cnow.cts; 1088 icount->cts = cnow.cts;
1089 icount.dsr = cnow.dsr; 1089 icount->dsr = cnow.dsr;
1090 icount.rng = cnow.rng; 1090 icount->rng = cnow.rng;
1091 icount.dcd = cnow.dcd; 1091 icount->dcd = cnow.dcd;
1092 icount.rx = cnow.rx; 1092 icount->rx = cnow.rx;
1093 icount.tx = cnow.tx; 1093 icount->tx = cnow.tx;
1094 icount.frame = cnow.frame; 1094 icount->frame = cnow.frame;
1095 icount.overrun = cnow.overrun; 1095 icount->overrun = cnow.overrun;
1096 icount.parity = cnow.parity; 1096 icount->parity = cnow.parity;
1097 icount.brk = cnow.brk; 1097 icount->brk = cnow.brk;
1098 icount.buf_overrun = cnow.buf_overrun; 1098 icount->buf_overrun = cnow.buf_overrun;
1099 1099
1100 return copy_to_user(icnt, &icount, sizeof(icount)) ? -EFAULT : 0; 1100 return 0;
1101} 1101}
1102 1102
1103/* 1103/*
@@ -1150,10 +1150,6 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
1150 case TIOCMIWAIT: 1150 case TIOCMIWAIT:
1151 ret = uart_wait_modem_status(state, arg); 1151 ret = uart_wait_modem_status(state, arg);
1152 break; 1152 break;
1153
1154 case TIOCGICOUNT:
1155 ret = uart_get_count(state, uarg);
1156 break;
1157 } 1153 }
1158 1154
1159 if (ret != -ENOIOCTLCMD) 1155 if (ret != -ENOIOCTLCMD)
@@ -2295,6 +2291,7 @@ static const struct tty_operations uart_ops = {
2295#endif 2291#endif
2296 .tiocmget = uart_tiocmget, 2292 .tiocmget = uart_tiocmget,
2297 .tiocmset = uart_tiocmset, 2293 .tiocmset = uart_tiocmset,
2294 .get_icount = uart_get_icount,
2298#ifdef CONFIG_CONSOLE_POLL 2295#ifdef CONFIG_CONSOLE_POLL
2299 .poll_init = uart_poll_init, 2296 .poll_init = uart_poll_init,
2300 .poll_get_char = uart_poll_get_char, 2297 .poll_get_char = uart_poll_get_char,