[PATCH 3/6] staging: octeon-usb: cvmx-usbcx-defs.h: avoid long lines in CVMX_USBCX macros

Dan Carpenter dan.carpenter at oracle.com
Wed Jun 5 08:36:46 UTC 2013


On Wed, Jun 05, 2013 at 12:31:32AM +0300, Aaro Koskinen wrote:
> -#define CVMX_USBCX_DAINT(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000818ull) + ((block_id) & 1) * 0x100000000000ull)

There should be a few helper macros.  I don't know the names for
these:
#define bid_to_xxx1(block_id) ((block_id) & 1) ? 0x100000000000ull : 0)
#define bid_to_xxx4(block_id) ((block_id) & 1) ? 0x40000000000ull : 0)
#define bid_to_xxx8(block_id) ((block_id) & 1) ? 0x8000000000ull : 0)

#define SEG_PREFIX 0x00016F001000ull << 15
#define CVMX_ADD(addr) CVMX_ADD_IO_SEG(SEG_PREFIX | (addr))

Then CVMX_USBCX_DAINTMSK() becomes:

#define CVMX_USBCX_DAINT(block_id) (CVMX_ADD(0x0818) + bid_to_xxx1(block_id))

It fits on one line and it uses words instead of magic numbers.

regards,
dan carpenter





More information about the devel mailing list