107d7fe7bSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2719f82d3SEliot Blennerhassett /************************************************************************
3719f82d3SEliot Blennerhassett
4719f82d3SEliot Blennerhassett AudioScience HPI driver
540818b62SEliot Blennerhassett Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
6719f82d3SEliot Blennerhassett
7719f82d3SEliot Blennerhassett
8719f82d3SEliot Blennerhassett Debug macro translation.
9719f82d3SEliot Blennerhassett
10719f82d3SEliot Blennerhassett ************************************************************************/
11719f82d3SEliot Blennerhassett
12719f82d3SEliot Blennerhassett #include "hpi_internal.h"
13719f82d3SEliot Blennerhassett #include "hpidebug.h"
14719f82d3SEliot Blennerhassett
15719f82d3SEliot Blennerhassett /* Debug level; 0 quiet; 1 informative, 2 debug, 3 verbose debug. */
16719f82d3SEliot Blennerhassett int hpi_debug_level = HPI_DEBUG_LEVEL_DEFAULT;
17719f82d3SEliot Blennerhassett
hpi_debug_init(void)18719f82d3SEliot Blennerhassett void hpi_debug_init(void)
19719f82d3SEliot Blennerhassett {
20719f82d3SEliot Blennerhassett printk(KERN_INFO "debug start\n");
21719f82d3SEliot Blennerhassett }
22719f82d3SEliot Blennerhassett
hpi_debug_level_set(int level)23719f82d3SEliot Blennerhassett int hpi_debug_level_set(int level)
24719f82d3SEliot Blennerhassett {
25719f82d3SEliot Blennerhassett int old_level;
26719f82d3SEliot Blennerhassett
27719f82d3SEliot Blennerhassett old_level = hpi_debug_level;
28719f82d3SEliot Blennerhassett hpi_debug_level = level;
29719f82d3SEliot Blennerhassett return old_level;
30719f82d3SEliot Blennerhassett }
31719f82d3SEliot Blennerhassett
hpi_debug_level_get(void)32719f82d3SEliot Blennerhassett int hpi_debug_level_get(void)
33719f82d3SEliot Blennerhassett {
34719f82d3SEliot Blennerhassett return hpi_debug_level;
35719f82d3SEliot Blennerhassett }
36719f82d3SEliot Blennerhassett
hpi_debug_message(struct hpi_message * phm,char * sz_fileline)37719f82d3SEliot Blennerhassett void hpi_debug_message(struct hpi_message *phm, char *sz_fileline)
38719f82d3SEliot Blennerhassett {
39719f82d3SEliot Blennerhassett if (phm) {
401528fbb5SEliot Blennerhassett printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version,
41f0dcad41SEliot Blennerhassett phm->adapter_index, phm->obj_index, phm->function,
42f0dcad41SEliot Blennerhassett phm->u.c.attribute);
43719f82d3SEliot Blennerhassett }
44719f82d3SEliot Blennerhassett
45719f82d3SEliot Blennerhassett }
46719f82d3SEliot Blennerhassett
hpi_debug_data(u16 * pdata,u32 len)47719f82d3SEliot Blennerhassett void hpi_debug_data(u16 *pdata, u32 len)
48719f82d3SEliot Blennerhassett {
49719f82d3SEliot Blennerhassett u32 i;
50719f82d3SEliot Blennerhassett int j;
51719f82d3SEliot Blennerhassett int k;
52719f82d3SEliot Blennerhassett int lines;
53719f82d3SEliot Blennerhassett int cols = 8;
54719f82d3SEliot Blennerhassett
55*af787b2eSLars-Peter Clausen lines = DIV_ROUND_UP(len, cols);
56719f82d3SEliot Blennerhassett if (lines > 8)
57719f82d3SEliot Blennerhassett lines = 8;
58719f82d3SEliot Blennerhassett
59719f82d3SEliot Blennerhassett for (i = 0, j = 0; j < lines; j++) {
60719f82d3SEliot Blennerhassett printk(KERN_DEBUG "%p:", (pdata + i));
61719f82d3SEliot Blennerhassett
62719f82d3SEliot Blennerhassett for (k = 0; k < cols && i < len; i++, k++)
63874b83d3STakashi Iwai printk(KERN_CONT "%s%04x", k == 0 ? "" : " ", pdata[i]);
64719f82d3SEliot Blennerhassett
65874b83d3STakashi Iwai printk(KERN_CONT "\n");
66719f82d3SEliot Blennerhassett }
67719f82d3SEliot Blennerhassett }
68