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