console-server: introduce `struct console_server`
Lift `struct console_server` from `struct console`
struct console_server will enable obmc-console to support multiple
consoles in a single obmc-console-server in the future.
Currently the 'struct console_server' only supports one active console.
Change-Id: Icb22fb46f217b174f3bccc0a03485549d82d1d6b
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/console-dbus.c b/console-dbus.c
index d9b8689..220d3e0 100644
--- a/console-dbus.c
+++ b/console-dbus.c
@@ -37,7 +37,7 @@
int i;
int rc;
- tty_init_termios(console);
+ tty_init_termios(console->server);
for (i = 0; i < console->n_handlers; i++) {
const struct handler_type *type;
@@ -49,7 +49,7 @@
continue;
}
- rc = type->baudrate(handler, console->tty.uart.baud);
+ rc = type->baudrate(handler, console->server->tty.uart.baud);
if (rc) {
warnx("Can't set terminal baudrate for handler %s",
type->name);
@@ -82,8 +82,8 @@
return -EINVAL;
}
- assert(console->tty.type == TTY_DEVICE_UART);
- console->tty.uart.baud = speed;
+ assert(console->server->tty.type == TTY_DEVICE_UART);
+ console->server->tty.uart.baud = speed;
tty_change_baudrate(console);
sd_bus_emit_properties_changed(bus, path, interface, property, NULL);
@@ -99,13 +99,14 @@
sd_bus_error *error __attribute__((unused)))
{
struct console *console = userdata;
+ struct console_server *server = console->server;
uint64_t baudrate;
int r;
- assert(console->tty.type == TTY_DEVICE_UART);
- baudrate = parse_baud_to_int(console->tty.uart.baud);
+ assert(server->tty.type == TTY_DEVICE_UART);
+ baudrate = parse_baud_to_int(server->tty.uart.baud);
if (!baudrate) {
- warnx("Invalid baud rate: '%d'", console->tty.uart.baud);
+ warnx("Invalid baud rate: '%d'", server->tty.uart.baud);
}
r = sd_bus_message_append(reply, "t", baudrate);
@@ -190,7 +191,7 @@
return -1;
}
- if (console->tty.type == TTY_DEVICE_UART) {
+ if (console->server->tty.type == TTY_DEVICE_UART) {
/* Register UART interface */
r = sd_bus_add_object_vtable(console->bus, NULL, obj_name,
UART_INTF, console_uart_vtable,