Skip to content

Commit 38ecd70

Browse files
Russell Kingdavem330
authored andcommitted
net: sfp: fix hwmon
The referenced commit below allowed more than one hwmon device to be created per SFP, which is definitely not what we want. Avoid this by only creating the hwmon device just as we transition to WAITDEV state. Fixes: 139d3a2 ("net: sfp: allow modules with slow diagnostics to probe") Signed-off-by: Russell King <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0cb96b5 commit 38ecd70

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

drivers/net/phy/sfp.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,10 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
17541754
break;
17551755
}
17561756

1757+
err = sfp_hwmon_insert(sfp);
1758+
if (err)
1759+
dev_warn(sfp->dev, "hwmon probe failed: %d\n", err);
1760+
17571761
sfp_sm_mod_next(sfp, SFP_MOD_WAITDEV, 0);
17581762
/* fall through */
17591763
case SFP_MOD_WAITDEV:
@@ -1803,15 +1807,6 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
18031807
case SFP_MOD_ERROR:
18041808
break;
18051809
}
1806-
1807-
#if IS_ENABLED(CONFIG_HWMON)
1808-
if (sfp->sm_mod_state >= SFP_MOD_WAITDEV &&
1809-
IS_ERR_OR_NULL(sfp->hwmon_dev)) {
1810-
err = sfp_hwmon_insert(sfp);
1811-
if (err)
1812-
dev_warn(sfp->dev, "hwmon probe failed: %d\n", err);
1813-
}
1814-
#endif
18151810
}
18161811

18171812
static void sfp_sm_main(struct sfp *sfp, unsigned int event)

0 commit comments

Comments
 (0)