From: Harvey Harrison <harvey.harrison@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Bryan Wu <cooloney@kernel.org>, Jie Zhang <jie.zhang@analog.com>,
Oliver Neukum <oliver@neukum.org>,
david-b@pacbell.net, greg@kroah.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: [RFC-PATCH] lib: add byteorder helpers for the aligned case
Date: Fri, 16 May 2008 11:09:45 -0700 [thread overview]
Message-ID: <1210961386.5915.43.camel@brick> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0805161021450.25035-100000@netrider.rowland.org>
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@gmail.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
next prev parent reply other threads:[~2008-05-16 18:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-15 6:19 [PATCH 1/1] [usb/host]: use get/put_unaligned_* helpers to fix more potential unaligned issues Bryan Wu
2008-05-15 7:40 ` Oliver Neukum
2008-05-15 8:03 ` Jie Zhang
2008-05-15 8:09 ` Bryan Wu
2008-05-15 8:36 ` Oliver Neukum
2008-05-15 9:15 ` Jie Zhang
2008-05-15 9:54 ` Bryan Wu
2008-05-15 12:19 ` Oliver Neukum
2008-05-15 13:03 ` David Brownell
2008-05-15 13:27 ` Oliver Neukum
2008-05-15 14:28 ` Alan Stern
2008-05-16 0:33 ` [PATCH] usb: file-storage.c use unaligned access helpers Harvey Harrison
2008-05-16 14:32 ` Alan Stern
2008-05-16 18:09 ` Harvey Harrison [this message]
2008-05-17 0:35 ` [RFC-PATCH] lib: add byteorder helpers for the aligned case Alan Stern
2008-05-17 0:37 ` Harvey Harrison
2008-05-15 15:37 ` [PATCH 1/1] [usb/host]: use get/put_unaligned_* helpers to fix more potential unaligned issues Harvey Harrison
2008-05-16 0:05 ` Andrew Morton
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=1210961386.5915.43.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cooloney@kernel.org \
--cc=david-b@pacbell.net \
--cc=greg@kroah.com \
--cc=jie.zhang@analog.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oliver@neukum.org \
--cc=stern@rowland.harvard.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.