Skip to content

Commit

Permalink
sfp: fix RX_LOS signal handling
Browse files Browse the repository at this point in the history
The options word is a be16 quantity, so we need to test the flags
having converted the endian-ness.  Convert the flag bits to be16,
which can be optimised by the compiler, rather than converting a
variable at runtime.

Reported-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Russell King authored and David S. Miller committed Dec 1, 2017
1 parent a0da456 commit acf1c02
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/phy/sfp.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static void sfp_sm_link_check_los(struct sfp *sfp)
* SFP_OPTIONS_LOS_NORMAL are set? For now, we assume
* the same as SFP_OPTIONS_LOS_NORMAL set.
*/
if (sfp->id.ext.options & SFP_OPTIONS_LOS_INVERTED)
if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_INVERTED))
los ^= SFP_F_LOS;

if (los)
Expand Down Expand Up @@ -582,7 +582,8 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
if (event == SFP_E_TX_FAULT)
sfp_sm_fault(sfp, true);
else if (event ==
(sfp->id.ext.options & SFP_OPTIONS_LOS_INVERTED ?
(sfp->id.ext.options &
cpu_to_be16(SFP_OPTIONS_LOS_INVERTED) ?
SFP_E_LOS_HIGH : SFP_E_LOS_LOW))
sfp_sm_link_up(sfp);
break;
Expand All @@ -592,7 +593,8 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
sfp_sm_link_down(sfp);
sfp_sm_fault(sfp, true);
} else if (event ==
(sfp->id.ext.options & SFP_OPTIONS_LOS_INVERTED ?
(sfp->id.ext.options &
cpu_to_be16(SFP_OPTIONS_LOS_INVERTED) ?
SFP_E_LOS_LOW : SFP_E_LOS_HIGH)) {
sfp_sm_link_down(sfp);
sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0);
Expand Down

0 comments on commit acf1c02

Please sign in to comment.