devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laxman Dewangan <ldewangan@nvidia.com>
To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
	grant.likely@linaro.org
Cc: ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	swarren@nvidia.com, kerwinw@nvidia.com,
	Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 2/2] dt-binding: add header to define types and conversion
Date: Thu, 12 Dec 2013 18:54:53 +0530	[thread overview]
Message-ID: <1386854693-10871-2-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1386854693-10871-1-git-send-email-ldewangan@nvidia.com>

Add a header file to define the macros for type conversion
to be used by DTS file.

Add macro for the S32 to U32 conversion by using 2's complement.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 include/dt-bindings/types.h |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
 create mode 100644 include/dt-bindings/types.h

diff --git a/include/dt-bindings/types.h b/include/dt-bindings/types.h
new file mode 100644
index 0000000..2b7ea75
--- /dev/null
+++ b/include/dt-bindings/types.h
@@ -0,0 +1,18 @@
+/*
+ * This header provides macros for different types and conversions
+ */
+
+#ifndef _DT_BINDINGS_TYPES_H_
+#define _DT_BINDINGS_TYPES_H_
+
+/*
+ * S32_TO_U32: This macro converts the signed number to 2's complement
+ * unisgned number. E.g. S32_TO_U32(-3) will be 0xfffffffd and
+ * S32_TO_U32(3) will be 0x3;
+ * Use of_property_read_s32() for getting back the correct signed value
+ * in driver.
+ */
+#define S32_TO_U32(x) (((x) < 0) ? (((-(x)) ^ 0xFFFFFFFFU) + 1) : (x))
+
+#endif
+
-- 
1.7.0.4

  reply	other threads:[~2013-12-12 13:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12 13:24 [PATCH 1/2] of: add support for reading s32 property value Laxman Dewangan
2013-12-12 13:24 ` Laxman Dewangan [this message]
2013-12-12 18:01 ` Stephen Warren
     [not found]   ` <52A9FA00.7080506-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-12-13  6:32     ` Laxman Dewangan

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=1386854693-10871-2-git-send-email-ldewangan@nvidia.com \
    --to=ldewangan@nvidia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=grant.likely@linaro.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kerwinw@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=swarren@nvidia.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;
as well as URLs for NNTP newsgroup(s).