We already add registered console to global console_list, so there isn't really a need to have a global console pointer. Now, with majority of references to console pointer gone, we can easily ditch it and use console_list directly instead. Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx> --- common/console_simple.c | 5 +---- lib/console.c | 7 +++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/common/console_simple.c b/common/console_simple.c index ac22a2592..91b6cb6cd 100644 --- a/common/console_simple.c +++ b/common/console_simple.c @@ -5,14 +5,11 @@ #include <debug_ll.h> #include <console.h> -extern struct console_device *console; - int console_register(struct console_device *newcdev) { - if (console) + if (!list_empty(&console_list)) return -EBUSY; - console = newcdev; console_list.prev = console_list.next = &newcdev->list; newcdev->list.prev = newcdev->list.next = &console_list; diff --git a/lib/console.c b/lib/console.c index b8d6456c9..03563c9de 100644 --- a/lib/console.c +++ b/lib/console.c @@ -28,8 +28,7 @@ __data struct console_device console_ll = { .putc = NULL, .ctx = NULL, }; -__data struct console_device *console; -LIST_HEAD(console_list); +__data LIST_HEAD(console_list); EXPORT_SYMBOL(console_list); /** @@ -73,10 +72,10 @@ struct console_device *__console_get_default(void) if (unlikely(!console_ll.putc)) console_ll.putc = __console_ll_putc; - if (IS_ENABLED(__PBL__) || !console) + if (IS_ENABLED(__PBL__) || list_empty(&console_list)) return &console_ll; - return console; + return list_first_entry(&console_list, struct console_device, list); } /** -- 2.17.0 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox