diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2019-12-03 23:51:28 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-12-04 16:57:52 -0800 |
commit | 38ecd706ca78525d9c4e3bdf9dbe4d2860c125ef (patch) | |
tree | 6a6507d3ec5fcd232b04e2d51956cc4411b5d3c0 /drivers/net/phy/sfp.c | |
parent | 0cb96b5749bf500f3612cda52fc98eb795fcd62d (diff) | |
download | linux-stable-38ecd706ca78525d9c4e3bdf9dbe4d2860c125ef.tar.gz linux-stable-38ecd706ca78525d9c4e3bdf9dbe4d2860c125ef.tar.bz2 linux-stable-38ecd706ca78525d9c4e3bdf9dbe4d2860c125ef.zip |
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: 139d3a212a1f ("net: sfp: allow modules with slow diagnostics to probe")
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/sfp.c')
-rw-r--r-- | drivers/net/phy/sfp.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index c118d9f0195b..c0b9a8e4e65a 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1754,6 +1754,10 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event) break; } + err = sfp_hwmon_insert(sfp); + if (err) + dev_warn(sfp->dev, "hwmon probe failed: %d\n", err); + sfp_sm_mod_next(sfp, SFP_MOD_WAITDEV, 0); /* fall through */ case SFP_MOD_WAITDEV: @@ -1803,15 +1807,6 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event) case SFP_MOD_ERROR: break; } - -#if IS_ENABLED(CONFIG_HWMON) - if (sfp->sm_mod_state >= SFP_MOD_WAITDEV && - IS_ERR_OR_NULL(sfp->hwmon_dev)) { - err = sfp_hwmon_insert(sfp); - if (err) - dev_warn(sfp->dev, "hwmon probe failed: %d\n", err); - } -#endif } static void sfp_sm_main(struct sfp *sfp, unsigned int event) |