From: Florian Fainelli Subject: Re: [PATCH net-next 2/4] net: phy: sfp: Use correct endian for sfp->id.ext.options Date: Thu, 9 Nov 2017 20:39:24 -0800 Message-ID: References: <20171108034911.16382-1-f.fainelli@gmail.com> <20171108034911.16382-3-f.fainelli@gmail.com> <20171108085636.GO9463@n2100.armlinux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, davem@davemloft.net, andrew@lunn.ch To: Russell King - ARM Linux Return-path: Received: from mail-qk0-f194.google.com ([209.85.220.194]:45006 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755858AbdKJEj1 (ORCPT ); Thu, 9 Nov 2017 23:39:27 -0500 Received: by mail-qk0-f194.google.com with SMTP id v137so10536181qkb.1 for ; Thu, 09 Nov 2017 20:39:27 -0800 (PST) In-Reply-To: <20171108085636.GO9463@n2100.armlinux.org.uk> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 11/08/2017 12:56 AM, Russell King - ARM Linux wrote: > On Tue, Nov 07, 2017 at 07:49:09PM -0800, Florian Fainelli wrote: >> 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) > > It would be more efficient to convert the constants to BE16 rather > than an indeterminant number to CPU endian. The compiler can optimise > the constant. Same for the other two hunks. Sure, I can do that. -- Florian