summaryrefslogtreecommitdiff
path: root/board/kirby
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-10-07 13:20:58 -0700
committerBill Richardson <wfrichar@chromium.org>2013-10-10 15:16:06 +0000
commit2fb228c198d2581df4c90bd94f0240737a9db134 (patch)
tree1a64ab9e540c98e814fc8ad3019df204471ec6bf /board/kirby
parentff8c8fee79e148567c0f2128db69563acb29ee54 (diff)
downloadchrome-ec-2fb228c198d2581df4c90bd94f0240737a9db134.tar.gz
cleanup: Don't use [N] = {} when initializing arrays
If we do this: enum foo_v { FOO_A, FOO_B, FOO_COUNT }; struct foo_t foo[] = { {...}, {...}, }; BUILD_ASSERT(ARRAY_SIZE(foo) == FOO_COUNT); Then we can be sure we're at least initialized all the elements of foo, although there's no particular guarantee that the order is correct. However, if we use this: struct foo_t foo[] = { [FOO_A] = {...}, [FOO_B] = {...}, }; and we accidentally get one wrong: struct foo_t foo[] = { [FOO_B] = {...}, [FOO_B] = {...}, }; Then the assertion still passes, but we've only initialized one element. Don't do that. BUG=chrome-os-partner:18343 BRANCH=none TEST=manual Refactoring only. Build everything. It should still work. Change-Id: I58f659207990f18c6fb74b1cac2ec1163cdb07ea Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/172115 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'board/kirby')
-rw-r--r--board/kirby/board.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/board/kirby/board.c b/board/kirby/board.c
index 4cac7b6d9f..ca88e1416f 100644
--- a/board/kirby/board.c
+++ b/board/kirby/board.c
@@ -106,13 +106,13 @@ const struct gpio_alt_func gpio_alt_funcs[] = {
};
const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs);
-/* PWM channels */
+/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
- [PWM_CH_CHG_Y] = {STM32_TIM(3), STM32_TIM_CH(1), PWM_CONFIG_ACTIVE_LOW,
+ {STM32_TIM(3), STM32_TIM_CH(1), PWM_CONFIG_ACTIVE_LOW,
GPIO_CHG_LED_Y},
- [PWM_CH_CHG_G] = {STM32_TIM(3), STM32_TIM_CH(2), PWM_CONFIG_ACTIVE_LOW,
+ {STM32_TIM(3), STM32_TIM_CH(2), PWM_CONFIG_ACTIVE_LOW,
GPIO_CHG_LED_G},
- [PWM_CH_CHG_R] = {STM32_TIM(3), STM32_TIM_CH(3), PWM_CONFIG_ACTIVE_LOW,
+ {STM32_TIM(3), STM32_TIM_CH(3), PWM_CONFIG_ACTIVE_LOW,
GPIO_CHG_LED_R},
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);