Skip to content

Commit bef227c

Browse files
Ivan Bornyakovdavem330
authored andcommitted
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 <andrew@lunn.ch> Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 813c2dd commit bef227c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/net/phy/sfp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,6 +2487,9 @@ static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee,
24872487
unsigned int first, last, len;
24882488
int ret;
24892489

2490+
if (!(sfp->state & SFP_F_PRESENT))
2491+
return -ENODEV;
2492+
24902493
if (ee->len == 0)
24912494
return -EINVAL;
24922495

@@ -2519,6 +2522,9 @@ static int sfp_module_eeprom_by_page(struct sfp *sfp,
25192522
const struct ethtool_module_eeprom *page,
25202523
struct netlink_ext_ack *extack)
25212524
{
2525+
if (!(sfp->state & SFP_F_PRESENT))
2526+
return -ENODEV;
2527+
25222528
if (page->bank) {
25232529
NL_SET_ERR_MSG(extack, "Banks not supported");
25242530
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)