提交 41f668b9 编写于 作者: A Andy Shevchenko 提交者: Tom Rini

console: Introduce console_start() and console_stop()

In the future we would like to stop unused consoles and
also add a reference counting to avoid imbalanced calls
to ->start() and ->stop() in some cases.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: NSimon Glass <sjg@chromium.org>
上级 a17b38ce
...@@ -172,13 +172,9 @@ static int console_setfile(int file, struct stdio_dev * dev) ...@@ -172,13 +172,9 @@ static int console_setfile(int file, struct stdio_dev * dev)
case stdin: case stdin:
case stdout: case stdout:
case stderr: case stderr:
/* Start new device */ error = console_start(file, dev);
if (dev->start) { if (error)
error = dev->start(dev); break;
/* If it's not started dont use it */
if (error < 0)
break;
}
/* Assign the new device (leaving the existing one started) */ /* Assign the new device (leaving the existing one started) */
stdio_devices[file] = dev; stdio_devices[file] = dev;
...@@ -389,6 +385,26 @@ static inline void console_doenv(int file, struct stdio_dev *dev) ...@@ -389,6 +385,26 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
#endif #endif
#endif /* CONIFIG_IS_ENABLED(CONSOLE_MUX) */ #endif /* CONIFIG_IS_ENABLED(CONSOLE_MUX) */
int console_start(int file, struct stdio_dev *sdev)
{
int error;
/* Start new device */
if (sdev->start) {
error = sdev->start(sdev);
/* If it's not started don't use it */
if (error < 0)
return error;
}
return 0;
}
void console_stop(int file, struct stdio_dev *sdev)
{
if (sdev->stop)
sdev->stop(sdev);
}
/** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/ /** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/
int serial_printf(const char *fmt, ...) int serial_printf(const char *fmt, ...)
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#define __CONSOLE_H #define __CONSOLE_H
#include <stdbool.h> #include <stdbool.h>
#include <stdio_dev.h>
#include <linux/errno.h> #include <linux/errno.h>
extern char console_buffer[]; extern char console_buffer[];
...@@ -15,6 +16,8 @@ extern char console_buffer[]; ...@@ -15,6 +16,8 @@ extern char console_buffer[];
/* common/console.c */ /* common/console.c */
int console_init_f(void); /* Before relocation; uses the serial stuff */ int console_init_f(void); /* Before relocation; uses the serial stuff */
int console_init_r(void); /* After relocation; uses the console stuff */ int console_init_r(void); /* After relocation; uses the console stuff */
int console_start(int file, struct stdio_dev *sdev); /* Start a console device */
void console_stop(int file, struct stdio_dev *sdev); /* Stop a console device */
int console_assign(int file, const char *devname); /* Assign the console */ int console_assign(int file, const char *devname); /* Assign the console */
int ctrlc(void); int ctrlc(void);
int had_ctrlc(void); /* have we had a Control-C since last clear? */ int had_ctrlc(void); /* have we had a Control-C since last clear? */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册