[PATCH 1/2] console: add is_ready callbback support

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Wed Nov 20 07:39:11 EST 2013


Some console such as net console need some parameter to work (IP & Port).
So we can not enable them if not present.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 common/console.c  | 3 +++
 include/console.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/common/console.c b/common/console.c
index 56bc864..32c5d38 100644
--- a/common/console.c
+++ b/common/console.c
@@ -62,6 +62,9 @@ static int console_std_set(struct device_d *dev, struct param_d *param,
 	char active[4];
 	unsigned int flag = 0, i = 0;
 
+	if (cdev->is_ready && !cdev->is_ready(cdev))
+		return -EIO;
+
 	if (val) {
 		if (strchr(val, 'i') && cdev->getc) {
 			active[i++] = 'i';
diff --git a/include/console.h b/include/console.h
index 550b440..b4caf55 100644
--- a/include/console.h
+++ b/include/console.h
@@ -37,6 +37,7 @@ struct console_device {
 	struct device_d *dev;
 	struct device_d class_dev;
 
+	int (*is_ready)(struct console_device *cdev);
 	int (*tstc)(struct console_device *cdev);
 	void (*putc)(struct console_device *cdev, char c);
 	int  (*getc)(struct console_device *cdev);
-- 
1.8.4.3




More information about the barebox mailing list