From: Robert Jarzmik <robert.jarzmik@free.fr>
To: barebox@lists.infradead.org
Cc: Robert Jarzmik <robert.jarzmik@atosorigin.com>
Subject: [PATCH 1/5] console: add console unregistering
Date: Thu, 24 Nov 2011 04:01:26 +0100 [thread overview]
Message-ID: <1322103690-32669-2-git-send-email-robert.jarzmik@free.fr> (raw)
In-Reply-To: <1322103690-32669-1-git-send-email-robert.jarzmik@free.fr>
From: Robert Jarzmik <robert.jarzmik@atosorigin.com>
Some console are transient, like the USB connected serial
console which should be removed when the USB connection is
severed.
Enable console removal for such devices.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
common/console.c | 24 ++++++++++++++++++------
common/console_simple.c | 4 ++++
include/console.h | 1 +
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/common/console.c b/common/console.c
index 06e9c29..706d9b2 100644
--- a/common/console.c
+++ b/common/console.c
@@ -154,13 +154,9 @@ int console_register(struct console_device *newcdev)
list_add_tail(&newcdev->list, &console_list);
- if (console_output_buffer) {
- while (kfifo_getc(console_output_buffer, &ch) == 0)
- console_putc(CONSOLE_STDOUT, ch);
- kfifo_free(console_output_buffer);
- console_output_buffer = NULL;
- }
+ while (kfifo_getc(console_output_buffer, &ch) == 0)
+ console_putc(CONSOLE_STDOUT, ch);
if (first)
barebox_banner();
@@ -168,6 +164,22 @@ int console_register(struct console_device *newcdev)
}
EXPORT_SYMBOL(console_register);
+int console_unregister(struct console_device *cdev)
+{
+ struct device_d *dev = &cdev->class_dev;
+ int status;
+
+ list_del(&cdev->list);
+ if (list_empty(&console_list))
+ initialized = CONSOLE_UNINITIALIZED;
+
+ status = unregister_device(dev);
+ if (!status)
+ memset(cdev, 0, sizeof(*cdev));
+ return status;
+}
+EXPORT_SYMBOL(console_unregister);
+
static int getc_raw(void)
{
struct console_device *cdev;
diff --git a/common/console_simple.c b/common/console_simple.c
index 7304d8e..7e0619d 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -157,3 +157,7 @@ int console_register(struct console_device *newcdev)
}
return 0;
}
+
+int console_unregister(struct console_device *cdev)
+{
+}
diff --git a/include/console.h b/include/console.h
index 3bcc5db..c0817f6 100644
--- a/include/console.h
+++ b/include/console.h
@@ -49,6 +49,7 @@ struct console_device {
};
int console_register(struct console_device *cdev);
+int console_unregister(struct console_device *cdev);
extern struct list_head console_list;
#define for_each_console(console) list_for_each_entry(console, &console_list, list)
--
1.7.5.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-11-24 3:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-24 3:01 [PATCH 0/5] Enable a console over a serial USB gadget Robert Jarzmik
2011-11-24 3:01 ` Robert Jarzmik [this message]
2011-11-24 3:01 ` [PATCH 2/5] usb/gadget: add pxa27x_udc driver Robert Jarzmik
2011-11-24 3:01 ` [PATCH 3/5] usb/gadget: use generic usb_gadget_poll() in u_serial Robert Jarzmik
2011-11-24 3:01 ` [PATCH 4/5] usb/gadget: add USB serial connect and disconnect Robert Jarzmik
2011-11-24 3:01 ` [PATCH 5/5] usb/gadget: make serial gadget resistant to cable unplug Robert Jarzmik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322103690-32669-2-git-send-email-robert.jarzmik@free.fr \
--to=robert.jarzmik@free.fr \
--cc=barebox@lists.infradead.org \
--cc=robert.jarzmik@atosorigin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox