Skip to content

Commit 256e43c

Browse files
Russell Kingdavem330
authored andcommitted
net: sfp: error handling for phy probe
Signed-off-by: Russell King <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 281e4ea commit 256e43c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

drivers/net/phy/sfp.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,37 +1410,39 @@ static void sfp_sm_phy_detach(struct sfp *sfp)
14101410
sfp->mod_phy = NULL;
14111411
}
14121412

1413-
static void sfp_sm_probe_phy(struct sfp *sfp, bool is_c45)
1413+
static int sfp_sm_probe_phy(struct sfp *sfp, bool is_c45)
14141414
{
14151415
struct phy_device *phy;
14161416
int err;
14171417

14181418
phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45);
14191419
if (phy == ERR_PTR(-ENODEV)) {
14201420
dev_info(sfp->dev, "no PHY detected\n");
1421-
return;
1421+
return 0;
14221422
}
14231423
if (IS_ERR(phy)) {
14241424
dev_err(sfp->dev, "mdiobus scan returned %ld\n", PTR_ERR(phy));
1425-
return;
1425+
return PTR_ERR(phy);
14261426
}
14271427

14281428
err = phy_device_register(phy);
14291429
if (err) {
14301430
phy_device_free(phy);
14311431
dev_err(sfp->dev, "phy_device_register failed: %d\n", err);
1432-
return;
1432+
return err;
14331433
}
14341434

14351435
err = sfp_add_phy(sfp->sfp_bus, phy);
14361436
if (err) {
14371437
phy_device_remove(phy);
14381438
phy_device_free(phy);
14391439
dev_err(sfp->dev, "sfp_add_phy failed: %d\n", err);
1440-
return;
1440+
return err;
14411441
}
14421442

14431443
sfp->mod_phy = phy;
1444+
1445+
return 0;
14441446
}
14451447

14461448
static void sfp_sm_link_up(struct sfp *sfp)
@@ -1513,21 +1515,24 @@ static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn)
15131515
* Clause 45 copper SFP+ modules (10G) appear to switch their interface
15141516
* mode according to the negotiated line speed.
15151517
*/
1516-
static void sfp_sm_probe_for_phy(struct sfp *sfp)
1518+
static int sfp_sm_probe_for_phy(struct sfp *sfp)
15171519
{
1520+
int err = 0;
1521+
15181522
switch (sfp->id.base.extended_cc) {
15191523
case SFF8024_ECC_10GBASE_T_SFI:
15201524
case SFF8024_ECC_10GBASE_T_SR:
15211525
case SFF8024_ECC_5GBASE_T:
15221526
case SFF8024_ECC_2_5GBASE_T:
1523-
sfp_sm_probe_phy(sfp, true);
1527+
err = sfp_sm_probe_phy(sfp, true);
15241528
break;
15251529

15261530
default:
15271531
if (sfp->id.base.e1000_base_t)
1528-
sfp_sm_probe_phy(sfp, false);
1532+
err = sfp_sm_probe_phy(sfp, false);
15291533
break;
15301534
}
1535+
return err;
15311536
}
15321537

15331538
static int sfp_module_parse_power(struct sfp *sfp)
@@ -1938,7 +1943,10 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
19381943
init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT
19391944
* clear. Probe for the PHY and check the LOS state.
19401945
*/
1941-
sfp_sm_probe_for_phy(sfp);
1946+
if (sfp_sm_probe_for_phy(sfp)) {
1947+
sfp_sm_next(sfp, SFP_S_FAIL, 0);
1948+
break;
1949+
}
19421950
if (sfp_module_start(sfp->sfp_bus)) {
19431951
sfp_sm_next(sfp, SFP_S_FAIL, 0);
19441952
break;

0 commit comments

Comments
 (0)