[Concept,06/14] ulib: Add a way to obtain the version

Message ID 20250911214425.3687188-7-sjg@u-boot.org
State New
Headers
Series ulib: Add support for Rust main programs |

Commit Message

Simon Glass Sept. 11, 2025, 9:44 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

It is possible to simply read the 'version_string' variable, but it
seems better to add a proper API call to get this. It is already
defined in lib/ulib/ulib.c

Add a prototype to u-boot-lib.h

Make use of it from the demo program.

Fix the comment for ulib_uninit() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 examples/ulib/demo.c | 2 +-
 include/u-boot-lib.h | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
  

Patch

diff --git a/examples/ulib/demo.c b/examples/ulib/demo.c
index 9d916d3878a..5077fcda0a6 100644
--- a/examples/ulib/demo.c
+++ b/examples/ulib/demo.c
@@ -31,7 +31,7 @@  int main(int argc, char *argv[])
 	}
 
 	demo_show_banner();
-	printf("U-Boot version: %s\n", version_string);
+	printf("U-Boot version: %s\n", ulib_get_version());
 	printf("\n");
 
 	/* Use U-Boot's os_open to open a file */
diff --git a/include/u-boot-lib.h b/include/u-boot-lib.h
index aabc77aa4eb..934cc33eff5 100644
--- a/include/u-boot-lib.h
+++ b/include/u-boot-lib.h
@@ -25,10 +25,17 @@  struct global_data;
 int ulib_init(char *progname);
 
 /**
- * ulib_uninit() shut down the U-Boot librrary
+ * ulib_uninit() - shut down the U-Boot library
  *
  * Call this when your program has finished using the library, before it exits
  */
 void ulib_uninit(void);
 
+/**
+ * ulib_get_version() - Get the version string
+ *
+ * Return: Full U-Boot version string
+ */
+const char *ulib_get_version(void);
+
 #endif