[PATCH v3 09/11] setexpr: Promote 'setexpr_get_arg()' to a public function
lukas.funke-oss at weidmueller.com
lukas.funke-oss at weidmueller.com
Wed Jan 10 10:10:35 CET 2024
From: Lukas Funke <lukas.funke at weidmueller.com>
Promote 'setexpr_get_arg()' to a public function in order to use it
from the setexpr command and in the printf-internals.
Signed-off-by: Lukas Funke <lukas.funke at weidmueller.com>
---
(no changes since v1)
cmd/setexpr.c | 15 +--------------
include/command.h | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/cmd/setexpr.c b/cmd/setexpr.c
index bc57d41448..9caa68d20d 100644
--- a/cmd/setexpr.c
+++ b/cmd/setexpr.c
@@ -21,20 +21,7 @@
#define MAX_STR_LEN 128
-/**
- * struct expr_arg: Holds an argument to an expression
- *
- * @ival: Integer value (if width is not CMD_DATA_SIZE_STR)
- * @sval: String value (if width is CMD_DATA_SIZE_STR)
- */
-struct expr_arg {
- union {
- ulong ival;
- char *sval;
- };
-};
-
-static int setexpr_get_arg(char *s, int w, struct expr_arg *argp)
+int setexpr_get_arg(char *s, int w, struct expr_arg *argp)
{
struct expr_arg arg;
diff --git a/include/command.h b/include/command.h
index 4cec634545..d0aa98b1f6 100644
--- a/include/command.h
+++ b/include/command.h
@@ -248,6 +248,33 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc,
int setexpr_regex_sub(char *data, uint data_size, char *nbuf, uint nbuf_size,
const char *r, const char *s, bool global);
+/**
+ * struct expr_arg: Holds an argument to an expression
+ *
+ * @ival: Integer value (if width is not CMD_DATA_SIZE_STR)
+ * @sval: String value (if width is CMD_DATA_SIZE_STR)
+ * @bmap: Bitmap value (if width is > u64)
+ */
+struct expr_arg {
+ union {
+ ulong ival;
+ char *sval;
+ uchar *bmap;
+ };
+};
+
+/**
+ * setexpr_get_arg() - Converts a string argument to it's value. If argument
+ * starts with a '*' treat it as a pointer and dereference.
+ *
+ * @s: Argument string
+ * @w: Byte width of argument
+ * @argp: Pointer where the value should be stored
+ *
+ * Return: 0 on success, -EINVAL on failure
+ */
+int setexpr_get_arg(char *s, int w, struct expr_arg *argp);
+
/*
* Error codes that commands return to cmd_process(). We use the standard 0
* and 1 for success and failure, but add one more case - failure with a
--
2.30.2
More information about the U-Boot
mailing list