aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Bornyakov <[email protected]>2023-04-06 16:08:33 +0300
committerDavid S. Miller <[email protected]>2023-04-09 16:01:28 +0100
commitbef227c1537cb8005311c0842bc5449e8c7a5973 (patch)
treeab9b924053b727145b72e3d46401acee71c16496
parent813c2dd78618f108fdcf9cd726ea90f081ee2881 (diff)
net: sfp: avoid EEPROM read of absent SFP module
If SFP module is not present, it is sensible to fail sfp_module_eeprom() and sfp_module_eeprom_by_page() early to avoid excessive I2C transfers which are garanteed to fail. Suggested-by: Andrew Lunn <[email protected]> Signed-off-by: Ivan Bornyakov <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
-rw-r--r--drivers/net/phy/sfp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 81edc457c5a1..bf345032d450 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2487,6 +2487,9 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee,
unsigned int first, last, len;
int ret;
+ if (!(sfp->state & SFP_F_PRESENT))
+ return -ENODEV;
+
if (ee->len == 0)
return -EINVAL;
@@ -2519,6 +2522,9 @@ static int sfp_module_eeprom_by_page(struct sfp *sfp,
const struct ethtool_module_eeprom *page,
struct netlink_ext_ack *extack)
{
+ if (!(sfp->state & SFP_F_PRESENT))
+ return -ENODEV;
+
if (page->bank) {
NL_SET_ERR_MSG(extack, "Banks not supported");
return -EOPNOTSUPP;