Commit 01fd45f6 authored by Johan Hovold's avatar Johan Hovold
Browse files

USB: serial: add generic support for TIOCSSERIAL



TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

The closing_wait parameter determines how long to wait for the transfer
buffers to drain during close and the default timeout of 30 seconds may
not be sufficient at low line speeds. In other cases, when for example
flow is stopped, the default timeout may instead be too long.

Add generic support for TIOCSSERIAL and TIOCGSERIAL with handling of the
three common parameters close_delay, closing_wait and line for the
benefit of all USB serial drivers while still allowing drivers to
implement further functionality through the existing callbacks.

This currently includes a few drivers that report their base baud clock
rate even if that is really only of interest when setting custom
divisors through the deprecated ASYNC_SPD_CUST interface; an interface
which only the FTDI driver actually implements.

Some drivers have also been reporting back a fake UART type, something
which should no longer be needed and will be dropped by a follow-on
patch.

Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 5f92aee9
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -385,17 +385,10 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
	return result;
}

static int ark3116_get_serial_info(struct tty_struct *tty,
static void ark3116_get_serial_info(struct tty_struct *tty,
			struct serial_struct *ss)
{
	struct usb_serial_port *port = tty->driver_data;

	ss->type = PORT_16654;
	ss->line = port->minor;
	ss->close_delay = 50;
	ss->closing_wait = 3000;

	return 0;
}

static int ark3116_tiocmget(struct tty_struct *tty)
+3 −9
Original line number Diff line number Diff line
@@ -820,19 +820,13 @@ static int f81232_carrier_raised(struct usb_serial_port *port)
	return 0;
}

static int f81232_get_serial_info(struct tty_struct *tty,
		struct serial_struct *ss)
static void f81232_get_serial(struct tty_struct *tty, struct serial_struct *ss)
{
	struct usb_serial_port *port = tty->driver_data;
	struct f81232_private *priv = usb_get_serial_port_data(port);

	ss->type = PORT_16550A;
	ss->line = port->minor;
	ss->baud_base = priv->baud_base;
	ss->close_delay = 50;
	ss->closing_wait = 3000;

	return 0;
}

static void  f81232_interrupt_work(struct work_struct *work)
@@ -1023,7 +1017,7 @@ static struct usb_serial_driver f81232_device = {
	.close =		f81232_close,
	.dtr_rts =		f81232_dtr_rts,
	.carrier_raised =	f81232_carrier_raised,
	.get_serial =		f81232_get_serial_info,
	.get_serial =		f81232_get_serial,
	.break_ctl =		f81232_break_ctl,
	.set_termios =		f81232_set_termios,
	.tiocmget =		f81232_tiocmget,
@@ -1048,7 +1042,7 @@ static struct usb_serial_driver f81534a_device = {
	.close =		f81232_close,
	.dtr_rts =		f81232_dtr_rts,
	.carrier_raised =	f81232_carrier_raised,
	.get_serial =		f81232_get_serial_info,
	.get_serial =		f81232_get_serial,
	.break_ctl =		f81232_break_ctl,
	.set_termios =		f81232_set_termios,
	.tiocmget =		f81232_tiocmget,
+1 −7
Original line number Diff line number Diff line
@@ -1140,8 +1140,7 @@ static void f81534_close(struct usb_serial_port *port)
	mutex_unlock(&serial_priv->urb_mutex);
}

static int f81534_get_serial_info(struct tty_struct *tty,
				  struct serial_struct *ss)
static void f81534_get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
{
	struct usb_serial_port *port = tty->driver_data;
	struct f81534_port_private *port_priv;
@@ -1149,12 +1148,7 @@ static int f81534_get_serial_info(struct tty_struct *tty,
	port_priv = usb_get_serial_port_data(port);

	ss->type = PORT_16550A;
	ss->line = port->minor;
	ss->baud_base = port_priv->baud_base;
	ss->close_delay = 50;
	ss->closing_wait = 3000;

	return 0;
}

static void f81534_process_per_serial_block(struct usb_serial_port *port,
+2 −9
Original line number Diff line number Diff line
@@ -1082,8 +1082,7 @@ static int ftdi_tiocmset(struct tty_struct *tty,
			unsigned int set, unsigned int clear);
static int  ftdi_ioctl(struct tty_struct *tty,
			unsigned int cmd, unsigned long arg);
static int get_serial_info(struct tty_struct *tty,
				struct serial_struct *ss);
static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss);
static int set_serial_info(struct tty_struct *tty,
				struct serial_struct *ss);
static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
@@ -1477,20 +1476,14 @@ static int read_latency_timer(struct usb_serial_port *port)
	return 0;
}

static int get_serial_info(struct tty_struct *tty,
				struct serial_struct *ss)
static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
{
	struct usb_serial_port *port = tty->driver_data;
	struct ftdi_private *priv = usb_get_serial_port_data(port);

	ss->line = port->minor;
	ss->flags = priv->flags;
	ss->baud_base = priv->baud_base;
	ss->custom_divisor = priv->custom_divisor;
	ss->close_delay = 50;
	ss->closing_wait = 3000;

	return 0;
}

static int set_serial_info(struct tty_struct *tty,
+2 −10
Original line number Diff line number Diff line
@@ -1594,17 +1594,9 @@ static int edge_tiocmget(struct tty_struct *tty)
	return result;
}

static int get_serial_info(struct tty_struct *tty,
				struct serial_struct *ss)
static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
{
	struct usb_serial_port *port = tty->driver_data;

	ss->type = PORT_16550A;
	ss->line		= port->minor;
	ss->close_delay		= 50;
	ss->closing_wait	= 3000;

	return 0;
}


Loading