public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Eric Miao <eric.miao@linaro.org>
Cc: Richard Zhao <richard.zhao@linaro.org>,
	patches@linaro.org, vinod.koul@intel.com,
	linux-kernel@vger.kernel.org, kernel@pengutronix.de,
	dan.j.williams@intel.com, shawn.guo@linaro.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 2/2] dma/imx-sdma: convert _raw_readl/_raw_writel to readl/writel
Date: Mon, 9 Jan 2012 14:12:14 +0000	[thread overview]
Message-ID: <20120109141214.GP21765@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CAMPhdO84p=0D3KrrFnwup4igoh4oNWXOCbW+BOkoRiC8m=JnmQ@mail.gmail.com>

On Mon, Jan 09, 2012 at 09:25:12PM +0800, Eric Miao wrote:
> Does this also mean when endian conversion is not necessary, the __raw_*
> version will be better here? Or generally the _relaxed variants are more
> recommended as endian conversion will be optimized away anyway with
> these AMBA accesses as both sides are little-endian?

Useless endian conversions are always optimized away.  Here's the
definitions:

If your CPU is operating in little endian mode, for 32-bit and 16-bit:

#define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
#define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))

So these are just casts to keep sparse happy and able to check this stuff.

#define __cpu_to_be32(x) ((__force __be32)__swab32((x)))
#define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
#define __cpu_to_be16(x) ((__force __be16)__swab16((x)))
#define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))

These do the endian conversion.

If your CPU is running in big endian mode:

#define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
#define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))

So these do the endian conversion, and:

#define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
#define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
#define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
#define __be16_to_cpu(x) ((__force __u16)(__be16)(x))

These are just casts.

  reply	other threads:[~2012-01-09 14:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-08 14:44 [PATCH v4 0/2] mx-sdma: memory barrier fix Richard Zhao
2012-01-08 14:44 ` [PATCH v4 1/2] dma/imx-sdma: let sdma_run_channel call sdma_enable_channel Richard Zhao
2012-01-08 14:44 ` [PATCH v4 2/2] dma/imx-sdma: convert _raw_readl/_raw_writel to readl/writel Richard Zhao
2012-01-09  1:22   ` Shawn Guo
2012-01-09 11:51   ` Russell King - ARM Linux
2012-01-09 13:25     ` Eric Miao
2012-01-09 14:12       ` Russell King - ARM Linux [this message]
2012-01-09 14:21     ` Richard Zhao
2012-01-09 14:46       ` Russell King - ARM Linux
2012-01-09 15:02         ` Richard Zhao
2012-01-09  9:33 ` [PATCH v4 0/2] mx-sdma: memory barrier fix Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120109141214.GP21765@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=dan.j.williams@intel.com \
    --cc=eric.miao@linaro.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=richard.zhao@linaro.org \
    --cc=shawn.guo@linaro.org \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox