Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
424a4b59 4807f2c0

+12 -19
+12 -19
drivers/staging/greybus/uart.c
··· 708 708 return retval; 709 709 } 710 710 711 - static int get_serial_usage(struct gb_tty *gb_tty, 712 - struct serial_icounter_struct __user *count) 711 + static int gb_tty_get_icount(struct tty_struct *tty, 712 + struct serial_icounter_struct *icount) 713 713 { 714 - struct serial_icounter_struct icount; 715 - int retval = 0; 714 + struct gb_tty *gb_tty = tty->driver_data; 716 715 717 - memset(&icount, 0, sizeof(icount)); 718 - icount.dsr = gb_tty->iocount.dsr; 719 - icount.rng = gb_tty->iocount.rng; 720 - icount.dcd = gb_tty->iocount.dcd; 721 - icount.frame = gb_tty->iocount.frame; 722 - icount.overrun = gb_tty->iocount.overrun; 723 - icount.parity = gb_tty->iocount.parity; 724 - icount.brk = gb_tty->iocount.brk; 716 + icount->dsr = gb_tty->iocount.dsr; 717 + icount->rng = gb_tty->iocount.rng; 718 + icount->dcd = gb_tty->iocount.dcd; 719 + icount->frame = gb_tty->iocount.frame; 720 + icount->overrun = gb_tty->iocount.overrun; 721 + icount->parity = gb_tty->iocount.parity; 722 + icount->brk = gb_tty->iocount.brk; 725 723 726 - if (copy_to_user(count, &icount, sizeof(icount)) > 0) 727 - retval = -EFAULT; 728 - 729 - return retval; 724 + return 0; 730 725 } 731 726 732 727 static int gb_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ··· 738 743 (struct serial_struct __user *)arg); 739 744 case TIOCMIWAIT: 740 745 return wait_serial_change(gb_tty, arg); 741 - case TIOCGICOUNT: 742 - return get_serial_usage(gb_tty, 743 - (struct serial_icounter_struct __user *)arg); 744 746 } 745 747 746 748 return -ENOIOCTLCMD; ··· 819 827 .set_termios = gb_tty_set_termios, 820 828 .tiocmget = gb_tty_tiocmget, 821 829 .tiocmset = gb_tty_tiocmset, 830 + .get_icount = gb_tty_get_icount, 822 831 }; 823 832 824 833 static const struct tty_port_operations gb_port_ops = {