summaryrefslogtreecommitdiff
path: root/drivers/usb/serial/ark3116.c
diff options
context:
space:
mode:
authorMikhail Zaytsev <flashed@mail.ru>2018-01-06 20:15:22 +0300
committerJohan Hovold <johan@kernel.org>2018-01-09 14:53:27 +0300
commite255f2078b1206e51f1abd0623902429db35fb5f (patch)
tree898ae9dbe2fda026943ba3a10c259f30e39a8010 /drivers/usb/serial/ark3116.c
parent63443a0b2ab277ef677640bc32b4f94661821b70 (diff)
downloadlinux-e255f2078b1206e51f1abd0623902429db35fb5f.tar.xz
USB: serial: ark3116: move TIOCGSERIAL ioctl case to function
The patch moves TIOCGSERIAL ioctl case to get_serial_info function. Signed-off-by: Mikhail Zaytsev <flashed@mail.ru> [johan: keep the automatic __user pointer variable in ioctl callback ] Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/ark3116.c')
-rw-r--r--drivers/usb/serial/ark3116.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 2e957c76f61e..7796ad8e33c6 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -397,27 +397,33 @@ err_free:
return result;
}
+static int ark3116_get_serial_info(struct usb_serial_port *port,
+ struct serial_struct __user *retinfo)
+{
+ struct serial_struct tmp;
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ tmp.type = PORT_16654;
+ tmp.line = port->minor;
+ tmp.port = port->port_number;
+ tmp.baud_base = 460800;
+
+ if (copy_to_user(retinfo, &tmp, sizeof(tmp)))
+ return -EFAULT;
+
+ return 0;
+}
+
static int ark3116_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{
struct usb_serial_port *port = tty->driver_data;
- struct serial_struct serstruct;
void __user *user_arg = (void __user *)arg;
switch (cmd) {
case TIOCGSERIAL:
- /* XXX: Some of these values are probably wrong. */
- memset(&serstruct, 0, sizeof(serstruct));
- serstruct.type = PORT_16654;
- serstruct.line = port->minor;
- serstruct.port = port->port_number;
- serstruct.custom_divisor = 0;
- serstruct.baud_base = 460800;
-
- if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
- return -EFAULT;
-
- return 0;
+ return ark3116_get_serial_info(port, user_arg);
default:
break;
}