i2c: stm32: fix build issue

When building tests/kernel/test_build/test_debug on disco_l475_iot1 we
get the following build error:

drivers/i2c/i2c_ll_stm32_v2.c: In function ‘stm32_i2c_configure_timing’:
ext/hal/st/stm32cube/stm32l4xx/soc/stm32l4xx.h:207:38: error: ‘timing’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 #define WRITE_REG(REG, VAL)   ((REG) = (VAL))
                                      ^
drivers/i2c/i2c_ll_stm32_v2.c:265:8: note: ‘timing’ was declared here
  u32_t timing;
        ^~~~~~

Fix by initializing timing to 0.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2017-07-06 08:34:14 -05:00 committed by Kumar Gala
commit 4c233bbc05

View file

@ -262,7 +262,7 @@ int stm32_i2c_configure_timing(struct device *dev, u32_t clock)
u32_t i2c_hold_time_min, i2c_setup_time_min; u32_t i2c_hold_time_min, i2c_setup_time_min;
u32_t i2c_h_min_time, i2c_l_min_time; u32_t i2c_h_min_time, i2c_l_min_time;
u32_t presc = 1; u32_t presc = 1;
u32_t timing; u32_t timing = 0;
switch (data->dev_config.bits.speed) { switch (data->dev_config.bits.speed) {
case I2C_SPEED_STANDARD: case I2C_SPEED_STANDARD: