Commit 2794ffc4 authored by Russell King's avatar Russell King Committed by David S. Miller

sfp: fix EEPROM reading in the case of non-SFF8472 SFPs

The EEPROM reading was trying to read from the second EEPROM address
if we requested the last byte from the SFF8079 EEPROM, which caused a
failure when the second EEPROM is not present.  Discovered with a
S-RJ01 SFP module.  Fix this.

Fixes: 73970055 ("sfp: add SFP module support")
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 20b56ed9
...@@ -724,20 +724,19 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee, ...@@ -724,20 +724,19 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee,
len = min_t(unsigned int, last, ETH_MODULE_SFF_8079_LEN); len = min_t(unsigned int, last, ETH_MODULE_SFF_8079_LEN);
len -= first; len -= first;
ret = sfp->read(sfp, false, first, data, len); ret = sfp_read(sfp, false, first, data, len);
if (ret < 0) if (ret < 0)
return ret; return ret;
first += len; first += len;
data += len; data += len;
} }
if (first >= ETH_MODULE_SFF_8079_LEN && if (first < ETH_MODULE_SFF_8472_LEN && last > ETH_MODULE_SFF_8079_LEN) {
first < ETH_MODULE_SFF_8472_LEN) {
len = min_t(unsigned int, last, ETH_MODULE_SFF_8472_LEN); len = min_t(unsigned int, last, ETH_MODULE_SFF_8472_LEN);
len -= first; len -= first;
first -= ETH_MODULE_SFF_8079_LEN; first -= ETH_MODULE_SFF_8079_LEN;
ret = sfp->read(sfp, true, first, data, len); ret = sfp_read(sfp, true, first, data, len);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
......
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