lkml.org 
[lkml]   [2013]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] dt-binding: add header to define types and conversion
Date
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


\
 
 \ /
  Last update: 2013-12-12 15:21    [W:0.038 / U:0.744 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site