Skip to content

Commit 2d46973

Browse files
andy-shevbroonie
authored andcommitted
swab: Add array operations
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>
1 parent 6ed406e commit 2d46973

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

include/linux/swab.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,29 @@
2020
# define swab64s __swab64s
2121
# define swahw32s __swahw32s
2222
# define swahb32s __swahb32s
23+
24+
static inline void swab16_array(u16 *buf, unsigned int words)
25+
{
26+
while (words--) {
27+
swab16s(buf);
28+
buf++;
29+
}
30+
}
31+
32+
static inline void swab32_array(u32 *buf, unsigned int words)
33+
{
34+
while (words--) {
35+
swab32s(buf);
36+
buf++;
37+
}
38+
}
39+
40+
static inline void swab64_array(u64 *buf, unsigned int words)
41+
{
42+
while (words--) {
43+
swab64s(buf);
44+
buf++;
45+
}
46+
}
47+
2348
#endif /* _LINUX_SWAB_H */

0 commit comments

Comments
 (0)