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 macros.
0009 
0010 *****************************************************************************/
0011 
0012 #ifndef _HPIDEBUG_H
0013 #define _HPIDEBUG_H
0014 
0015 #include "hpi_internal.h"
0016 
0017 /* Define debugging levels.  */
0018 enum { HPI_DEBUG_LEVEL_ERROR = 0,   /* always log errors */
0019     HPI_DEBUG_LEVEL_WARNING = 1,
0020     HPI_DEBUG_LEVEL_NOTICE = 2,
0021     HPI_DEBUG_LEVEL_INFO = 3,
0022     HPI_DEBUG_LEVEL_DEBUG = 4,
0023     HPI_DEBUG_LEVEL_VERBOSE = 5 /* same printk level as DEBUG */
0024 };
0025 
0026 #define HPI_DEBUG_LEVEL_DEFAULT HPI_DEBUG_LEVEL_NOTICE
0027 
0028 /* an OS can define an extra flag string that is appended to
0029    the start of each message, eg see linux kernel hpios.h */
0030 
0031 #ifdef SOURCEFILE_NAME
0032 #define FILE_LINE  SOURCEFILE_NAME ":" __stringify(__LINE__) " "
0033 #else
0034 #define FILE_LINE  __FILE__ ":" __stringify(__LINE__) " "
0035 #endif
0036 
0037 #define HPI_DEBUG_ASSERT(expression) \
0038     do { \
0039         if (!(expression)) { \
0040             printk(KERN_ERR  FILE_LINE \
0041                 "ASSERT " __stringify(expression)); \
0042         } \
0043     } while (0)
0044 
0045 #define HPI_DEBUG_LOG(level, ...) \
0046     do { \
0047         if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \
0048             printk(HPI_DEBUG_FLAG_##level \
0049             FILE_LINE  __VA_ARGS__); \
0050         } \
0051     } while (0)
0052 
0053 void hpi_debug_init(void);
0054 int hpi_debug_level_set(int level);
0055 int hpi_debug_level_get(void);
0056 /* needed by Linux driver for dynamic debug level changes */
0057 extern int hpi_debug_level;
0058 
0059 void hpi_debug_message(struct hpi_message *phm, char *sz_fileline);
0060 
0061 void hpi_debug_data(u16 *pdata, u32 len);
0062 
0063 #define HPI_DEBUG_DATA(pdata, len) \
0064     do { \
0065         if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \
0066             hpi_debug_data(pdata, len); \
0067     } while (0)
0068 
0069 #define HPI_DEBUG_MESSAGE(level, phm) \
0070     do { \
0071         if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \
0072             hpi_debug_message(phm, HPI_DEBUG_FLAG_##level \
0073                 FILE_LINE __stringify(level)); \
0074         } \
0075     } while (0)
0076 
0077 #define HPI_DEBUG_RESPONSE(phr) \
0078     do { \
0079         if (((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && \
0080             (phr->error)) ||\
0081         (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE)) \
0082             printk(KERN_DEBUG "HPI_RES%d,%d,%d\n", \
0083                 phr->version, phr->error, phr->specific_error); \
0084     } while (0)
0085 
0086 #ifndef compile_time_assert
0087 #define compile_time_assert(cond, msg) \
0088     typedef char msg[(cond) ? 1 : -1]
0089 #endif
0090 
0091 #endif              /* _HPIDEBUG_H_  */