usb: gadget: u_serial: allow more console gadget ports
Allow configuring more than one console using USB serial or ACM gadget. By default, only first (ttyGS0) is a console, but this may be changed using function's new "console" attribute. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:

committed by
Felipe Balbi

parent
b417343c6a
commit
d7cb8fb7aa
@@ -1081,6 +1081,54 @@ static void gs_console_exit(struct gs_port *port)
|
||||
port->console = NULL;
|
||||
}
|
||||
|
||||
ssize_t gserial_set_console(unsigned char port_num, const char *page, size_t count)
|
||||
{
|
||||
struct gs_port *port;
|
||||
bool enable;
|
||||
int ret;
|
||||
|
||||
ret = strtobool(page, &enable);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&ports[port_num].lock);
|
||||
port = ports[port_num].port;
|
||||
|
||||
if (WARN_ON(port == NULL)) {
|
||||
ret = -ENXIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (enable)
|
||||
ret = gs_console_init(port);
|
||||
else
|
||||
gs_console_exit(port);
|
||||
out:
|
||||
mutex_unlock(&ports[port_num].lock);
|
||||
|
||||
return ret < 0 ? ret : count;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gserial_set_console);
|
||||
|
||||
ssize_t gserial_get_console(unsigned char port_num, char *page)
|
||||
{
|
||||
struct gs_port *port;
|
||||
ssize_t ret;
|
||||
|
||||
mutex_lock(&ports[port_num].lock);
|
||||
port = ports[port_num].port;
|
||||
|
||||
if (WARN_ON(port == NULL))
|
||||
ret = -ENXIO;
|
||||
else
|
||||
ret = sprintf(page, "%u\n", !!port->console);
|
||||
|
||||
mutex_unlock(&ports[port_num].lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(gserial_get_console);
|
||||
|
||||
#else
|
||||
|
||||
static int gs_console_connect(struct gs_port *port)
|
||||
|
Reference in New Issue
Block a user