Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  *  Copyright IBM Corp. 2001, 2007
0004  *  Authors:    Peter Tiedemann (ptiedem@de.ibm.com)
0005  *
0006  */
0007 
0008 #include <linux/stddef.h>
0009 #include <linux/string.h>
0010 #include <linux/kernel.h>
0011 #include <linux/errno.h>
0012 #include <linux/ctype.h>
0013 #include <linux/sysctl.h>
0014 #include <linux/module.h>
0015 #include <linux/init.h>
0016 #include <linux/fs.h>
0017 #include <linux/debugfs.h>
0018 #include "ctcm_dbug.h"
0019 
0020 /*
0021  * Debug Facility Stuff
0022  */
0023 
0024 struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS] = {
0025     [CTCM_DBF_SETUP]     = {"ctc_setup", 8, 1, 64, CTC_DBF_INFO, NULL},
0026     [CTCM_DBF_ERROR]     = {"ctc_error", 8, 1, 64, CTC_DBF_ERROR, NULL},
0027     [CTCM_DBF_TRACE]     = {"ctc_trace", 8, 1, 64, CTC_DBF_ERROR, NULL},
0028     [CTCM_DBF_MPC_SETUP] = {"mpc_setup", 8, 1, 80, CTC_DBF_INFO, NULL},
0029     [CTCM_DBF_MPC_ERROR] = {"mpc_error", 8, 1, 80, CTC_DBF_ERROR, NULL},
0030     [CTCM_DBF_MPC_TRACE] = {"mpc_trace", 8, 1, 80, CTC_DBF_ERROR, NULL},
0031 };
0032 
0033 void ctcm_unregister_dbf_views(void)
0034 {
0035     int x;
0036     for (x = 0; x < CTCM_DBF_INFOS; x++) {
0037         debug_unregister(ctcm_dbf[x].id);
0038         ctcm_dbf[x].id = NULL;
0039     }
0040 }
0041 
0042 int ctcm_register_dbf_views(void)
0043 {
0044     int x;
0045     for (x = 0; x < CTCM_DBF_INFOS; x++) {
0046         /* register the areas */
0047         ctcm_dbf[x].id = debug_register(ctcm_dbf[x].name,
0048                         ctcm_dbf[x].pages,
0049                         ctcm_dbf[x].areas,
0050                         ctcm_dbf[x].len);
0051         if (ctcm_dbf[x].id == NULL) {
0052             ctcm_unregister_dbf_views();
0053             return -ENOMEM;
0054         }
0055 
0056         /* register a view */
0057         debug_register_view(ctcm_dbf[x].id, &debug_hex_ascii_view);
0058         /* set a passing level */
0059         debug_set_level(ctcm_dbf[x].id, ctcm_dbf[x].level);
0060     }
0061 
0062     return 0;
0063 }
0064 
0065 void ctcm_dbf_longtext(enum ctcm_dbf_names dbf_nix, int level, char *fmt, ...)
0066 {
0067     char dbf_txt_buf[64];
0068     va_list args;
0069 
0070     if (!debug_level_enabled(ctcm_dbf[dbf_nix].id, level))
0071         return;
0072     va_start(args, fmt);
0073     vsnprintf(dbf_txt_buf, sizeof(dbf_txt_buf), fmt, args);
0074     va_end(args);
0075 
0076     debug_text_event(ctcm_dbf[dbf_nix].id, level, dbf_txt_buf);
0077 }
0078