lib: sbi: Fix return of sbi_console_init
authorXiang W <wxjstz@126.com>
Mon, 22 May 2023 05:18:06 +0000 (13:18 +0800)
committerAnup Patel <anup@brainfault.org>
Fri, 26 May 2023 07:06:54 +0000 (12:36 +0530)
console is not a required peripheral. So it should return success when
the console does not exist.

Signed-off-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_console.c

index f3ac003..168dffd 100644 (file)
@@ -481,5 +481,11 @@ void sbi_console_set_device(const struct sbi_console_device *dev)
 
 int sbi_console_init(struct sbi_scratch *scratch)
 {
-       return sbi_platform_console_init(sbi_platform_ptr(scratch));
+       int rc = sbi_platform_console_init(sbi_platform_ptr(scratch));
+
+       /* console is not a necessary device */
+       if (rc == SBI_ENODEV)
+               return 0;
+
+       return rc;
 }