Skip to content

Commit e255f20

Browse files
Flashedjhovold
authored andcommitted
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>
1 parent 63443a0 commit e255f20

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

drivers/usb/serial/ark3116.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -397,27 +397,33 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
397397
return result;
398398
}
399399

400+
static int ark3116_get_serial_info(struct usb_serial_port *port,
401+
struct serial_struct __user *retinfo)
402+
{
403+
struct serial_struct tmp;
404+
405+
memset(&tmp, 0, sizeof(tmp));
406+
407+
tmp.type = PORT_16654;
408+
tmp.line = port->minor;
409+
tmp.port = port->port_number;
410+
tmp.baud_base = 460800;
411+
412+
if (copy_to_user(retinfo, &tmp, sizeof(tmp)))
413+
return -EFAULT;
414+
415+
return 0;
416+
}
417+
400418
static int ark3116_ioctl(struct tty_struct *tty,
401419
unsigned int cmd, unsigned long arg)
402420
{
403421
struct usb_serial_port *port = tty->driver_data;
404-
struct serial_struct serstruct;
405422
void __user *user_arg = (void __user *)arg;
406423

407424
switch (cmd) {
408425
case TIOCGSERIAL:
409-
/* XXX: Some of these values are probably wrong. */
410-
memset(&serstruct, 0, sizeof(serstruct));
411-
serstruct.type = PORT_16654;
412-
serstruct.line = port->minor;
413-
serstruct.port = port->port_number;
414-
serstruct.custom_divisor = 0;
415-
serstruct.baud_base = 460800;
416-
417-
if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
418-
return -EFAULT;
419-
420-
return 0;
426+
return ark3116_get_serial_info(port, user_arg);
421427
default:
422428
break;
423429
}

0 commit comments

Comments
 (0)