Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[linux-2.6] / drivers / s390 / net / ctcm_dbug.c
1 /*
2  *      drivers/s390/net/ctcm_dbug.c
3  *
4  *      Copyright IBM Corp. 2001, 2007
5  *      Authors:        Peter Tiedemann (ptiedem@de.ibm.com)
6  *
7  */
8
9 #include <linux/stddef.h>
10 #include <linux/string.h>
11 #include <linux/kernel.h>
12 #include <linux/errno.h>
13 #include <linux/slab.h>
14 #include <linux/ctype.h>
15 #include <linux/sysctl.h>
16 #include <linux/module.h>
17 #include <linux/init.h>
18 #include <linux/fs.h>
19 #include <linux/debugfs.h>
20 #include "ctcm_dbug.h"
21
22 /*
23  * Debug Facility Stuff
24  */
25
26 struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS] = {
27         [CTCM_DBF_SETUP]     = {"ctc_setup", 8, 1, 64, CTC_DBF_INFO, NULL},
28         [CTCM_DBF_ERROR]     = {"ctc_error", 8, 1, 64, CTC_DBF_ERROR, NULL},
29         [CTCM_DBF_TRACE]     = {"ctc_trace", 8, 1, 64, CTC_DBF_ERROR, NULL},
30         [CTCM_DBF_MPC_SETUP] = {"mpc_setup", 8, 1, 80, CTC_DBF_INFO, NULL},
31         [CTCM_DBF_MPC_ERROR] = {"mpc_error", 8, 1, 80, CTC_DBF_ERROR, NULL},
32         [CTCM_DBF_MPC_TRACE] = {"mpc_trace", 8, 1, 80, CTC_DBF_ERROR, NULL},
33 };
34
35 void ctcm_unregister_dbf_views(void)
36 {
37         int x;
38         for (x = 0; x < CTCM_DBF_INFOS; x++) {
39                 debug_unregister(ctcm_dbf[x].id);
40                 ctcm_dbf[x].id = NULL;
41         }
42 }
43
44 int ctcm_register_dbf_views(void)
45 {
46         int x;
47         for (x = 0; x < CTCM_DBF_INFOS; x++) {
48                 /* register the areas */
49                 ctcm_dbf[x].id = debug_register(ctcm_dbf[x].name,
50                                                 ctcm_dbf[x].pages,
51                                                 ctcm_dbf[x].areas,
52                                                 ctcm_dbf[x].len);
53                 if (ctcm_dbf[x].id == NULL) {
54                         ctcm_unregister_dbf_views();
55                         return -ENOMEM;
56                 }
57
58                 /* register a view */
59                 debug_register_view(ctcm_dbf[x].id, &debug_hex_ascii_view);
60                 /* set a passing level */
61                 debug_set_level(ctcm_dbf[x].id, ctcm_dbf[x].level);
62         }
63
64         return 0;
65 }
66
67 void ctcm_dbf_longtext(enum ctcm_dbf_names dbf_nix, int level, char *fmt, ...)
68 {
69         char dbf_txt_buf[64];
70         va_list args;
71
72         if (level > (ctcm_dbf[dbf_nix].id)->level)
73                 return;
74         va_start(args, fmt);
75         vsnprintf(dbf_txt_buf, sizeof(dbf_txt_buf), fmt, args);
76         va_end(args);
77
78         debug_text_event(ctcm_dbf[dbf_nix].id, level, dbf_txt_buf);
79 }
80