Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /************************************************************************
0003 
0004     AudioScience HPI driver
0005     Copyright (C) 1997-2011  AudioScience Inc. <support@audioscience.com>
0006 
0007 
0008 Debug macro translation.
0009 
0010 ************************************************************************/
0011 
0012 #include "hpi_internal.h"
0013 #include "hpidebug.h"
0014 
0015 /* Debug level; 0 quiet; 1 informative, 2 debug, 3 verbose debug.  */
0016 int hpi_debug_level = HPI_DEBUG_LEVEL_DEFAULT;
0017 
0018 void hpi_debug_init(void)
0019 {
0020     printk(KERN_INFO "debug start\n");
0021 }
0022 
0023 int hpi_debug_level_set(int level)
0024 {
0025     int old_level;
0026 
0027     old_level = hpi_debug_level;
0028     hpi_debug_level = level;
0029     return old_level;
0030 }
0031 
0032 int hpi_debug_level_get(void)
0033 {
0034     return hpi_debug_level;
0035 }
0036 
0037 void hpi_debug_message(struct hpi_message *phm, char *sz_fileline)
0038 {
0039     if (phm) {
0040         printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version,
0041             phm->adapter_index, phm->obj_index, phm->function,
0042             phm->u.c.attribute);
0043     }
0044 
0045 }
0046 
0047 void hpi_debug_data(u16 *pdata, u32 len)
0048 {
0049     u32 i;
0050     int j;
0051     int k;
0052     int lines;
0053     int cols = 8;
0054 
0055     lines = DIV_ROUND_UP(len, cols);
0056     if (lines > 8)
0057         lines = 8;
0058 
0059     for (i = 0, j = 0; j < lines; j++) {
0060         printk(KERN_DEBUG "%p:", (pdata + i));
0061 
0062         for (k = 0; k < cols && i < len; i++, k++)
0063             printk(KERN_CONT "%s%04x", k == 0 ? "" : " ", pdata[i]);
0064 
0065         printk(KERN_CONT "\n");
0066     }
0067 }