hpidebug.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /************************************************************************
  3. AudioScience HPI driver
  4. Copyright (C) 1997-2011 AudioScience Inc. <[email protected]>
  5. Debug macro translation.
  6. ************************************************************************/
  7. #include "hpi_internal.h"
  8. #include "hpidebug.h"
  9. /* Debug level; 0 quiet; 1 informative, 2 debug, 3 verbose debug. */
  10. int hpi_debug_level = HPI_DEBUG_LEVEL_DEFAULT;
  11. void hpi_debug_init(void)
  12. {
  13. printk(KERN_INFO "debug start\n");
  14. }
  15. int hpi_debug_level_set(int level)
  16. {
  17. int old_level;
  18. old_level = hpi_debug_level;
  19. hpi_debug_level = level;
  20. return old_level;
  21. }
  22. int hpi_debug_level_get(void)
  23. {
  24. return hpi_debug_level;
  25. }
  26. void hpi_debug_message(struct hpi_message *phm, char *sz_fileline)
  27. {
  28. if (phm) {
  29. printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version,
  30. phm->adapter_index, phm->obj_index, phm->function,
  31. phm->u.c.attribute);
  32. }
  33. }
  34. void hpi_debug_data(u16 *pdata, u32 len)
  35. {
  36. u32 i;
  37. int j;
  38. int k;
  39. int lines;
  40. int cols = 8;
  41. lines = DIV_ROUND_UP(len, cols);
  42. if (lines > 8)
  43. lines = 8;
  44. for (i = 0, j = 0; j < lines; j++) {
  45. printk(KERN_DEBUG "%p:", (pdata + i));
  46. for (k = 0; k < cols && i < len; i++, k++)
  47. printk(KERN_CONT "%s%04x", k == 0 ? "" : " ", pdata[i]);
  48. printk(KERN_CONT "\n");
  49. }
  50. }