linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomas Winkler <tomas.winkler-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org
Cc: arnd-r2nGTMty4D4@public.gmane.org,
	Stephen Rothwell <sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org>,
	Tomas Winkler
	<tomas.winkler-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [char-misc-next 04/11 V2] uuid: extract macros for assigning raw arrays
Date: Wed, 27 May 2015 18:42:13 +0300	[thread overview]
Message-ID: <1432741333-11889-1-git-send-email-tomas.winkler@intel.com> (raw)

In order for mei client devices to use device id based on uuid we
have to use common types between user space (file2alias.c).
Similarly to vmbus,  mei  uses raw 16 byte array for that. 
To leverage on existing infrastructure around uuid_le type 
defined in uuid.h we add helper macros to handle conversions between
raw 16 byte array and uuid_{le,be} types.

Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org 
Signed-off-by: Tomas Winkler <tomas.winkler-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
V2: be verbose in the commit message 
 include/uapi/linux/uuid.h | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/include/uapi/linux/uuid.h b/include/uapi/linux/uuid.h
index 786f0773cc33..487f098c8517 100644
--- a/include/uapi/linux/uuid.h
+++ b/include/uapi/linux/uuid.h
@@ -32,27 +32,34 @@ typedef struct {
 	__u8 b[16];
 } uuid_be;
 
-#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
-((uuid_le)								\
-{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
-   (b) & 0xff, ((b) >> 8) & 0xff,					\
-   (c) & 0xff, ((c) >> 8) & 0xff,					\
-   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
+#define __UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)                     \
+	{(a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff,\
+	  (b) & 0xff, ((b) >> 8) & 0xff,                                       \
+	  (c) & 0xff, ((c) >> 8) & 0xff,                                       \
+	  (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)}
+
+#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)	\
+	((uuid_le) {__UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)})
+
+#define __UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)                     \
+	{((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff,\
+	  ((b) >> 8) & 0xff, (b) & 0xff,                                       \
+	  ((c) >> 8) & 0xff, (c) & 0xff,                                       \
+	  (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)}
 
 #define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
-((uuid_be)								\
-{{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \
-   ((b) >> 8) & 0xff, (b) & 0xff,					\
-   ((c) >> 8) & 0xff, (c) & 0xff,					\
-   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
+	((uuid_be) {__UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)})
+
+#define __NULL_UUID_LE							\
+	__UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
+		  0x00, 0x00, 0x00, 0x00)
 
-#define NULL_UUID_LE							\
-	UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
-		0x00, 0x00, 0x00, 0x00)
+#define NULL_UUID_LE ((uuid_le) {__NULL_UUID_LE})
 
-#define NULL_UUID_BE							\
-	UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
-		0x00, 0x00, 0x00, 0x00)
+#define __NULL_UUID_BE							\
+	__UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
+		  0x00, 0x00, 0x00, 0x00)
 
+#define NULL_UUID_BE ((uuid_be) {__NULL_UUID_BE})
 
 #endif /* _UAPI_LINUX_UUID_H_ */
-- 
2.1.0

             reply	other threads:[~2015-05-27 15:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 15:42 Tomas Winkler [this message]
     [not found] ` <1432741333-11889-1-git-send-email-tomas.winkler-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-05-27 16:50   ` [char-misc-next 04/11 V2] uuid: extract macros for assigning raw arrays Greg KH
     [not found]     ` <20150527165054.GB3533-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-05-27 17:24       ` Winkler, Tomas
     [not found]         ` <5B8DA87D05A7694D9FA63FD143655C1B3C4A2C8C-Jy8z56yoSI/jxeytcECX8bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-05-27 17:29           ` Greg KH
     [not found]             ` <20150527172919.GA5525-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-05-27 17:42               ` Winkler, Tomas
     [not found]                 ` <5B8DA87D05A7694D9FA63FD143655C1B3C4A2CDF-Jy8z56yoSI/jxeytcECX8bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-05-27 23:14                   ` Greg KH
     [not found]                     ` <20150527231420.GA29446-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-05-27 23:22                       ` Greg KH
     [not found]                         ` <20150527232254.GA8737-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-05-27 23:25                           ` Winkler, Tomas
     [not found]                             ` <5B8DA87D05A7694D9FA63FD143655C1B3C4A3096-Jy8z56yoSI/jxeytcECX8bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-05-28  0:13                               ` Greg KH
2015-05-28  0:17                             ` [PATCH] mei: fix up uuid matching Greg KH
     [not found]                               ` <20150528001727.GB2033-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2015-05-28 14:40                                 ` Stephen Rothwell
     [not found]                                   ` <20150529004045.63dbd39b-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org>
2015-05-28 22:11                                     ` Winkler, Tomas
2015-05-27 23:24                       ` [char-misc-next 04/11 V2] uuid: extract macros for assigning raw arrays Winkler, Tomas

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=1432741333-11889-1-git-send-email-tomas.winkler@intel.com \
    --to=tomas.winkler-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org \
    /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).