diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-07-30 17:26:20 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-31 12:33:31 -0700 |
commit | af777297370e971bd4ae64e0e947cb5a1774dbfe (patch) | |
tree | 282a090d2431626ce01e4940c4a4ca722d70166e /include/i2c.h | |
parent | f6799258c3842ef855bf1516066464431b1b1a7d (diff) | |
download | chrome-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 'include/i2c.h')
-rw-r--r-- | include/i2c.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/i2c.h b/include/i2c.h index 86535c1fa8..747967b3a6 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -20,6 +20,8 @@ struct i2c_port_t { int kbps; /* Speed in kbps */ }; +extern const struct i2c_port_t i2c_ports[]; + /* Flags for i2c_xfer() */ #define I2C_XFER_START (1 << 0) /* Start smbus session from idle state */ #define I2C_XFER_STOP (1 << 1) /* Terminate smbus session with stop bit */ |