microblaze: delay.h fix udelay and ndelay for 8 bit args
authorMichal Simek <michal.simek@xilinx.com>
Wed, 9 Jul 2014 11:23:55 +0000 (13:23 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 9 Jul 2014 11:24:50 +0000 (13:24 +0200)
Based on:
"asm-generic: delay.h fix udelay and ndelay for 8 bit args"
(sha1: a87e553fabe8ceadc6f90889066559234cf194c7)

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/microblaze/include/asm/delay.h

index 66fc24c24238f64cac057fa33e9b330af10867e3..60cb39deb533975c690f4f47240e1e9c7cd2d68c 100644 (file)
@@ -61,13 +61,29 @@ extern inline void __udelay(unsigned int x)
 extern void __bad_udelay(void);                /* deliberately undefined */
 extern void __bad_ndelay(void);                /* deliberately undefined */
 
-#define udelay(n) (__builtin_constant_p(n) ? \
-       ((n) > __MAX_UDELAY ? __bad_udelay() : __udelay((n) * (19 * HZ))) : \
-       __udelay((n) * (19 * HZ)))
+#define udelay(n)                                              \
+       ({                                                      \
+               if (__builtin_constant_p(n)) {                  \
+                       if ((n) / __MAX_UDELAY >= 1)            \
+                               __bad_udelay();                 \
+                       else                                    \
+                               __udelay((n) * (19 * HZ));      \
+               } else {                                        \
+                       __udelay((n) * (19 * HZ));              \
+               }                                               \
+       })
 
-#define ndelay(n) (__builtin_constant_p(n) ? \
-       ((n) > __MAX_NDELAY ? __bad_ndelay() : __udelay((n) * HZ)) : \
-       __udelay((n) * HZ))
+#define ndelay(n)                                              \
+       ({                                                      \
+               if (__builtin_constant_p(n)) {                  \
+                       if ((n) / __MAX_NDELAY >= 1)            \
+                               __bad_ndelay();                 \
+                       else                                    \
+                               __udelay((n) * HZ);             \
+               } else {                                        \
+                       __udelay((n) * HZ);                     \
+               }                                               \
+       })
 
 #define muldiv(a, b, c)                (((a)*(b))/(c))