diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-09-30 14:53:01 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-10-02 06:09:59 +0200 |
commit | 09cbc3fbdab5f3118062ceeefb0c1b043a75b3fb (patch) | |
tree | 8a1191179d41869146e25b03ec00ee0e4d2d36d2 /lib | |
parent | f91786df4b06af94a2bc59a8290e84668aa49358 (diff) | |
download | barebox-09cbc3fbdab5f3118062ceeefb0c1b043a75b3fb.tar.gz barebox-09cbc3fbdab5f3118062ceeefb0c1b043a75b3fb.tar.xz |
of: implement of_property_write_strings for multiple strings
The current way to set a property with multiple values (e.g. compatible
strings) is to have
char properties[] = "st,stm32mp157c-dk2\0st,stm32mp157";
of_set_property(np, "compatible", properties, sizeof(properties), 1);
Add a new helper to make this easier at the cost of one runtime
reallocation:
of_property_write_strings(np, "compatible,
"st,stm32mp157c-dk2", "st,stm32mp157", NULL);
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/string.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index 003070fa53..d250e58643 100644 --- a/lib/string.c +++ b/lib/string.c @@ -100,6 +100,19 @@ char * strcpy(char * dest,const char *src) #endif EXPORT_SYMBOL(strcpy); +/** + * stpcpy - Copy a %NUL terminated string, but return pointer to %NUL + * @dest: Where to copy the string to + * @src: Where to copy the string from + */ +char *stpcpy(char *dest, const char *src) +{ + while ((*dest++ = *src++) != '\0') + /* nothing */; + return dest - 1; +} +EXPORT_SYMBOL(stpcpy); + #ifndef __HAVE_ARCH_STRNCPY /** * strncpy - Copy a length-limited, %NUL-terminated string |