summaryrefslogtreecommitdiff
path: root/board/bds/board.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-07-30 17:26:20 -0700
committerChromeBot <chrome-bot@google.com>2013-07-31 12:33:31 -0700
commitaf777297370e971bd4ae64e0e947cb5a1774dbfe (patch)
tree282a090d2431626ce01e4940c4a4ca722d70166e /board/bds/board.c
parentf6799258c3842ef855bf1516066464431b1b1a7d (diff)
downloadchrome-ec-af777297370e971bd4ae64e0e947cb5a1774dbfe.tar.gz
Add build-time checks on board-specific array sizes.
We've been declaring a bunch of statically-sized arrays: extern struct foo_t foo[FOO_COUNT]; And then initializing them like so: struct foo_t foo[FOO_COUNT] = { /* blah */ }; That only catches cases where we initialize with too many entries. It doesn't catch cases where we haven't initialized enough. This change tests for both cases like so: extern struct foo_t foo[]; struct foo_t foo[] = { /* blah */ }; BUILD_ASSERT(ARRAY_SIZE(foo) == FOO_COUNT); The affected arrays are: adc_channels[ADC_CH_COUNT] gpio_list[GPIO_COUNT] temp_sensors[TEMP_SENSOR_COUNT] x86_signal_list[X86_SIGNAL_COUNT] i2c_ports[I2C_PORTS_USED] BUG=chrome-os-partner:18343 BRANCH=falco,peppy TEST=build all platforms All platforms should still build, all tests should still pass. Change-Id: Ibb16dc3201f32df7cdc875648e89ba4ffb09f733 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/63833 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'board/bds/board.c')
-rw-r--r--board/bds/board.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/board/bds/board.c b/board/bds/board.c
index 2794ff06db..830b8fcf41 100644
--- a/board/bds/board.c
+++ b/board/bds/board.c
@@ -12,7 +12,7 @@
#include "util.h"
/* ADC channels. Must be in the exactly same order as in enum adc_channel. */
-const struct adc_t adc_channels[ADC_CH_COUNT] = {
+const struct adc_t adc_channels[] = {
/* EC internal temperature is calculated by
* 273 + (295 - 450 * ADC_VALUE / ADC_READ_MAX) / 2
* = -225 * ADC_VALUE / ADC_READ_MAX + 420.5
@@ -29,19 +29,22 @@ const struct adc_t adc_channels[ADC_CH_COUNT] = {
{"BDSPot", LM4_ADC_SEQ1, 33 * 4000, ADC_READ_MAX * 16, 0,
LM4_AIN(0), 0x06 /* IE0 | END0 */, LM4_GPIO_E, (1<<3)},
};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
/* I2C ports */
-const struct i2c_port_t i2c_ports[I2C_PORTS_USED] = {
+const struct i2c_port_t i2c_ports[] = {
{"lightbar", I2C_PORT_LIGHTBAR, 400},
};
+BUILD_ASSERT(ARRAY_SIZE(i2c_ports) == I2C_PORTS_USED);
/* GPIO signal list. Must match order from enum gpio_signal. */
-const struct gpio_info gpio_list[GPIO_COUNT] = {
+const struct gpio_info gpio_list[] = {
{"RECOVERYn", LM4_GPIO_D, (1<<1), GPIO_PULL_UP, NULL},
{"DEBUG_LED", LM4_GPIO_A, (1<<7), GPIO_OUT_LOW, NULL},
/* Unimplemented signals which we need to emulate for now */
GPIO_SIGNAL_NOT_IMPLEMENTED("WP"),
GPIO_SIGNAL_NOT_IMPLEMENTED("ENTERING_RW"),
};
+BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT);