video: Add a way to write a partial string to the console
When writing multiple lines of text we need to be able to control which
text goes on each line. Add a new vidconsole_put_stringn() function to
help with this.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 3259bd2..fa329bd 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -508,12 +508,14 @@
return 0;
}
-int vidconsole_put_string(struct udevice *dev, const char *str)
+int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen)
{
- const char *s;
+ const char *s, *end = NULL;
int ret;
- for (s = str; *s; s++) {
+ if (maxlen != -1)
+ end = str + maxlen;
+ for (s = str; *s && (maxlen == -1 || s < end); s++) {
ret = vidconsole_put_char(dev, *s);
if (ret)
return ret;
@@ -522,6 +524,11 @@
return 0;
}
+int vidconsole_put_string(struct udevice *dev, const char *str)
+{
+ return vidconsole_put_stringn(dev, str, -1);
+}
+
static void vidconsole_putc(struct stdio_dev *sdev, const char ch)
{
struct udevice *dev = sdev->priv;