Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: sfp: handle cases where neither BR, min nor BR, max is given

When computing the bitrate using values read from an SFP module EEPROM,
we use the nominal BR plus BR,min and BR,max to determine the
boundaries. But in some cases BR,min and BR,max aren't provided, which
led the SFP code to end up having the nominal value for both the minimum
and maximum bitrate values. When using a passive cable, the nominal
value should be used as the maximum one, and there is no minimum one
so we should use 0.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Antoine Tenart and committed by
David S. Miller
2b999ba8 8d42eada

+7
+7
drivers/net/phy/sfp-bus.c
··· 132 132 br_max = br_nom + br_nom * id->ext.br_min / 100; 133 133 br_min = br_nom - br_nom * id->ext.br_min / 100; 134 134 } 135 + 136 + /* When using passive cables, in case neither BR,min nor BR,max 137 + * are specified, set br_min to 0 as the nominal value is then 138 + * used as the maximum. 139 + */ 140 + if (br_min == br_max && id->base.sfp_ct_passive) 141 + br_min = 0; 135 142 } 136 143 137 144 /* Set ethtool support from the compliance fields. */