Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2f2efb8 authored by Mika Westerberg's avatar Mika Westerberg Committed by David S. Miller
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: default avatarMichael Jamet <michael.jamet@intel.com>
Reviewed-by: default avatarYehezkel Bernat <yehezkel.bernat@intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1dd236fd
Loading
Loading
Loading
Loading
+0 −14
Original line number Original line Diff line number Diff line
@@ -289,20 +289,6 @@ static void tb_cfg_print_error(struct tb_ctl *ctl,
	}
	}
}
}


static void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
{
	int i;
	for (i = 0; i < len; i++)
		dst[i] = cpu_to_be32(src[i]);
}

static void be32_to_cpu_array(u32 *dst, __be32 *src, size_t len)
{
	int i;
	for (i = 0; i < len; i++)
		dst[i] = be32_to_cpu(src[i]);
}

static __be32 tb_crc(const void *data, size_t len)
static __be32 tb_crc(const void *data, size_t len)
{
{
	return cpu_to_be32(~__crc32c_le(~0, data, len));
	return cpu_to_be32(~__crc32c_le(~0, data, len));
+16 −0
Original line number Original line Diff line number Diff line
@@ -170,4 +170,20 @@ static inline void be64_add_cpu(__be64 *var, u64 val)
	*var = cpu_to_be64(be64_to_cpu(*var) + val);
	*var = cpu_to_be64(be64_to_cpu(*var) + val);
}
}


static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
{
	int i;

	for (i = 0; i < len; i++)
		dst[i] = cpu_to_be32(src[i]);
}

static inline void be32_to_cpu_array(u32 *dst, const __be32 *src, size_t len)
{
	int i;

	for (i = 0; i < len; i++)
		dst[i] = be32_to_cpu(src[i]);
}

#endif /* _LINUX_BYTEORDER_GENERIC_H */
#endif /* _LINUX_BYTEORDER_GENERIC_H */