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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce cpu_to_le16_array() and le16_to_cpu_array() for existing and
future users.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Cc: Anton Sviridenko <anton@xxxxxxxxxxxxxxxxxxx>
Cc: Andrey Utkin <andrey.utkin@xxxxxxxxxxxxxxxxxxx>
Cc: Ismael Luceno <ismael@xxxxxxxxxxx>
Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
Cc: Jussi Kivilinna <jussi.kivilinna@xxxxxx>
Cc: Kalle Valo <kvalo@xxxxxxxxxxxxxx>
Cc: Jeff Kirsher <jeffrey.t.kirsher@xxxxxxxxx>
Cc: Sylwia Wnuczko <sylwia.wnuczko@xxxxxxxxx>
Cc: Jesse Brandeburg <jesse.brandeburg@xxxxxxxxx>
---
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(+)

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)
 {
-- 
2.28.0




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux