From: Radhey Shyam Pandey <radheys@xilinx.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Anirudha Sarangi <anirudh@xilinx.com>,
Michal Simek <michals@xilinx.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"mchehab+samsung@kernel.org" <mchehab+samsung@kernel.org>,
John Linn <linnj@xilinx.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: RE: [PATCH v3 -next 4/4] net: emaclite: Fix restricted cast warning of sparse
Date: Mon, 10 Feb 2020 14:55:20 +0000 [thread overview]
Message-ID: <CH2PR02MB70008E426323BBF4EF3BCCA2C7190@CH2PR02MB7000.namprd02.prod.outlook.com> (raw)
In-Reply-To: <20200131134849.GE9639@lunn.ch>
> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: Friday, January 31, 2020 7:19 PM
> To: Radhey Shyam Pandey <radheys@xilinx.com>
> Cc: davem@davemloft.net; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; Anirudha Sarangi <anirudh@xilinx.com>; Michal Simek
> <michals@xilinx.com>; gregkh@linuxfoundation.org;
> mchehab+samsung@kernel.org; John Linn <linnj@xilinx.com>; linux-arm-
> kernel@lists.infradead.org
> Subject: Re: [PATCH v3 -next 4/4] net: emaclite: Fix restricted cast warning of
> sparse
>
> 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 <radhey.shyam.pandey@xilinx.com>
> > Reported-by: kbuild test robot <lkp@intel.com>
> > ---
> > 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.
Thanks for the review. Yes, defining xemaclite_readlbe32 would eliminate the
cast need. I will address it in the next version.
>
> Andrew
prev parent reply other threads:[~2020-02-10 14:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-31 11:47 [PATCH v3 -next 0/4] net: emaclite: support arm64 platform Radhey Shyam Pandey
2020-01-31 11:47 ` [PATCH v3 -next 1/4] net: emaclite: Fix coding style Radhey Shyam Pandey
2020-01-31 11:47 ` [PATCH v3 -next 2/4] net: emaclite: In kconfig remove arch dependency Radhey Shyam Pandey
2020-01-31 11:47 ` [PATCH v3 -next 3/4] net: emaclite: Fix arm64 compilation warnings Radhey Shyam Pandey
2020-01-31 13:37 ` Andrew Lunn
2020-02-10 14:26 ` Radhey Shyam Pandey
2020-01-31 11:47 ` [PATCH v3 -next 4/4] net: emaclite: Fix restricted cast warning of sparse Radhey Shyam Pandey
2020-01-31 13:48 ` Andrew Lunn
2020-02-10 14:55 ` Radhey Shyam Pandey [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CH2PR02MB70008E426323BBF4EF3BCCA2C7190@CH2PR02MB7000.namprd02.prod.outlook.com \
--to=radheys@xilinx.com \
--cc=andrew@lunn.ch \
--cc=anirudh@xilinx.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=linnj@xilinx.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab+samsung@kernel.org \
--cc=michals@xilinx.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).