[PATCH V3] MIPS: Fix longstanding errors in div64.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are four errors in div64.h caused by commit c21004cd5b4cb7d479514
("MIPS: Rewrite <asm/div64.h> to work with gcc 4.4.0."):

1, Only 32bit kernel need __div64_32(), but the above commit makes it
   depend on 64bit kernel by mistake.

2, asm-generic/div64.h should be included after __div64_32() definition.

3, __n should be initialized as *n before use (and "*__n >> 32" should
   be "__n >> 32") in __div64_32() definition.

4, linux/types.h should be included at the first place, otherwise BITS_
   PER_LONG is not defined.

Fixes: c21004cd5b4cb7d479514 ("MIPS: Rewrite <asm/div64.h> to work with gcc 4.4.0.")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Huacai Chen <chenhuacai@xxxxxxxxxxx>
---
 arch/mips/include/asm/div64.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/mips/include/asm/div64.h b/arch/mips/include/asm/div64.h
index dc5ea5736440..d827c13c3bc5 100644
--- a/arch/mips/include/asm/div64.h
+++ b/arch/mips/include/asm/div64.h
@@ -9,12 +9,10 @@
 #ifndef __ASM_DIV64_H
 #define __ASM_DIV64_H
 
-#include <asm-generic/div64.h>
-
-#if BITS_PER_LONG == 64
-
 #include <linux/types.h>
 
+#if BITS_PER_LONG == 32
+
 /*
  * No traps on overflows for any of these...
  */
@@ -24,9 +22,9 @@
 	unsigned long __cf, __tmp, __tmp2, __i;				\
 	unsigned long __quot32, __mod32;				\
 	unsigned long __high, __low;					\
-	unsigned long long __n;						\
+	unsigned long long __n = *n;					\
 									\
-	__high = *__n >> 32;						\
+	__high = __n >> 32;						\
 	__low = __n;							\
 	__asm__(							\
 	"	.set	push					\n"	\
@@ -63,6 +61,8 @@
 	__mod32;							\
 })
 
-#endif /* BITS_PER_LONG == 64 */
+#endif /* BITS_PER_LONG == 32 */
+
+#include <asm-generic/div64.h>
 
 #endif /* __ASM_DIV64_H */
-- 
2.27.0




[Index of Archives]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux