ctcm_dbug.c 1.8 KB

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