RE: [PATCH v3] Renesas Ethernet AVB driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




From: Lino Sanfilippo
> On 14.04.2015 00:07, Sergei Shtylyov wrote:
> 
...
> > +#ifdef __LITTLE_ENDIAN
> > +	u32 res: 16;	/* Reserved bits */
> > +	u32 ts_sh: 16;	/* Timestamp high */
> > +#else
> > +	u32 ts_sh: 16;	/* Timestamp high */
> > +	u32 res: 16;	/* Reserved bits */
> > +#endif
> > +};
> 
> I recall a thread in which the use of bitfields for structs that are
> shared with the hardware was considered a bad idea (because the compiler
> is free to reorder the fields). Shift operations are probably a better
> choice here.

The compiler itself isn't free to reorder the fields, but the order
is an implementation decision for the compiler/ABI.
An ABI will probably define a bit order, but it doesn't have to match
the endianness.

Shifting and masking also tends to generate better code.

	David

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux