SHARE
TWEET

Untitled

a guest Sep 6th, 2017 502 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. commit a2ec6252e4640b573e0db795cd484df73a46b246
  2. Author: Arnd Bergmann <arnd@arndb.de>
  3. Date:   Fri Mar 4 16:15:20 2016 +0100
  4.  
  5.     asm-generic: always use struct based unaligned access
  6.    
  7.     Signed-off-by: Arnd Bergmann <arnd@arndb.de>
  8.  
  9. diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h
  10. index 1ac097279db1..e8f5523eeb0a 100644
  11. --- a/include/asm-generic/unaligned.h
  12. +++ b/include/asm-generic/unaligned.h
  13. @@ -3,29 +3,19 @@
  14.  
  15.  /*
  16.   * This is the most generic implementation of unaligned accesses
  17. - * and should work almost anywhere.
  18. + * and should work almost anywhere, we trust that the compiler
  19. + * knows how to handle unaligned accesses.
  20.   */
  21.  #include <asm/byteorder.h>
  22.  
  23. -/* Set by the arch if it can handle unaligned accesses in hardware. */
  24. -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
  25. -# include <linux/unaligned/access_ok.h>
  26. -#endif
  27. +#include <linux/unaligned/le_struct.h>
  28. +#include <linux/unaligned/be_struct.h>
  29. +#include <linux/unaligned/generic.h>
  30.  
  31.  #if defined(__LITTLE_ENDIAN)
  32. -# ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
  33. -#  include <linux/unaligned/le_struct.h>
  34. -#  include <linux/unaligned/be_byteshift.h>
  35. -# endif
  36. -# include <linux/unaligned/generic.h>
  37.  # define get_unaligned __get_unaligned_le
  38.  # define put_unaligned __put_unaligned_le
  39.  #elif defined(__BIG_ENDIAN)
  40. -# ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
  41. -#  include <linux/unaligned/be_struct.h>
  42. -#  include <linux/unaligned/le_byteshift.h>
  43. -# endif
  44. -# include <linux/unaligned/generic.h>
  45.  # define get_unaligned __get_unaligned_be
  46.  # define put_unaligned __put_unaligned_be
  47.  #else
  48. diff --git a/include/linux/unaligned/be_struct.h b/include/linux/unaligned/be_struct.h
  49. index 132415836c50..9ab8c53bb3fe 100644
  50. --- a/include/linux/unaligned/be_struct.h
  51. +++ b/include/linux/unaligned/be_struct.h
  52. @@ -2,35 +2,36 @@
  53.  #define _LINUX_UNALIGNED_BE_STRUCT_H
  54.  
  55.  #include <linux/unaligned/packed_struct.h>
  56. +#include <asm/byteorder.h>
  57.  
  58.  static inline u16 get_unaligned_be16(const void *p)
  59.  {
  60. -   return __get_unaligned_cpu16((const u8 *)p);
  61. +   return be16_to_cpu((__le16 __force)__get_unaligned_cpu16((const u8 *)p));
  62.  }
  63.  
  64.  static inline u32 get_unaligned_be32(const void *p)
  65.  {
  66. -   return __get_unaligned_cpu32((const u8 *)p);
  67. +   return be32_to_cpu((__le32 __force)__get_unaligned_cpu32((const u8 *)p));
  68.  }
  69.  
  70.  static inline u64 get_unaligned_be64(const void *p)
  71.  {
  72. -   return __get_unaligned_cpu64((const u8 *)p);
  73. +   return be64_to_cpu((__le64 __force)__get_unaligned_cpu64((const u8 *)p));
  74.  }
  75.  
  76.  static inline void put_unaligned_be16(u16 val, void *p)
  77.  {
  78. -   __put_unaligned_cpu16(val, p);
  79. +   __put_unaligned_cpu16((u16 __force)cpu_to_be16(val), p);
  80.  }
  81.  
  82.  static inline void put_unaligned_be32(u32 val, void *p)
  83.  {
  84. -   __put_unaligned_cpu32(val, p);
  85. +   __put_unaligned_cpu32((u32 __force)cpu_to_be32(val), p);
  86.  }
  87.  
  88.  static inline void put_unaligned_be64(u64 val, void *p)
  89.  {
  90. -   __put_unaligned_cpu64(val, p);
  91. +   __put_unaligned_cpu64((u64 __force)cpu_to_be64(val), p);
  92.  }
  93.  
  94.  #endif /* _LINUX_UNALIGNED_BE_STRUCT_H */
  95. diff --git a/include/linux/unaligned/le_struct.h b/include/linux/unaligned/le_struct.h
  96. index 088c4572faa8..64171ad0b100 100644
  97. --- a/include/linux/unaligned/le_struct.h
  98. +++ b/include/linux/unaligned/le_struct.h
  99. @@ -2,35 +2,36 @@
  100.  #define _LINUX_UNALIGNED_LE_STRUCT_H
  101.  
  102.  #include <linux/unaligned/packed_struct.h>
  103. +#include <asm/byteorder.h>
  104.  
  105.  static inline u16 get_unaligned_le16(const void *p)
  106.  {
  107. -   return __get_unaligned_cpu16((const u8 *)p);
  108. +   return le16_to_cpu((__le16 __force)__get_unaligned_cpu16((const u8 *)p));
  109.  }
  110.  
  111.  static inline u32 get_unaligned_le32(const void *p)
  112.  {
  113. -   return __get_unaligned_cpu32((const u8 *)p);
  114. +   return le32_to_cpu((__le32 __force)__get_unaligned_cpu32((const u8 *)p));
  115.  }
  116.  
  117.  static inline u64 get_unaligned_le64(const void *p)
  118.  {
  119. -   return __get_unaligned_cpu64((const u8 *)p);
  120. +   return le64_to_cpu((__le64 __force)__get_unaligned_cpu64((const u8 *)p));
  121.  }
  122.  
  123.  static inline void put_unaligned_le16(u16 val, void *p)
  124.  {
  125. -   __put_unaligned_cpu16(val, p);
  126. +   __put_unaligned_cpu16((u16 __force)cpu_to_le16(val), p);
  127.  }
  128.  
  129.  static inline void put_unaligned_le32(u32 val, void *p)
  130.  {
  131. -   __put_unaligned_cpu32(val, p);
  132. +   __put_unaligned_cpu32((u32 __force)cpu_to_le32(val), p);
  133.  }
  134.  
  135.  static inline void put_unaligned_le64(u64 val, void *p)
  136.  {
  137. -   __put_unaligned_cpu64(val, p);
  138. +   __put_unaligned_cpu64((u64 __force)cpu_to_le64(val), p);
  139.  }
  140.  
  141.  #endif /* _LINUX_UNALIGNED_LE_STRUCT_H */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top