diff mbox series

[U-Boot] video: Factor out vidconsole_put_string()

Message ID 20190517182231.32535-1-marex@denx.de
State Accepted
Delegated to: Anatolij Gustschin
Headers show
Series [U-Boot] video: Factor out vidconsole_put_string() | expand

Commit Message

Marek Vasut May 17, 2019, 6:22 p.m. UTC
Pull the vidconsole_put_string() function from DM tests, make it
available to e.g. boards that want to display information on the
LCD on boot.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Anatolij Gustschin <agust@denx.de>
---
 drivers/video/vidconsole-uclass.c | 17 +++++++++++++++--
 include/video_console.h           | 16 ++++++++++++++++
 test/dm/video.c                   |  8 --------
 3 files changed, 31 insertions(+), 10 deletions(-)

Comments

Anatolij Gustschin May 17, 2019, 7:30 p.m. UTC | #1
On Fri, 17 May 2019 20:22:31 +0200
Marek Vasut marex@denx.de wrote:

> Pull the vidconsole_put_string() function from DM tests, make it
> available to e.g. boards that want to display information on the
> LCD on boot.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Anatolij Gustschin <agust@denx.de>

Reviewed-by: Anatolij Gustschin <agust@denx.de>

--
Anatolij
Anatolij Gustschin May 20, 2019, 11:12 a.m. UTC | #2
On Fri, 17 May 2019 20:22:31 +0200
Marek Vasut marex@denx.de wrote:

> Pull the vidconsole_put_string() function from DM tests, make it
> available to e.g. boards that want to display information on the
> LCD on boot.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Anatolij Gustschin <agust@denx.de>
> ---
>  drivers/video/vidconsole-uclass.c | 17 +++++++++++++++--
>  include/video_console.h           | 16 ++++++++++++++++
>  test/dm/video.c                   |  8 --------
>  3 files changed, 31 insertions(+), 10 deletions(-)

Applied to u-boot-video/master, thanks!

--
Anatolij
diff mbox series

Patch

diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index c31303b56e..af88588904 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -529,6 +529,20 @@  int vidconsole_put_char(struct udevice *dev, char ch)
 	return 0;
 }
 
+int vidconsole_put_string(struct udevice *dev, const char *str)
+{
+	const char *s;
+	int ret;
+
+	for (s = str; *s; s++) {
+		ret = vidconsole_put_char(dev, *s);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 static void vidconsole_putc(struct stdio_dev *sdev, const char ch)
 {
 	struct udevice *dev = sdev->priv;
@@ -541,8 +555,7 @@  static void vidconsole_puts(struct stdio_dev *sdev, const char *s)
 {
 	struct udevice *dev = sdev->priv;
 
-	while (*s)
-		vidconsole_put_char(dev, *s++);
+	vidconsole_put_string(dev, s);
 	video_sync(dev->parent, false);
 }
 
diff --git a/include/video_console.h b/include/video_console.h
index 52a41ac200..0936ceaaf1 100644
--- a/include/video_console.h
+++ b/include/video_console.h
@@ -214,6 +214,22 @@  int vidconsole_set_row(struct udevice *dev, uint row, int clr);
  */
 int vidconsole_put_char(struct udevice *dev, char ch);
 
+/**
+ * vidconsole_put_string() - Output a string to the current console position
+ *
+ * Outputs a string to the console and advances the cursor. This function
+ * handles wrapping to new lines and scrolling the console. Special
+ * characters are handled also: \n, \r, \b and \t.
+ *
+ * The device always starts with the cursor at position 0,0 (top left). It
+ * can be adjusted manually using vidconsole_position_cursor().
+ *
+ * @dev:	Device to adjust
+ * @str:	String to write
+ * @return 0 if OK, -ve on error
+ */
+int vidconsole_put_string(struct udevice *dev, const char *str);
+
 /**
  * vidconsole_position_cursor() - Move the text cursor
  *
diff --git a/test/dm/video.c b/test/dm/video.c
index 6be5defc53..3151ebb73f 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -97,14 +97,6 @@  static int select_vidconsole(struct unit_test_state *uts, const char *drv_name)
 	return 0;
 }
 
-static void vidconsole_put_string(struct udevice *dev, const char *str)
-{
-	const char *s;
-
-	for (s = str; *s; s++)
-		vidconsole_put_char(dev, *s);
-}
-
 /* Test text output works on the video console */
 static int dm_test_video_text(struct unit_test_state *uts)
 {