swab: Add array operations
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 31 Aug 2022 21:27:42 +0000 (00:27 +0300)
committerMark Brown <broonie@kernel.org>
Wed, 7 Sep 2022 11:42:25 +0000 (12:42 +0100)
For now, some simple array operations to swab.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220831212744.56435-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/linux/swab.h

index bcff514..9b804db 100644 (file)
 # define swab64s __swab64s
 # define swahw32s __swahw32s
 # define swahb32s __swahb32s
+
+static inline void swab16_array(u16 *buf, unsigned int words)
+{
+       while (words--) {
+               swab16s(buf);
+               buf++;
+       }
+}
+
+static inline void swab32_array(u32 *buf, unsigned int words)
+{
+       while (words--) {
+               swab32s(buf);
+               buf++;
+       }
+}
+
+static inline void swab64_array(u64 *buf, unsigned int words)
+{
+       while (words--) {
+               swab64s(buf);
+               buf++;
+       }
+}
+
 #endif /* _LINUX_SWAB_H */