From eff7a1910a60b1d30b10257fd4a12b5ed1402594 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Tue, 10 Sep 2013 17:55:02 +0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/168739 Reviewed-by: Vincent Palatin Reviewed-by: Randall Spangler Tested-by: Randall Spangler --- common/util.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common/util.c') 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 */ -- cgit v1.2.1