hamradio/scc: add missing block braces to multi-statement if
[linux/fpc-iii.git] / drivers / s390 / net / ctcm_dbug.h
blobfdff34fe59a2e994edb39260a89233e3d876f855
1 /*
2 * drivers/s390/net/ctcm_dbug.h
4 * Copyright IBM Corp. 2001, 2007
5 * Authors: Peter Tiedemann (ptiedem@de.ibm.com)
7 */
9 #ifndef _CTCM_DBUG_H_
10 #define _CTCM_DBUG_H_
13 * Debug Facility stuff
16 #include <asm/debug.h>
18 #ifdef DEBUG
19 #define do_debug 1
20 #else
21 #define do_debug 0
22 #endif
23 #ifdef DEBUGDATA
24 #define do_debug_data 1
25 #else
26 #define do_debug_data 0
27 #endif
28 #ifdef DEBUGCCW
29 #define do_debug_ccw 1
30 #else
31 #define do_debug_ccw 0
32 #endif
34 /* define dbf debug levels similar to kernel msg levels */
35 #define CTC_DBF_ALWAYS 0 /* always print this */
36 #define CTC_DBF_EMERG 0 /* system is unusable */
37 #define CTC_DBF_ALERT 1 /* action must be taken immediately */
38 #define CTC_DBF_CRIT 2 /* critical conditions */
39 #define CTC_DBF_ERROR 3 /* error conditions */
40 #define CTC_DBF_WARN 4 /* warning conditions */
41 #define CTC_DBF_NOTICE 5 /* normal but significant condition */
42 #define CTC_DBF_INFO 5 /* informational */
43 #define CTC_DBF_DEBUG 6 /* debug-level messages */
45 DECLARE_PER_CPU(char[256], ctcm_dbf_txt_buf);
47 enum ctcm_dbf_names {
48 CTCM_DBF_SETUP,
49 CTCM_DBF_ERROR,
50 CTCM_DBF_TRACE,
51 CTCM_DBF_MPC_SETUP,
52 CTCM_DBF_MPC_ERROR,
53 CTCM_DBF_MPC_TRACE,
54 CTCM_DBF_INFOS /* must be last element */
57 struct ctcm_dbf_info {
58 char name[DEBUG_MAX_NAME_LEN];
59 int pages;
60 int areas;
61 int len;
62 int level;
63 debug_info_t *id;
66 extern struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS];
68 int ctcm_register_dbf_views(void);
69 void ctcm_unregister_dbf_views(void);
71 static inline const char *strtail(const char *s, int n)
73 int l = strlen(s);
74 return (l > n) ? s + (l - n) : s;
77 /* sort out levels early to avoid unnecessary sprintfs */
78 static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level)
80 return (dbf_grp->level >= level);
83 #define CTCM_FUNTAIL strtail((char *)__func__, 16)
85 #define CTCM_DBF_TEXT(name, level, text) \
86 do { \
87 debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, level, text); \
88 } while (0)
90 #define CTCM_DBF_HEX(name, level, addr, len) \
91 do { \
92 debug_event(ctcm_dbf[CTCM_DBF_##name].id, \
93 level, (void *)(addr), len); \
94 } while (0)
96 #define CTCM_DBF_TEXT_(name, level, text...) \
97 do { \
98 if (ctcm_dbf_passes(ctcm_dbf[CTCM_DBF_##name].id, level)) { \
99 char *ctcm_dbf_txt_buf = \
100 get_cpu_var(ctcm_dbf_txt_buf); \
101 sprintf(ctcm_dbf_txt_buf, text); \
102 debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, \
103 level, ctcm_dbf_txt_buf); \
104 put_cpu_var(ctcm_dbf_txt_buf); \
106 } while (0)
109 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
110 * dev : netdevice with valid name field.
111 * text: any text string.
113 #define CTCM_DBF_DEV_NAME(cat, dev, text) \
114 do { \
115 CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) : %s", \
116 CTCM_FUNTAIL, dev->name, text); \
117 } while (0)
119 #define MPC_DBF_DEV_NAME(cat, dev, text) \
120 do { \
121 CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) : %s", \
122 CTCM_FUNTAIL, dev->name, text); \
123 } while (0)
125 #define CTCMY_DBF_DEV_NAME(cat, dev, text) \
126 do { \
127 if (IS_MPCDEV(dev)) \
128 MPC_DBF_DEV_NAME(cat, dev, text); \
129 else \
130 CTCM_DBF_DEV_NAME(cat, dev, text); \
131 } while (0)
134 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
135 * dev : netdevice.
136 * text: any text string.
138 #define CTCM_DBF_DEV(cat, dev, text) \
139 do { \
140 CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) : %s", \
141 CTCM_FUNTAIL, dev, text); \
142 } while (0)
144 #define MPC_DBF_DEV(cat, dev, text) \
145 do { \
146 CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) : %s", \
147 CTCM_FUNTAIL, dev, text); \
148 } while (0)
150 #define CTCMY_DBF_DEV(cat, dev, text) \
151 do { \
152 if (IS_MPCDEV(dev)) \
153 MPC_DBF_DEV(cat, dev, text); \
154 else \
155 CTCM_DBF_DEV(cat, dev, text); \
156 } while (0)
158 #endif