Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1344647
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] net: ezchip: adapt driver to little endian architecture |
| Date | 2016-02-26 21:20 +0100 |
| Message-ID | <r6x1M-6H-9@gated-at.bofh.it> (permalink) |
| References | <r6vW1-7QN-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] net: ezchip: adapt driver to little endian architecture Lada Trimasova <Lada.Trimasova@synopsys.com> - 2016-02-26 20:10 +0100
Re: [PATCH] net: ezchip: adapt driver to little endian architecture Arnd Bergmann <arnd@arndb.de> - 2016-02-26 21:20 +0100
Re: [PATCH] net: ezchip: adapt driver to little endian architecture Arnd Bergmann <arnd@arndb.de> - 2016-02-26 21:20 +0100
Re: [PATCH] net: ezchip: adapt driver to little endian architecture David Miller <davem@davemloft.net> - 2016-02-26 21:30 +0100
csiph-web