diff mbox series

[v2,1/8] byteorder: Introduce cpu_to_le16_array() and le16_to_cpu_array()

Message ID 20200817184659.58419-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/8] byteorder: Introduce cpu_to_le16_array() and le16_to_cpu_array() | expand

Commit Message

Andy Shevchenko Aug. 17, 2020, 6:46 p.m. UTC
Introduce cpu_to_le16_array() and le16_to_cpu_array() for existing and
future users.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Anton Sviridenko <anton@corp.bluecherry.net>
Cc: Andrey Utkin <andrey.utkin@corp.bluecherry.net>
Cc: Ismael Luceno <ismael@iodev.co.uk>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: Sylwia Wnuczko <sylwia.wnuczko@intel.com>
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
---
v2: split out of the USB patch

The idea, how I see it, is to push entire series via USB tree as a main
target of it. The immutable branch can be used for others to pick up.
Of course maintainers can propose better approach.

 include/linux/byteorder/generic.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Andy Shevchenko Aug. 18, 2020, 8:01 a.m. UTC | #1
On Mon, Aug 17, 2020 at 09:46:52PM +0300, Andy Shevchenko wrote:
> Introduce cpu_to_le16_array() and le16_to_cpu_array() for existing and
> future users.

It appears that the series needs more work. Please, discard this and at some
point I'll send v3.
diff mbox series

Patch

diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
index 4b13e0a3e15b..24904ad79df0 100644
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -156,6 +156,22 @@  static inline void le64_add_cpu(__le64 *var, u64 val)
 	*var = cpu_to_le64(le64_to_cpu(*var) + val);
 }
 
+static inline void cpu_to_le16_array(__le16 *dst, const u16 *src, size_t len)
+{
+	int i;
+
+	for (i = 0; i < len; i++)
+		dst[i] = cpu_to_le16(src[i]);
+}
+
+static inline void le16_to_cpu_array(u16 *dst, const __le16 *src, size_t len)
+{
+	int i;
+
+	for (i = 0; i < len; i++)
+		dst[i] = le16_to_cpu(src[i]);
+}
+
 /* XXX: this stuff can be optimized */
 static inline void le32_to_cpu_array(u32 *buf, unsigned int words)
 {