Skip to content

Commit f2f2efb

Browse files
westeridavem330
authored andcommitted
byteorder: Move {cpu_to_be32, be32_to_cpu}_array() from Thunderbolt to core
We will be using these when communicating XDomain discovery protocol over Thunderbolt link but they might be useful for other drivers as well. Make them available through byteorder/generic.h. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Michael Jamet <michael.jamet@intel.com> Reviewed-by: Yehezkel Bernat <yehezkel.bernat@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1dd236f commit f2f2efb

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

‎drivers/thunderbolt/ctl.c‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,6 @@ static void tb_cfg_print_error(struct tb_ctl *ctl,
289289
}
290290
}
291291

292-
static void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
293-
{
294-
int i;
295-
for (i = 0; i < len; i++)
296-
dst[i] = cpu_to_be32(src[i]);
297-
}
298-
299-
static void be32_to_cpu_array(u32 *dst, __be32 *src, size_t len)
300-
{
301-
int i;
302-
for (i = 0; i < len; i++)
303-
dst[i] = be32_to_cpu(src[i]);
304-
}
305-
306292
static __be32 tb_crc(const void *data, size_t len)
307293
{
308294
return cpu_to_be32(~__crc32c_le(~0, data, len));

‎include/linux/byteorder/generic.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,20 @@ static inline void be64_add_cpu(__be64 *var, u64 val)
170170
*var = cpu_to_be64(be64_to_cpu(*var) + val);
171171
}
172172

173+
static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
174+
{
175+
int i;
176+
177+
for (i = 0; i < len; i++)
178+
dst[i] = cpu_to_be32(src[i]);
179+
}
180+
181+
static inline void be32_to_cpu_array(u32 *dst, const __be32 *src, size_t len)
182+
{
183+
int i;
184+
185+
for (i = 0; i < len; i++)
186+
dst[i] = be32_to_cpu(src[i]);
187+
}
188+
173189
#endif /* _LINUX_BYTEORDER_GENERIC_H */

0 commit comments

Comments
 (0)