linux-mips
[Top] [All Lists]

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

To: Aaro Koskinen <aaro.koskinen@iki.fi>
Subject: Re: [PATCH 3/6] staging: octeon-usb: cvmx-usbcx-defs.h: avoid long lines in CVMX_USBCX macros
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 5 Jun 2013 11:36:46 +0300
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, devel@driverdev.osuosl.org, linux-mips@linux-mips.org, linux-usb@vger.kernel.org
In-reply-to: <1370381495-3358-4-git-send-email-aaro.koskinen@iki.fi>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1370381495-3358-1-git-send-email-aaro.koskinen@iki.fi> <1370381495-3358-4-git-send-email-aaro.koskinen@iki.fi>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.21 (2010-09-15)
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



<Prev in Thread] Current Thread [Next in Thread>