From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Subject: [PATCH net-next 2/4] net: phy: sfp: Use correct endian for sfp->id.ext.options Date: Tue, 7 Nov 2017 19:49:09 -0800 Message-ID: <20171108034911.16382-3-f.fainelli@gmail.com> References: <20171108034911.16382-1-f.fainelli@gmail.com> Cc: davem@davemloft.net, andrew@lunn.ch, rmk+kernel@armlinux.org.uk, Florian Fainelli To: netdev@vger.kernel.org Return-path: Received: from mail-oi0-f67.google.com ([209.85.218.67]:43347 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751929AbdKHDtW (ORCPT ); Tue, 7 Nov 2017 22:49:22 -0500 Received: by mail-oi0-f67.google.com with SMTP id c77so1055027oig.0 for ; Tue, 07 Nov 2017 19:49:22 -0800 (PST) In-Reply-To: <20171108034911.16382-1-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: The extended ID options 16-bit value is big-endian (and actually annotated as such), but we would be accessing it with our CPU endian, which would not allow the correct detection of whether the LOS signal is inverted or not. Fixes: 73970055450e ("sfp: add SFP module support") Signed-off-by: Florian Fainelli --- drivers/net/phy/sfp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 942288aa9cdb..dfb28b269687 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -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 (be16_to_cpu(sfp->id.ext.options) & SFP_OPTIONS_LOS_INVERTED) los ^= SFP_F_LOS; if (los) @@ -583,7 +583,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 ? + (be16_to_cpu(sfp->id.ext.options) & + SFP_OPTIONS_LOS_INVERTED ? SFP_E_LOS_HIGH : SFP_E_LOS_LOW)) sfp_sm_link_up(sfp); break; @@ -593,7 +594,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 ? + (be16_to_cpu(sfp->id.ext.options) & + 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); -- 2.14.1