ctcm_dbug.c 1.9 KB

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