zcrypt_debug.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright IBM Corp. 2012
  3. * Author(s): Holger Dengler (hd@linux.vnet.ibm.com)
  4. */
  5. #ifndef ZCRYPT_DEBUG_H
  6. #define ZCRYPT_DEBUG_H
  7. #include <asm/debug.h>
  8. #include "zcrypt_api.h"
  9. /* that gives us 15 characters in the text event views */
  10. #define ZCRYPT_DBF_LEN 16
  11. #define DBF_ERR 3 /* error conditions */
  12. #define DBF_WARN 4 /* warning conditions */
  13. #define DBF_INFO 6 /* informational */
  14. #define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO)
  15. #define ZCRYPT_DBF_COMMON(level, text...) \
  16. do { \
  17. if (debug_level_enabled(zcrypt_dbf_common, level)) { \
  18. char debug_buffer[ZCRYPT_DBF_LEN]; \
  19. snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
  20. debug_text_event(zcrypt_dbf_common, level, \
  21. debug_buffer); \
  22. } \
  23. } while (0)
  24. #define ZCRYPT_DBF_DEVICES(level, text...) \
  25. do { \
  26. if (debug_level_enabled(zcrypt_dbf_devices, level)) { \
  27. char debug_buffer[ZCRYPT_DBF_LEN]; \
  28. snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
  29. debug_text_event(zcrypt_dbf_devices, level, \
  30. debug_buffer); \
  31. } \
  32. } while (0)
  33. #define ZCRYPT_DBF_DEV(level, device, text...) \
  34. do { \
  35. if (debug_level_enabled(device->dbf_area, level)) { \
  36. char debug_buffer[ZCRYPT_DBF_LEN]; \
  37. snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
  38. debug_text_event(device->dbf_area, level, \
  39. debug_buffer); \
  40. } \
  41. } while (0)
  42. int zcrypt_debug_init(void);
  43. void zcrypt_debug_exit(void);
  44. #endif /* ZCRYPT_DEBUG_H */