summaryrefslogtreecommitdiff
path: root/common/util.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-09-10 17:55:02 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-11 19:45:38 +0000
commiteff7a1910a60b1d30b10257fd4a12b5ed1402594 (patch)
treed604e3ec704575a5bdbedc7f172ed062586cdf12 /common/util.c
parent876d4c0031ce0d277f23eb08760c83b854038064 (diff)
downloadchrome-ec-eff7a1910a60b1d30b10257fd4a12b5ed1402594.tar.gz
Support multi-bit mask in STM32L's GPIO functions
The definition of GPIO interface allows passing in multi-bit mask, and this is what's done by gpio_config_module(). Fix STM32L's function so that it doesn't accidentally set incorrect GPIO register values. BUG=chrome-os-partner:22605 TEST=On Kirby, do 'led r 0' and check the value of 0x40020800 is 0x01540000. BRANCH=None Change-Id: I9a1c8074aab7345485a590ecf138bf99d0742997 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168739 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/util.c')
-rw-r--r--common/util.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c
index 0d7bff2710..f120cdad24 100644
--- a/common/util.c
+++ b/common/util.c
@@ -273,6 +273,13 @@ int uint64divmod(uint64_t *n, int d)
return r;
}
+int get_next_bit(uint32_t *mask)
+{
+ int bit = 31 - __builtin_clz(*mask);
+ *mask &= ~(1 << bit);
+ return bit;
+}
+
/****************************************************************************/
/* stateful conditional stuff */