Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e255f207 authored by Mikhail Zaytsev's avatar Mikhail Zaytsev Committed by Johan Hovold
Browse files

USB: serial: ark3116: move TIOCGSERIAL ioctl case to function



The patch moves TIOCGSERIAL ioctl case to get_serial_info function.

Signed-off-by: default avatarMikhail Zaytsev <flashed@mail.ru>
[johan: keep the automatic __user pointer variable in ioctl callback ]
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 63443a0b
Loading
Loading
Loading
Loading
+19 −13
Original line number Original line Diff line number Diff line
@@ -397,27 +397,33 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
	return result;
	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,
static int ark3116_ioctl(struct tty_struct *tty,
			 unsigned int cmd, unsigned long arg)
			 unsigned int cmd, unsigned long arg)
{
{
	struct usb_serial_port *port = tty->driver_data;
	struct usb_serial_port *port = tty->driver_data;
	struct serial_struct serstruct;
	void __user *user_arg = (void __user *)arg;
	void __user *user_arg = (void __user *)arg;


	switch (cmd) {
	switch (cmd) {
	case TIOCGSERIAL:
	case TIOCGSERIAL:
		/* XXX: Some of these values are probably wrong. */
		return ark3116_get_serial_info(port, user_arg);
		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;
	default:
	default:
		break;
		break;
	}
	}