* [PATCH net] net: phy: sfp: hwmon: Fix scaling of RX power
@ 2019-07-21 16:50 Andrew Lunn
2019-07-21 18:52 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Lunn @ 2019-07-21 16:50 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Russell King, Chris Healy, Andrew Lunn
The RX power read from the SFP uses units of 0.1uW. This must be
scaled to units of uW for HWMON. This requires a divide by 10, not the
current 100.
With this change in place, sensors(1) and ethtool -m agree:
sff2-isa-0000
Adapter: ISA adapter
in0: +3.23 V
temp1: +33.1 C
power1: 270.00 uW
power2: 200.00 uW
curr1: +0.01 A
Laser output power : 0.2743 mW / -5.62 dBm
Receiver signal average optical power : 0.2014 mW / -6.96 dBm
Reported-by: chris.healy@zii.aero
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Fixes: 1323061a018a ("net: phy: sfp: Add HWMON support for module sensors")
---
drivers/net/phy/sfp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 2d816aadea79..e36c04c26866 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -517,7 +517,7 @@ static int sfp_hwmon_read_sensor(struct sfp *sfp, int reg, long *value)
static void sfp_hwmon_to_rx_power(long *value)
{
- *value = DIV_ROUND_CLOSEST(*value, 100);
+ *value = DIV_ROUND_CLOSEST(*value, 10);
}
static void sfp_hwmon_calibrate(struct sfp *sfp, unsigned int slope, int offset,
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net: phy: sfp: hwmon: Fix scaling of RX power
2019-07-21 16:50 [PATCH net] net: phy: sfp: hwmon: Fix scaling of RX power Andrew Lunn
@ 2019-07-21 18:52 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-07-21 18:52 UTC (permalink / raw)
To: andrew; +Cc: netdev, rmk+kernel, Chris.Healy
From: Andrew Lunn <andrew@lunn.ch>
Date: Sun, 21 Jul 2019 18:50:08 +0200
> The RX power read from the SFP uses units of 0.1uW. This must be
> scaled to units of uW for HWMON. This requires a divide by 10, not the
> current 100.
>
> With this change in place, sensors(1) and ethtool -m agree:
>
> sff2-isa-0000
> Adapter: ISA adapter
> in0: +3.23 V
> temp1: +33.1 C
> power1: 270.00 uW
> power2: 200.00 uW
> curr1: +0.01 A
>
> Laser output power : 0.2743 mW / -5.62 dBm
> Receiver signal average optical power : 0.2014 mW / -6.96 dBm
>
> Reported-by: chris.healy@zii.aero
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> Fixes: 1323061a018a ("net: phy: sfp: Add HWMON support for module sensors")
Applied and queued up for -stable, thanks Andrew.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-21 18:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-21 16:50 [PATCH net] net: phy: sfp: hwmon: Fix scaling of RX power Andrew Lunn
2019-07-21 18:52 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox