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