Re: [PATCH 11/15] MIPS: paravirt: Add pci controller for virtio

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

 



On Tue, May 20, 2014 at 04:47:12PM +0200, Andreas Herrmann wrote:

> +
> +union pci_config_address {
> +	struct {
> +#ifdef __LITTLE_ENDIAN
> +		unsigned	register_number	: 8;		/* 7  .. 0  */
> +		unsigned	devfn_number	: 8;		/* 15 .. 8  */
> +		unsigned	bus_number	: 8;		/* 23 .. 16 */
> +		unsigned	reserved	: 7;		/* 30 .. 24 */
> +		unsigned	enable_bit	: 1;		/* 31       */
> +#else
> +		unsigned	enable_bit	: 1;		/* 31       */
> +		unsigned	reserved	: 7;		/* 30 .. 24 */
> +		unsigned	bus_number	: 8;		/* 23 .. 16 */
> +		unsigned	devfn_number	: 8;		/* 15 .. 8  */
> +		unsigned	register_number	: 8;		/* 7  .. 0  */
> +#endif

For this kind of endianess dependency there is a more elegant way of
defining things in linux-next's <uapi/asm/bitfield.h> like:

#include <uapi/asm/bitfield.h>
...

struct {
	__BITFIELD_FIELD(unsigned	enable_bit	: 1,		/* 31       */
	__BITFIELD_FIELD(unsigned	reserved	: 7,		/* 30 .. 24 */
	__BITFIELD_FIELD(unsigned	bus_number	: 8,		/* 23 .. 16 */
	__BITFIELD_FIELD(unsigned	devfn_number	: 8,		/* 15 .. 8  */
	__BITFIELD_FIELD(unsigned	register_number	: 8,		/* 7  .. 0  */
	)))));
};

No ifdef, no duplication!

  Ralf


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux