Merge commit 'origin/master' into next
[pandora-kernel.git] / arch / blackfin / include / asm / bug.h
1 #ifndef _BLACKFIN_BUG_H
2 #define _BLACKFIN_BUG_H
3
4 #ifdef CONFIG_BUG
5
6 #define BFIN_BUG_OPCODE 0xefcd
7
8 #ifdef CONFIG_DEBUG_BUGVERBOSE
9
10 #define _BUG_OR_WARN(flags)                                             \
11         asm volatile(                                                   \
12                 "1:     .hword  %0\n"                                   \
13                 "       .section __bug_table,\"a\",@progbits\n"         \
14                 "2:     .long   1b\n"                                   \
15                 "       .long   %1\n"                                   \
16                 "       .short  %2\n"                                   \
17                 "       .short  %3\n"                                   \
18                 "       .org    2b + %4\n"                              \
19                 "       .previous"                                      \
20                 :                                                       \
21                 : "i"(BFIN_BUG_OPCODE), "i"(__FILE__),                  \
22                   "i"(__LINE__), "i"(flags),                            \
23                   "i"(sizeof(struct bug_entry)))
24
25 #else
26
27 #define _BUG_OR_WARN(flags)                                             \
28         asm volatile(                                                   \
29                 "1:     .hword  %0\n"                                   \
30                 "       .section __bug_table,\"a\",@progbits\n"         \
31                 "2:     .long   1b\n"                                   \
32                 "       .short  %1\n"                                   \
33                 "       .org    2b + %2\n"                              \
34                 "       .previous"                                      \
35                 :                                                       \
36                 : "i"(BFIN_BUG_OPCODE), "i"(flags),                     \
37                   "i"(sizeof(struct bug_entry)))
38
39 #endif /* CONFIG_DEBUG_BUGVERBOSE */
40
41 #define BUG()                                                           \
42         do {                                                            \
43                 _BUG_OR_WARN(0);                                        \
44                 for (;;);                                               \
45         } while (0)
46
47 #define WARN_ON(condition)                                                      \
48         ({                                                              \
49                 int __ret_warn_on = !!(condition);                      \
50                 if (unlikely(__ret_warn_on))                            \
51                         _BUG_OR_WARN(BUGFLAG_WARNING);                  \
52                 unlikely(__ret_warn_on);                                \
53         })
54
55 #define HAVE_ARCH_BUG
56 #define HAVE_ARCH_WARN_ON
57
58 #endif
59
60 #include <asm-generic/bug.h>
61
62 #endif