Skip to content

Commit

Permalink
net: phy: sfp: hwmon: Fix scaling of RX power
Browse files Browse the repository at this point in the history
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: [email protected]
Signed-off-by: Andrew Lunn <[email protected]>
Fixes: 1323061 ("net: phy: sfp: Add HWMON support for module sensors")
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
lunn authored and davem330 committed Jul 21, 2019
1 parent 503d81d commit 0cea0e1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/phy/sfp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0cea0e1

Please sign in to comment.