Commit ab8e3c9c authored by Alessandro Rubini's avatar Alessandro Rubini

eeprom: rename "present" to "init"

eeprom_present() returned a value nobody used. Rename to eeprom_init()
instead. Also, save the two parameters so that they are not needed
in other functions (see later commits).

Also, turn int8_t to int as function arguments (int is better for the
CPU).

This adds 20 bytes to the legacy case, and removes 4 to the sdb case.
The legacy size is reduced by later commits.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9db373ba
......@@ -58,14 +58,20 @@
uint8_t has_eeprom = 0;
uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr)
static int i2cif, i2c_addr; /* globals, using the names we always used */
void eeprom_init(int chosen_i2cif, int chosen_i2c_addr)
{
/* Save these to globals, they are never passed any more */
i2cif = chosen_i2cif;
i2c_addr = chosen_i2c_addr;
has_eeprom = 1;
if (!mi2c_devprobe(i2cif, i2c_addr))
if (!mi2c_devprobe(i2cif, i2c_addr))
has_eeprom = 0;
return 0;
return;
}
static int eeprom_read(uint8_t i2cif, uint8_t i2c_addr, uint32_t offset,
......
......@@ -138,11 +138,11 @@ static struct sdbfs wrc_sdb = {
uint8_t has_eeprom = 0; /* modified at init time */
/*
* Init: returns 0 for success; it changes has_eeprom above
* Init: sets "int has_eeprom" above
*
* This is called by wrc_main, after initializing both w1 and i2c
*/
uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr)
void eeprom_init(int chosen_i2cif, int chosen_i2c_addr)
{
uint32_t magic = 0;
static unsigned entry_points[] = {0, 64, 128, 256, 512, 1024};
......@@ -169,10 +169,10 @@ uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr)
/*
* If w1 failed, look for i2c: start from low offsets.
*/
if (!mi2c_devprobe(i2cif, i2c_addr))
return 0;
i2c_params.ifnum = i2cif;
i2c_params.addr = i2c_addr;
i2c_params.ifnum = chosen_i2cif;
i2c_params.addr = chosen_i2c_addr;
if (!mi2c_devprobe(i2c_params.ifnum, i2c_params.addr))
return;
/* While looking for the magic number, use sdb-based read function */
for (i = 0; i < ARRAY_SIZE(entry_points); i++) {
......@@ -185,7 +185,7 @@ uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr)
}
if (i == ARRAY_SIZE(entry_points)) {
pp_printf("No SDB filesystem in i2c eeprom\n");
return 0;
return;
}
found_exit:
......@@ -193,7 +193,7 @@ found_exit:
has_eeprom = 1;
sdbfs_dev_create(&wrc_sdb);
eeprom_sdb_list(&wrc_sdb);
return 0;
return;
}
/*
......
......@@ -27,7 +27,7 @@ struct s_sfpinfo {
uint8_t chksum;
} __attribute__ ((__packed__));
uint8_t eeprom_present(uint8_t i2cif, uint8_t i2c_addr);
void eeprom_init(int i2cif, int i2c_addr);
int32_t eeprom_sfpdb_erase(uint8_t i2cif, uint8_t i2c_addr);
int32_t eeprom_sfp_section(uint8_t i2cif, uint8_t i2c_addr, size_t size,
......
......@@ -60,7 +60,7 @@ static void wrc_initialize()
/*initialize I2C bus*/
mi2c_init(WRPC_FMC_I2C);
/*check if EEPROM is onboard*/
eeprom_present(WRPC_FMC_I2C, FMC_EEPROM_ADR);
eeprom_init(WRPC_FMC_I2C, FMC_EEPROM_ADR);
mac_addr[0] = 0x08; //
mac_addr[1] = 0x00; // CERN OUI
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment