Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp660592ybl; Fri, 31 Jan 2020 05:50:56 -0800 (PST) X-Google-Smtp-Source: APXvYqxidUxJlxMXOdLpkkSQR0bDyxqMYKbk5EvnVqk+xOTY5+kFTGhjG3DdxCleOCB4TXy1cBDX X-Received: by 2002:aca:f487:: with SMTP id s129mr2313197oih.75.1580478656137; Fri, 31 Jan 2020 05:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580478656; cv=none; d=google.com; s=arc-20160816; b=QufkvWq5PXxwVoMo1y1KhDsFkchtWJxpBiZoPf5y9KHqiooTc0+MKnngMhS8Y7VitX BDWa7X4gCokVWbiuDImtg7696O3J32TXfoR1G8t9l5TE45oDVpIugoB5FsKB8ek9bXC0 bGFnKyn1wxjEZOW6uVWPs8UwM3sJ2BFV+/1TkLTIR8u8DT7Ozp/8zL/jSn6bhiOju2PJ AgZ2F/wlUHeY8tJpSqjShFikTgJFtt+sQE1QuwLfGlHUssUdY2i6KYsBbcUESemyULTi RdZUUcnq7IqIUE4HZGYCq1NfOXcV/mUSRVTD3EoBXrl32i5FHJkXFpA2v44LwmCmvnhI CxOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=77heQxkPpR1j313BxRvUk+Ag0IcAcRqZAwmlY8oelSk=; b=XE8dnCt34wOfomlDomwiWj06JJnOp5BqN92Y9tVQ1qBXnV0aBJOCbNCqWybFAsdzJ9 yOESDa3uzcNTwOiJIIhH8nifq+ZOVWD+YT5LKLsqIiWeTxc1v8TgMnK/rKFAErNH4ofb iSG+T24P/mx7r960/v0QoO2fFtGxshog12B8t6O1Ucj35iLV1XPhXwQhExngiOa1UyhN ISRHibT0x6Ekr41m/dgLThZJ0PMdoVOepnyKbCsyiu/b9ZSNsP+UzGQCPRyyuv0QMRzw cdVwp1k0wlzyv7n23g13zAqtUrevYSAP3IhsBH/ZPL2vqbq6o0s5+jHdcxa8dizBhinI FWbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=TIEugwB+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w15si4762962otm.263.2020.01.31.05.50.44; Fri, 31 Jan 2020 05:50:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=TIEugwB+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728856AbgAaNsx (ORCPT + 99 others); Fri, 31 Jan 2020 08:48:53 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:59948 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728614AbgAaNsx (ORCPT ); Fri, 31 Jan 2020 08:48:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=77heQxkPpR1j313BxRvUk+Ag0IcAcRqZAwmlY8oelSk=; b=TIEugwB+DJLbJVsOL7NvEZ8BQ0 kUUqorMqCOHdGJ2OyIPrZvzj8X0hz8byAyuQfmwhlYVwwKrBp3LYPrTiCUxUcmJxzjpLPLJHE8pjj iMso6TTHiNJCyVyz2qk3h3tQwvUbPx8ynzTCZ1gVHjB1FHqXcBWrc+zoBsoxOofPVrQo=; Received: from andrew by vps0.lunn.ch with local (Exim 4.93) (envelope-from ) id 1ixWfB-0007Nv-Iw; Fri, 31 Jan 2020 14:48:49 +0100 Date: Fri, 31 Jan 2020 14:48:49 +0100 From: Andrew Lunn To: Radhey Shyam Pandey Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, anirudha.sarangi@xilinx.com, michal.simek@xilinx.com, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, john.linn@xilinx.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 -next 4/4] net: emaclite: Fix restricted cast warning of sparse Message-ID: <20200131134849.GE9639@lunn.ch> References: <1580471270-16262-1-git-send-email-radhey.shyam.pandey@xilinx.com> <1580471270-16262-5-git-send-email-radhey.shyam.pandey@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1580471270-16262-5-git-send-email-radhey.shyam.pandey@xilinx.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 31, 2020 at 05:17:50PM +0530, Radhey Shyam Pandey wrote: > Explicitly cast xemaclite_readl return value when it's passed to ntohl. > Fixes below reported sparse warnings: > > xilinx_emaclite.c:411:24: sparse: sparse: cast to restricted __be32 > xilinx_emaclite.c:420:36: sparse: sparse: cast to restricted __be32 > > Signed-off-by: Radhey Shyam Pandey > Reported-by: kbuild test robot > --- > drivers/net/ethernet/xilinx/xilinx_emaclite.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c > index 96e9d21..3273d4f 100644 > --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c > +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c > @@ -408,7 +408,8 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data, int maxlen) > > /* Get the protocol type of the ethernet frame that arrived > */ > - proto_type = ((ntohl(xemaclite_readl(addr + XEL_HEADER_OFFSET + > + proto_type = ((ntohl((__force __be32)xemaclite_readl(addr + > + XEL_HEADER_OFFSET + > XEL_RXBUFF_OFFSET)) >> XEL_HEADER_SHIFT) & > XEL_RPLR_LENGTH_MASK); > > @@ -417,7 +418,7 @@ static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data, int maxlen) > */ > if (proto_type > ETH_DATA_LEN) { > if (proto_type == ETH_P_IP) { > - length = ((ntohl(xemaclite_readl(addr + > + length = ((ntohl((__force __be32)xemaclite_readl(addr + > XEL_HEADER_IP_LENGTH_OFFSET + > XEL_RXBUFF_OFFSET)) >> > XEL_HEADER_SHIFT) & If i understand this code correctly, you need the ntohl because you are poking around inside the packet. All the other uses of xemaclite_readl() are for descriptors etc. It would be cleaner if you defined a xemaclite_readlbe32. If you use ioread32be() it will do the endinness swap for you, so you don't need the ntohl() and the horrible cast. Andrew