Browse Source

staging: greybus: use get_icount tty operation

Use the tty get_icount operation instead of implementing TIOCGICOUNT
directly.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Johan Hovold 8 years ago
parent
commit
424a4b595e
1 changed files with 12 additions and 19 deletions
  1. 12 19
      drivers/staging/greybus/uart.c

+ 12 - 19
drivers/staging/greybus/uart.c

@@ -708,25 +708,20 @@ static int wait_serial_change(struct gb_tty *gb_tty, unsigned long arg)
 	return retval;
 	return retval;
 }
 }
 
 
-static int get_serial_usage(struct gb_tty *gb_tty,
-			    struct serial_icounter_struct __user *count)
+static int gb_tty_get_icount(struct tty_struct *tty,
+			     struct serial_icounter_struct *icount)
 {
 {
-	struct serial_icounter_struct icount;
-	int retval = 0;
-
-	memset(&icount, 0, sizeof(icount));
-	icount.dsr = gb_tty->iocount.dsr;
-	icount.rng = gb_tty->iocount.rng;
-	icount.dcd = gb_tty->iocount.dcd;
-	icount.frame = gb_tty->iocount.frame;
-	icount.overrun = gb_tty->iocount.overrun;
-	icount.parity = gb_tty->iocount.parity;
-	icount.brk = gb_tty->iocount.brk;
+	struct gb_tty *gb_tty = tty->driver_data;
 
 
-	if (copy_to_user(count, &icount, sizeof(icount)) > 0)
-		retval = -EFAULT;
+	icount->dsr = gb_tty->iocount.dsr;
+	icount->rng = gb_tty->iocount.rng;
+	icount->dcd = gb_tty->iocount.dcd;
+	icount->frame = gb_tty->iocount.frame;
+	icount->overrun = gb_tty->iocount.overrun;
+	icount->parity = gb_tty->iocount.parity;
+	icount->brk = gb_tty->iocount.brk;
 
 
-	return retval;
+	return 0;
 }
 }
 
 
 static int gb_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 static int gb_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
@@ -743,9 +738,6 @@ static int gb_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
 				       (struct serial_struct __user *)arg);
 				       (struct serial_struct __user *)arg);
 	case TIOCMIWAIT:
 	case TIOCMIWAIT:
 		return wait_serial_change(gb_tty, arg);
 		return wait_serial_change(gb_tty, arg);
-	case TIOCGICOUNT:
-		return get_serial_usage(gb_tty,
-					(struct serial_icounter_struct __user *)arg);
 	}
 	}
 
 
 	return -ENOIOCTLCMD;
 	return -ENOIOCTLCMD;
@@ -827,6 +819,7 @@ static const struct tty_operations gb_ops = {
 	.set_termios =		gb_tty_set_termios,
 	.set_termios =		gb_tty_set_termios,
 	.tiocmget =		gb_tty_tiocmget,
 	.tiocmget =		gb_tty_tiocmget,
 	.tiocmset =		gb_tty_tiocmset,
 	.tiocmset =		gb_tty_tiocmset,
+	.get_icount =		gb_tty_get_icount,
 };
 };
 
 
 static const struct tty_port_operations gb_port_ops = {
 static const struct tty_port_operations gb_port_ops = {