ctcm_dbug.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/kernel.h>
  10. #include <linux/errno.h>
  11. #include <linux/slab.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. DEFINE_PER_CPU(char[256], ctcm_dbf_txt_buf);
  23. struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS] = {
  24. [CTCM_DBF_SETUP] = {"ctc_setup", 8, 1, 64, 5, NULL},
  25. [CTCM_DBF_ERROR] = {"ctc_error", 8, 1, 64, 3, NULL},
  26. [CTCM_DBF_TRACE] = {"ctc_trace", 8, 1, 64, 3, NULL},
  27. [CTCM_DBF_MPC_SETUP] = {"mpc_setup", 8, 1, 64, 5, NULL},
  28. [CTCM_DBF_MPC_ERROR] = {"mpc_error", 8, 1, 64, 3, NULL},
  29. [CTCM_DBF_MPC_TRACE] = {"mpc_trace", 8, 1, 64, 3, 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. }