From: Arnd Bergmann <arnd@arndb.de>
To: Lada Trimasova <Lada.Trimasova@synopsys.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
Noam Camus <noamc@ezchip.com>, Tal Zilcer <talz@ezchip.com>
Subject: Re: [PATCH] net: ezchip: adapt driver to little endian architecture
Date: Fri, 26 Feb 2016 21:12:58 +0100 [thread overview]
Message-ID: <2727618.vosfDbrtXA@wuerfel> (raw)
In-Reply-To: <1456513509-30844-1-git-send-email-ltrimas@synopsys.com>
On Friday 26 February 2016 22:05:09 Lada Trimasova wrote:
>
> @@ -75,6 +86,7 @@ struct nps_enet_rx_ctl {
> * nr: Length in bytes of Rx frame loaded by MAC to Rx buffer
> */
> struct {
> +#ifdef CONFIG_CPU_BIG_ENDIAN
> u32
> __reserved_1:16,
> cr:1,
> @@ -82,6 +94,15 @@ struct nps_enet_rx_ctl {
> crc:1,
> __reserved_2:2,
> nr:11;
> +#else
> + u32
> + nr:11,
> + __reserved_2:2,
> + crc:1,
> + er:1,
> + cr:1,
> + __reserved_1:16;
> +#endif
> };
A nicer way to do this would be to remove all the bitfields
and use named constants for accessing the fields insode of
a u32 or u64 variable.
The order of the bits in a bit field is implementation specific
and your method might not work on all architectures. Even if the
driver is only meant to run on a single CPU architecture, it's
always better to write portable code.
Arnd
prev parent reply other threads:[~2016-02-26 20:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 19:05 [PATCH] net: ezchip: adapt driver to little endian architecture Lada Trimasova
2016-02-26 20:10 ` Arnd Bergmann
2016-02-26 20:25 ` David Miller
2016-02-26 20:12 ` Arnd Bergmann [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=2727618.vosfDbrtXA@wuerfel \
--to=arnd@arndb.de \
--cc=Alexey.Brodkin@synopsys.com \
--cc=Lada.Trimasova@synopsys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=noamc@ezchip.com \
--cc=talz@ezchip.com \
/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