From 255a55106292891caead93c1e4b87beee18ca8f7 Mon Sep 17 00:00:00 2001 From: Anton Staaf Date: Wed, 20 Jan 2016 14:48:28 -0800 Subject: [PATCH] GPIO: Use gpio_reset in a few more places The new gpio_reset function simplifies the pattern used in this code, that of returning a GPIO to its original configured state. It also removes a few instances of using port/mask pairs. Signed-off-by: Anton Staaf BRANCH=None BUG=None TEST=make buildall -j Change-Id: I6e411aaf2f0fbc18aca0ed8742c400a0efe5690d Reviewed-on: https://chromium-review.googlesource.com/324059 Commit-Ready: Anton Staaf Tested-by: Anton Staaf Reviewed-by: Shawn N --- chip/mec1322/system.c | 11 ++++------- chip/npcx/system.c | 16 +++------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c index 967d8eb03b..fd38321d39 100644 --- a/chip/mec1322/system.c +++ b/chip/mec1322/system.c @@ -270,13 +270,10 @@ void system_hibernate(uint32_t seconds, uint32_t microseconds) if (hibernate_wake_pins_used > 0) { for (i = 0; i < hibernate_wake_pins_used; ++i) { - const enum gpio_signal *pin = &hibernate_wake_pins[i]; - gpio_set_flags_by_mask(gpio_list[*pin].port, - gpio_list[*pin].mask, - gpio_list[*pin].flags); - gpio_set_alternate_function(gpio_list[*pin].port, - gpio_list[*pin].mask, -1); - gpio_enable_interrupt(*pin); + const enum gpio_signal pin = hibernate_wake_pins[i]; + + gpio_reset(pin); + gpio_enable_interrupt(pin); } interrupt_enable(); diff --git a/chip/npcx/system.c b/chip/npcx/system.c index dd44fce62d..8123b9afcc 100644 --- a/chip/npcx/system.c +++ b/chip/npcx/system.c @@ -324,18 +324,8 @@ void system_set_gpios_and_wakeup_inputs_hibernate(void) gpio_set_flags_by_mask(0x0, 0xF0, GPIO_INPUT | GPIO_PULL_UP); /* Enable wake-up inputs of hibernate_wake_pins array */ - if (hibernate_wake_pins_used > 0) { - for (i = 0; i < hibernate_wake_pins_used; i++) { - const enum gpio_signal *pin = &hibernate_wake_pins[i]; - /* Make sure switch to GPIOs */ - gpio_set_alternate_function(gpio_list[*pin].port, - gpio_list[*pin].mask, -1); - /* Set wake-up settings for GPIOs */ - gpio_set_flags_by_mask(gpio_list[*pin].port, - gpio_list[*pin].mask, - gpio_list[*pin].flags); - } - } + for (i = 0; i < hibernate_wake_pins_used; i++) + gpio_reset(hibernate_wake_pins[i]); #ifdef CONFIG_USB_PD_PORT_COUNT /* @@ -354,7 +344,7 @@ void system_set_gpios_and_wakeup_inputs_hibernate(void) /* board-level function to set GPIOs state in hibernate */ if (board_set_gpio_hibernate_state) - return board_set_gpio_hibernate_state(); + board_set_gpio_hibernate_state(); } /**