Commit 4ed88edb authored by Alessandro Rubini's avatar Alessandro Rubini

eeprom: don't pass redundant parameters to eeprom_get_sfp

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent ca42df73
...@@ -146,7 +146,7 @@ int32_t eeprom_sfpdb_erase(void) ...@@ -146,7 +146,7 @@ int32_t eeprom_sfpdb_erase(void)
return sfpcount; return sfpcount;
} }
int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp, int eeprom_get_sfp(struct s_sfpinfo * sfp,
uint8_t add, uint8_t pos) uint8_t add, uint8_t pos)
{ {
static uint8_t sfpcount = 0; static uint8_t sfpcount = 0;
...@@ -208,8 +208,7 @@ int eeprom_match_sfp(struct s_sfpinfo * sfp) ...@@ -208,8 +208,7 @@ int eeprom_match_sfp(struct s_sfpinfo * sfp)
struct s_sfpinfo dbsfp; struct s_sfpinfo dbsfp;
for (i = 0; i < sfpcount; ++i) { for (i = 0; i < sfpcount; ++i) {
temp = eeprom_get_sfp(WRPC_FMC_I2C, FMC_EEPROM_ADR, temp = eeprom_get_sfp(&dbsfp, 0, i);
&dbsfp, 0, i);
if (!i) { if (!i) {
sfpcount = temp; //only in first round valid sfpcount is returned from eeprom_get_sfp sfpcount = temp; //only in first round valid sfpcount is returned from eeprom_get_sfp
if (sfpcount == 0 || sfpcount == 0xFF) if (sfpcount == 0 || sfpcount == 0xFF)
......
...@@ -287,7 +287,7 @@ int32_t eeprom_sfpdb_erase(void) ...@@ -287,7 +287,7 @@ int32_t eeprom_sfpdb_erase(void)
return ret == 1 ? 0 : -1; return ret == 1 ? 0 : -1;
} }
int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp, int eeprom_get_sfp(struct s_sfpinfo * sfp,
uint8_t add, uint8_t pos) uint8_t add, uint8_t pos)
{ {
static uint8_t sfpcount = 0; static uint8_t sfpcount = 0;
...@@ -357,8 +357,7 @@ int eeprom_match_sfp(struct s_sfpinfo * sfp) ...@@ -357,8 +357,7 @@ int eeprom_match_sfp(struct s_sfpinfo * sfp)
struct s_sfpinfo dbsfp; struct s_sfpinfo dbsfp;
for (i = 0; i < sfpcount; ++i) { for (i = 0; i < sfpcount; ++i) {
temp = eeprom_get_sfp(i2c_params.ifnum, i2c_params.addr, temp = eeprom_get_sfp(&dbsfp, 0, i);
&dbsfp, 0, i);
if (!i) { if (!i) {
// first round: valid sfpcount is returned // first round: valid sfpcount is returned
sfpcount = temp; sfpcount = temp;
......
...@@ -31,6 +31,8 @@ void eeprom_init(int i2cif, int i2c_addr); ...@@ -31,6 +31,8 @@ void eeprom_init(int i2cif, int i2c_addr);
int eeprom_sfpdb_erase(void); int eeprom_sfpdb_erase(void);
int eeprom_match_sfp(struct s_sfpinfo *sfp); int eeprom_match_sfp(struct s_sfpinfo *sfp);
int eeprom_get_sfp(struct s_sfpinfo * sfp,
uint8_t add, uint8_t pos);
int8_t eeprom_phtrans(uint8_t i2cif, uint8_t i2c_addr, uint32_t * val, int8_t eeprom_phtrans(uint8_t i2cif, uint8_t i2c_addr, uint32_t * val,
uint8_t write); uint8_t write);
...@@ -41,7 +43,5 @@ int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr); ...@@ -41,7 +43,5 @@ int32_t eeprom_init_show(uint8_t i2cif, uint8_t i2c_addr);
int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, uint8_t *buf, int8_t eeprom_init_readcmd(uint8_t i2cif, uint8_t i2c_addr, uint8_t *buf,
uint8_t bufsize, uint8_t next); uint8_t bufsize, uint8_t next);
int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo * sfp,
uint8_t add, uint8_t pos);
#endif #endif
...@@ -66,7 +66,7 @@ static int cmd_sfp(const char *args[]) ...@@ -66,7 +66,7 @@ static int cmd_sfp(const char *args[])
sfp.dTx = atoi(args[2]); sfp.dTx = atoi(args[2]);
sfp.dRx = atoi(args[3]); sfp.dRx = atoi(args[3]);
sfp.alpha = atoi(args[4]); sfp.alpha = atoi(args[4]);
temp = eeprom_get_sfp(WRPC_FMC_I2C, FMC_EEPROM_ADR, &sfp, 1, 0); temp = eeprom_get_sfp(&sfp, 1, 0);
if (temp == EE_RET_DBFULL) if (temp == EE_RET_DBFULL)
mprintf("SFP DB is full\n"); mprintf("SFP DB is full\n");
else if (temp == EE_RET_I2CERR) else if (temp == EE_RET_I2CERR)
...@@ -75,8 +75,7 @@ static int cmd_sfp(const char *args[]) ...@@ -75,8 +75,7 @@ static int cmd_sfp(const char *args[])
mprintf("%d SFPs in DB\n", temp); mprintf("%d SFPs in DB\n", temp);
} else if (args[0] && !strcasecmp(args[0], "show")) { } else if (args[0] && !strcasecmp(args[0], "show")) {
for (i = 0; i < sfpcount; ++i) { for (i = 0; i < sfpcount; ++i) {
temp = eeprom_get_sfp(WRPC_FMC_I2C, FMC_EEPROM_ADR, temp = eeprom_get_sfp(&sfp, 0, i);
&sfp, 0, i);
if (!i) { if (!i) {
sfpcount = temp; //only in first round valid sfpcount is returned from eeprom_get_sfp sfpcount = temp; //only in first round valid sfpcount is returned from eeprom_get_sfp
if (sfpcount == 0 || sfpcount == 0xFF) { if (sfpcount == 0 || sfpcount == 0xFF) {
......
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