Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes...
[firefly-linux-kernel-4.4.55.git] / include / asm-avr32 / unaligned.h
index 791361786fcc6b40c9a39b7a291e95107a7e8648..041877290470f18b3867234e9ff3459d97df8d28 100644 (file)
@@ -1,36 +1,21 @@
-#ifndef __ASM_AVR32_UNALIGNED_H
-#define __ASM_AVR32_UNALIGNED_H
+#ifndef _ASM_AVR32_UNALIGNED_H
+#define _ASM_AVR32_UNALIGNED_H
 
 /*
  * AVR32 can handle some unaligned accesses, depending on the
  * implementation.  The AVR32 AP implementation can handle unaligned
  * words, but halfwords must be halfword-aligned, and doublewords must
  * be word-aligned.
+ *
+ * However, swapped word loads must be word-aligned so we can't
+ * optimize word loads in general.
  */
 
-#include <asm-generic/unaligned.h>
+#include <linux/unaligned/be_struct.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <linux/unaligned/generic.h>
 
-#ifdef CONFIG_CPU_AT32AP7000
+#define get_unaligned  __get_unaligned_be
+#define put_unaligned  __put_unaligned_be
 
-/* REVISIT calling memmove() may be smaller for 64-bit values ... */
-
-#undef get_unaligned
-#define get_unaligned(ptr) \
-       ___get_unaligned(ptr, sizeof((*ptr)))
-#define ___get_unaligned(ptr, size) \
-       ((size == 4) ? *(ptr) : __get_unaligned(ptr, size))
-
-#undef put_unaligned
-#define put_unaligned(val, ptr) \
-       ___put_unaligned((__u64)(val), ptr, sizeof((*ptr)))
-#define ___put_unaligned(val, ptr, size)               \
-do {                                                   \
-       if (size == 4)                                  \
-               *(ptr) = (val);                         \
-       else                                            \
-               __put_unaligned(val, ptr, size);        \
-} while (0)
-
-#endif
-
-#endif /* __ASM_AVR32_UNALIGNED_H */
+#endif /* _ASM_AVR32_UNALIGNED_H */