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

Commit f328227d authored by Manu Gautam's avatar Manu Gautam
Browse files

USB: android: Ensure at least two serial ports are initialized



Driver allows serial ports and transports initialization only once
during bootup. Hence, any attempt by user to switch to a composition
having more number of serial ports fails. As compositions with two
serial ports (with second one using TTY) are pretty common, make
sure there are at least two serials ports initialized to allow this.
And mark 2nd port to use TTY if user didn't specify the transport
explicitly.

CRs-fixed: 1012067
Change-Id: Ic1fe0044e2a54ab3243ae1f151c063d91de422d5
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent ec82f6fd
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -1886,6 +1886,19 @@ static int serial_function_bind_config(struct android_usb_function *f,
			}
		}
	}
	/*
	 * Make sure we always have two serials ports initialized to allow
	 * switching composition from 1 serial function to 2 serial functions.
	 * Mark 2nd port to use tty if user didn't specify transport.
	 */
	if ((config->instances_on == 1) && !serial_initialized) {
		err = gserial_init_port(ports, "tty", "serial_tty");
		if (err) {
			pr_err("serial: Cannot open port '%s'", "tty");
			goto out;
		}
		config->instances_on++;
	}

	/* limit the serial ports init only for boot ports */
	if (ports > config->instances_on)
@@ -1900,8 +1913,7 @@ static int serial_function_bind_config(struct android_usb_function *f,
		goto out;
	}

	config->instances_on = ports;
	for (i = 0; i < ports; i++) {
	for (i = 0; i < config->instances_on; i++) {
		config->f_serial_inst[i] = usb_get_function_instance("gser");
		if (IS_ERR(config->f_serial_inst[i])) {
			err = PTR_ERR(config->f_serial_inst[i]);