diff options
author | Bastian Stender <bst@pengutronix.de> | 2017-02-28 15:31:24 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-02-28 15:52:35 +0100 |
commit | 123357079882de948f5f42a15c1af21a26130af2 (patch) | |
tree | e139b36d21b05e749025ef5c2825cf96b272bbd0 /net | |
parent | 3cade5ec3a8a0bbf15c8495915961c9d718877be (diff) | |
download | barebox-123357079882de948f5f42a15c1af21a26130af2.tar.gz barebox-123357079882de948f5f42a15c1af21a26130af2.tar.xz |
console: replace set_active by open/close
Opening and closing consoles should be independent from setting them
active. This way it is possible to open e.g. a framebuffer console and
display text on it without showing stdout/stderr.
Signed-off-by: Bastian Stender <bst@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/netconsole.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/net/netconsole.c b/net/netconsole.c index ce3c418798..ef8b1856b6 100644 --- a/net/netconsole.c +++ b/net/netconsole.c @@ -105,19 +105,11 @@ static void nc_putc(struct console_device *cdev, char c) priv->busy = 0; } -static int nc_set_active(struct console_device *cdev, unsigned flags) +static int nc_open(struct console_device *cdev) { struct nc_priv *priv = container_of(cdev, struct nc_priv, cdev); - if (priv->con) { - net_unregister(priv->con); - priv->con = NULL; - } - - if (!flags) - return 0; - if (!priv->port) { pr_err("port not set\n"); return -EINVAL; @@ -142,6 +134,20 @@ static int nc_set_active(struct console_device *cdev, unsigned flags) return 0; } +static int nc_close(struct console_device *cdev) +{ + struct nc_priv *priv = container_of(cdev, + struct nc_priv, cdev); + + if (priv->con) { + net_unregister(priv->con); + priv->con = NULL; + return 0; + } + + return -EINVAL; +} + static int netconsole_init(void) { struct nc_priv *priv; @@ -155,7 +161,8 @@ static int netconsole_init(void) cdev->getc = nc_getc; cdev->devname = "netconsole"; cdev->devid = DEVICE_ID_SINGLE; - cdev->set_active = nc_set_active; + cdev->open = nc_open; + cdev->close = nc_close; g_priv = priv; |