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