Skip to content
Snippets Groups Projects
Commit 0df0d010 authored by Jonas Höppner's avatar Jonas Höppner
Browse files

[LIB][EEPROM] Fix error handling in auto init function

Instead of providing a default that may match or not, just fail if the
bus and address for the eeprom is not configured.
Also added a build-time warning.
parent bed37689
No related branches found
No related tags found
1 merge request!221[LIB][eeprom] Fix error handling in auto init function
......@@ -26,10 +26,12 @@
*/
#ifndef SECO_EEPROM_I2C_BUS
#define SECO_EEPROM_I2C_BUS 0x04
#define SECO_EEPROM_I2C_BUS -1
#warning SECO_EEPROM_I2C_BUS is not specified, please configure it in the board header file.
#endif
#ifndef SECO_EEPROM_I2C_ADDR
#define SECO_EEPROM_I2C_ADDR 0x50
#define SECO_EEPROM_I2C_ADDR -1
#warning SECO_EEPROM_I2C_ADDR is not specified, please configure it in the board header file.
#endif
u8 g_raw_data[EEPROM_SIZE];
......@@ -265,9 +267,20 @@ int seco_eeprom_auto_init(void)
int i2c_addr = SECO_EEPROM_I2C_ADDR;
env_str = env_get("seco_eeprom_i2c_bus");
if( env_str) i2c_bus_number = simple_strtoul(env_str, NULL, 0);
if( env_str)
i2c_bus_number = simple_strtoul(env_str, NULL, 0);
else if(i2c_bus_number < 0){
printf( "seco_eeprom_manager: Failed to auto initialize, 'i2c bus number' not found in environment or board header.\n");
return -1;
}
env_str = env_get("seco_eeprom_i2c_addr");
if( env_str) i2c_addr = simple_strtoul(env_str, NULL, 0);
if( env_str)
i2c_addr = simple_strtoul(env_str, NULL, 0);
else if( i2c_addr < 0){
printf( "seco_eeprom_manager: Failed to auto initialize, 'i2c address' not found in environment or board header.\n");
return -1;
}
return seco_eeprom_init(i2c_bus_number, i2c_addr);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment