summaryrefslogtreecommitdiff
path: root/common/console.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-12-21 15:30:00 +0300
committerTom Rini <trini@konsulko.com>2021-01-15 22:36:12 +0300
commit41f668b97c7ac8d519f15961b67fc52817115701 (patch)
treeec6896b66a95dd99a15810beeb404e69704b616d /common/console.c
parenta17b38ce3902e46777322f6ec26e51b25415fa5b (diff)
downloadu-boot-41f668b97c7ac8d519f15961b67fc52817115701.tar.xz
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/common/console.c b/common/console.c
index e82b5d2075..5b113da9d5 100644
--- a/common/console.c
+++ b/common/console.c
@@ -172,13 +172,9 @@ static int console_setfile(int file, struct stdio_dev * dev)
case stdin:
case stdout:
case stderr:
- /* Start new device */
- if (dev->start) {
- error = dev->start(dev);
- /* If it's not started dont use it */
- if (error < 0)
- break;
- }
+ error = console_start(file, dev);
+ if (error)
+ break;
/* Assign the new device (leaving the existing one started) */
stdio_devices[file] = dev;
@@ -389,6 +385,26 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
#endif
#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 *************************/
int serial_printf(const char *fmt, ...)