[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1210961386.5915.43.camel@brick>
Date: Fri, 16 May 2008 11:09:45 -0700
From: Harvey Harrison <harvey.harrison@...il.com>
To: Alan Stern <stern@...land.harvard.edu>
Cc: Bryan Wu <cooloney@...nel.org>, Jie Zhang <jie.zhang@...log.com>,
Oliver Neukum <oliver@...kum.org>, david-b@...bell.net,
greg@...ah.com, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>
Subject: [RFC-PATCH] lib: add byteorder helpers for the aligned case
Some users know the pointer they are writing to are aligned,
rather than doing *(__le16 *)ptr = cpu_to_le16(val) add helpers
wrapping this up that have the same convention as put_unaligned_le/be.
Signed-off-by: Harvey Harrison <harvey.harrison@...il.com>
---
Alan, as requested, I'm looking around a bit to see if there are actual
users for this. But it does make a nice complement to the unaligned
versions.
include/linux/byteorder/generic.h | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
index 0846e6b..38ff3e6 100644
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -119,6 +119,36 @@
#define cpu_to_be16s __cpu_to_be16s
#define be16_to_cpus __be16_to_cpus
+static inline void put_le16(u16 val, void *ptr)
+{
+ *(__le16 *)ptr = cpu_to_le16(val);
+}
+
+static inline void put_le32(u32 val, void *ptr)
+{
+ *(__le32 *)ptr = cpu_to_le32(val);
+}
+
+static inline void put_le64(u64 val, void *ptr)
+{
+ *(__le64 *)ptr = cpu_to_le64(val);
+}
+
+static inline void put_be16(u16 val, void *ptr)
+{
+ *(__be16 *)ptr = cpu_to_be16(val);
+}
+
+static inline void put_be32(u32 val, void *ptr)
+{
+ *(__be32 *)ptr = cpu_to_be32(val);
+}
+
+static inline void put_be64(u64 val, void *ptr)
+{
+ *(__be64 *)ptr = cpu_to_be64(val);
+}
+
/*
* They have to be macros in order to do the constant folding
* correctly - if the argument passed into a inline function
--
1.5.5.1.570.g26b5e
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists