summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/util.c
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-10-14 13:58:40 -0600
committerCommit Bot <commit-bot@chromium.org>2020-10-21 21:24:14 +0000
commitb81af1233e23497ca8317f2669947398d0142e12 (patch)
treefb70584fedaa44810587cc11c888de7def9893dc /zephyr/shim/src/util.c
parent65d7595dfe16963f31fb057ca93ba2f7334ecb0a (diff)
downloadchrome-ec-b81af1233e23497ca8317f2669947398d0142e12.tar.gz
zephyr: add initial gpio shim
Add the gpioget and gpioset commands to zephyr build. This requires a minimum set of platform/ec gpio_ API functions. Add the minimum set of gpio_ functions. More can be added later depending on future uses BRANCH=none BUG=b:169935802 TEST=verify gpioget and gpioset console command work on volteer TEST=verify that posix-ec compiles without any named_gpios in DT Change-Id: Ie6f0b4505aa17c50c01b71fc4ea5b59393f39fce Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2488141 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/shim/src/util.c')
-rw-r--r--zephyr/shim/src/util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/zephyr/shim/src/util.c b/zephyr/shim/src/util.c
index 998a0db01d..6cd6e0dc68 100644
--- a/zephyr/shim/src/util.c
+++ b/zephyr/shim/src/util.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <stdlib.h>
+#include <ctype.h>
/* Int and Long are same size, just forward to existing Long implementation */
int strtoi(const char *nptr, char **endptr, int base)
@@ -12,3 +13,15 @@ int strtoi(const char *nptr, char **endptr, int base)
return strtol(nptr, endptr, base);
}
BUILD_ASSERT(sizeof(int) == sizeof(long));
+
+int strcasecmp(const char *s1, const char *s2)
+{
+ int diff;
+
+ do {
+ diff = tolower(*s1) - tolower(*s2);
+ if (diff)
+ return diff;
+ } while (*(s1++) && *(s2++));
+ return 0;
+}