Skip to content

Commit 3ea5f79

Browse files
bravlcarlescufi
authored andcommitted
i2c: target: eeprom_target: add addressable size assert
Add build-time assert to check if the size defined is actually addressable. i.e: if address-width is set to 8, the maximum addressable size is 256 bytes. Signed-off-by: Bram Vlerick <[email protected]>
1 parent 52ee175 commit 3ea5f79

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/i2c/target/eeprom_target.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ static int i2c_eeprom_target_init(const struct device *dev)
259259
static uint8_t \
260260
i2c_eeprom_target_##inst##_buffer[(DT_INST_PROP(inst, size))]; \
261261
\
262+
BUILD_ASSERT(DT_INST_PROP(inst, size) <= \
263+
(1 << DT_INST_PROP_OR(inst, address_width, 8)), \
264+
"size must be <= than 2^address_width"); \
265+
\
262266
static const struct i2c_eeprom_target_config \
263267
i2c_eeprom_target_##inst##_cfg = { \
264268
.bus = I2C_DT_SPEC_INST_GET(inst), \

0 commit comments

Comments
 (0)