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

Commit da3b447a authored by Tarun Gupta's avatar Tarun Gupta Committed by Matt Wagantall
Browse files

USB: android: Allow reducing number of serial interfaces on comp switch



serial_function_bind_config will do initialization only once
and will only do bind for next composition switches with this we
can not support decrease or increase in number of serial
interfaces.

However it is possible to support compositions with number of
serial interfaces less than initialized. This change adds code
to handle the case where number of serial interface is less than
initialized. With this we do not support increasing number of
serial interfaces.

Change-Id: I2820e17199d94d898eaa367b63e6836f78d14d3e
Signed-off-by: default avatarTarun Gupta <tarung@codeaurora.org>
parent 278e185c
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -1791,14 +1791,9 @@ static int serial_function_bind_config(struct android_usb_function *f,
{
	char *name, *xport_name = NULL;
	char buf[32], *b, xport_name_buf[32], *tb;
	int err = -1, i;
	static int serial_initialized, ports;
	int err = -1, i, ports = 0;
	static int serial_initialized;
	struct serial_function_config *config = f->config;

	if (serial_initialized)
		goto bind_config;

	serial_initialized = 1;
	strlcpy(buf, serial_transports, sizeof(buf));
	b = strim(buf);

@@ -1811,11 +1806,15 @@ static int serial_function_bind_config(struct android_usb_function *f,
		if (name) {
			if (tb)
				xport_name = strsep(&tb, ",");
			err = gserial_init_port(ports, name, xport_name);
			if (!serial_initialized) {
				err = gserial_init_port(ports, name,
						xport_name);
				if (err) {
				pr_err("serial: Cannot open port '%s'", name);
					pr_err("serial: Cannot open port '%s'",
							name);
					goto out;
				}
			}
			ports++;
			if (ports >= MAX_SERIAL_INSTANCES) {
				pr_err("serial: max ports reached '%s'", name);
@@ -1823,6 +1822,12 @@ static int serial_function_bind_config(struct android_usb_function *f,
			}
		}
	}

	config->instances_on = ports;

	if (serial_initialized)
		goto bind_config;

	err = gport_setup(c);
	if (err) {
		pr_err("serial: Cannot setup transports");
@@ -1841,7 +1846,8 @@ static int serial_function_bind_config(struct android_usb_function *f,
			goto err_gser_usb_get_function;
		}
	}
	config->instances_on = ports;

	serial_initialized = 1;

bind_config:
	for (i = 0; i < ports; i++) {