From 1f7ab338b10d65ddaf05d1b4650270d10580a932 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Fri, 17 Jul 2015 10:57:54 -0700 Subject: cleanup: GPIO: Use common macro for converting mask to GPIO The same calculation is used across the code, so move it to a common macro. BUG=chrome-os-partner:42104 TEST=Verify Glados still boots AP. BRANCH=None Change-Id: I90da348f37fc670971737cfc5ddcfb9c34096c4b Signed-off-by: Shawn Nematbakhsh Reviewed-on: https://chromium-review.googlesource.com/286169 Reviewed-by: Alec Berg --- include/gpio.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/gpio.h') diff --git a/include/gpio.h b/include/gpio.h index 8734ea88e8..1374e85981 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -46,6 +46,9 @@ #define GPIO_INT_ANY (GPIO_INT_BOTH | GPIO_INT_LEVEL) #define GPIO_INT_BOTH_DSLEEP (GPIO_INT_BOTH | GPIO_INT_DSLEEP) +/* Convert GPIO mask to GPIO number / index. */ +#define GPIO_MASK_TO_NUM(mask) (31 - __builtin_clz(mask)) + /* NOTE: This is normally included from board.h, thru config.h and common.h But, * some boards and unit tests don't have a gpio_signal enum defined, so we * define an emtpy one here.*/ -- cgit v1.2.1