test/flash: Use signal enum instead of string name

Previously the flash test used the GPIO string name to identify the
write protect GPIO.  Change to use the GPIO signal enum.  This is faster
and removes a use of gpio_list.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j

Change-Id: I4203c33cfa6d2b25d73d886b5248857a0c271565
Reviewed-on: https://chromium-review.googlesource.com/321913
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Anton Staaf
2016-01-13 10:28:42 -08:00
committed by chrome-bot
parent cdaf11549f
commit 63eccdb090

View File

@@ -52,15 +52,16 @@ int flash_pre_op(void)
int gpio_get_level(enum gpio_signal signal)
{
const char *name = gpio_list[signal].name;
if (mock_wp == -1)
mock_wp = !!(test_get_state() & BOOT_WP_MASK);
if (strcasecmp(name, "WP_L") == 0)
return !mock_wp;
if (strcasecmp(name, "WP") == 0)
#if defined(CONFIG_WP_ACTIVE_HIGH)
if (signal == GPIO_WP)
return mock_wp;
#else
if (signal == GPIO_WP_L)
return !mock_wp;
#endif
/* Signal other than write protect. Just return 0. */
return 0;