mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* console fixes
@ 2012-04-13 14:57 Sascha Hauer
  2012-04-13 14:57 ` [PATCH 1/2] console simple: return with a proper error value Sascha Hauer
  2012-04-13 14:57 ` [PATCH 2/2] netconsole: bail out if console_register fails Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-04-13 14:57 UTC (permalink / raw)
  To: barebox

Two small fixes for netconsole and simple console.

----------------------------------------------------------------
Sascha Hauer (2):
      console simple: return with a proper error value
      netconsole: bail out if console_register fails

 common/console_simple.c |   14 ++++++++------
 net/netconsole.c        |    8 +++++++-
 2 files changed, 15 insertions(+), 7 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] console simple: return with a proper error value
  2012-04-13 14:57 console fixes Sascha Hauer
@ 2012-04-13 14:57 ` Sascha Hauer
  2012-04-13 14:57 ` [PATCH 2/2] netconsole: bail out if console_register fails Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-04-13 14:57 UTC (permalink / raw)
  To: barebox

There can be only one console for console_simple, so
return with -EBUSY when the second gets registered.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/console_simple.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/common/console_simple.c b/common/console_simple.c
index 49c5b33..7ad88d9 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -155,13 +155,15 @@ EXPORT_SYMBOL(ctrlc);
 
 int console_register(struct console_device *newcdev)
 {
-	if (!console) {
-		console = newcdev;
-		console_list.prev = console_list.next = &newcdev->list;
-		newcdev->list.prev = newcdev->list.next = &console_list;
+	if (console)
+		return -EBUSY;
+
+	console = newcdev;
+	console_list.prev = console_list.next = &newcdev->list;
+	newcdev->list.prev = newcdev->list.next = &console_list;
+
+	barebox_banner();
 
-		barebox_banner();
-	}
 	return 0;
 }
 
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] netconsole: bail out if console_register fails
  2012-04-13 14:57 console fixes Sascha Hauer
  2012-04-13 14:57 ` [PATCH 1/2] console simple: return with a proper error value Sascha Hauer
@ 2012-04-13 14:57 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-04-13 14:57 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 net/netconsole.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/netconsole.c b/net/netconsole.c
index 2ac3e64..48f2b98 100644
--- a/net/netconsole.c
+++ b/net/netconsole.c
@@ -174,6 +174,7 @@ static int netconsole_init(void)
 {
 	struct nc_priv *priv;
 	struct console_device *cdev;
+	int ret;
 
 	priv = xzalloc(sizeof(*priv));
 	cdev = &priv->cdev;
@@ -185,7 +186,12 @@ static int netconsole_init(void)
 
 	priv->fifo = kfifo_alloc(1024);
 
-	console_register(cdev);
+	ret = console_register(cdev);
+	if (ret) {
+		printf("netconsole: registering failed with %s\n", strerror(-ret));
+		kfree(priv);
+		return ret;
+	}
 
 	dev_add_param(&cdev->class_dev, "ip", nc_remoteip_set, NULL, 0);
 	dev_add_param(&cdev->class_dev, "port", nc_port_set, NULL, 0);
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-13 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-13 14:57 console fixes Sascha Hauer
2012-04-13 14:57 ` [PATCH 1/2] console simple: return with a proper error value Sascha Hauer
2012-04-13 14:57 ` [PATCH 2/2] netconsole: bail out if console_register fails Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox