18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci#ifndef _M68K_SWAB_H
38c2ecf20Sopenharmony_ci#define _M68K_SWAB_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/types.h>
68c2ecf20Sopenharmony_ci#include <linux/compiler.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#define __SWAB_64_THRU_32__
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#if defined (__mcfisaaplus__) || defined (__mcfisac__)
118c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u32 __arch_swab32(__u32 val)
128c2ecf20Sopenharmony_ci{
138c2ecf20Sopenharmony_ci	__asm__("byterev %0" : "=d" (val) : "0" (val));
148c2ecf20Sopenharmony_ci	return val;
158c2ecf20Sopenharmony_ci}
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define __arch_swab32 __arch_swab32
188c2ecf20Sopenharmony_ci#elif !defined(__mcoldfire__)
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u32 __arch_swab32(__u32 val)
218c2ecf20Sopenharmony_ci{
228c2ecf20Sopenharmony_ci	__asm__("rolw #8,%0; swap %0; rolw #8,%0" : "=d" (val) : "0" (val));
238c2ecf20Sopenharmony_ci	return val;
248c2ecf20Sopenharmony_ci}
258c2ecf20Sopenharmony_ci#define __arch_swab32 __arch_swab32
268c2ecf20Sopenharmony_ci#endif
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#endif /* _M68K_SWAB_H */
29