hpidebug.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /************************************************************************
  2. AudioScience HPI driver
  3. Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of version 2 of the GNU General Public License as
  6. published by the Free Software Foundation;
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. Debug macro translation.
  15. ************************************************************************/
  16. #include "hpi_internal.h"
  17. #include "hpidebug.h"
  18. /* Debug level; 0 quiet; 1 informative, 2 debug, 3 verbose debug. */
  19. int hpi_debug_level = HPI_DEBUG_LEVEL_DEFAULT;
  20. void hpi_debug_init(void)
  21. {
  22. printk(KERN_INFO "debug start\n");
  23. }
  24. int hpi_debug_level_set(int level)
  25. {
  26. int old_level;
  27. old_level = hpi_debug_level;
  28. hpi_debug_level = level;
  29. return old_level;
  30. }
  31. int hpi_debug_level_get(void)
  32. {
  33. return hpi_debug_level;
  34. }
  35. void hpi_debug_message(struct hpi_message *phm, char *sz_fileline)
  36. {
  37. if (phm) {
  38. printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version,
  39. phm->adapter_index, phm->obj_index, phm->function,
  40. phm->u.c.attribute);
  41. }
  42. }
  43. void hpi_debug_data(u16 *pdata, u32 len)
  44. {
  45. u32 i;
  46. int j;
  47. int k;
  48. int lines;
  49. int cols = 8;
  50. lines = (len + cols - 1) / cols;
  51. if (lines > 8)
  52. lines = 8;
  53. for (i = 0, j = 0; j < lines; j++) {
  54. printk(KERN_DEBUG "%p:", (pdata + i));
  55. for (k = 0; k < cols && i < len; i++, k++)
  56. printk("%s%04x", k == 0 ? "" : " ", pdata[i]);
  57. printk("\n");
  58. }
  59. }