blob: f16660589aa5fdd893ed1181f8729e7f6aaff903 [file] [log] [blame]
Lukas Hänel28a9ffd2012-11-07 13:17:39 +09001/*
2 * MobiCore driver module.(interface to the secure world SWD)
3 *
4 * <-- Copyright Giesecke & Devrient GmbH 2009-2012 -->
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef _MC_DEBUG_H_
12#define _MC_DEBUG_H_
13/* Found in main.c */
14extern struct device *mcd;
15
16#define MCDRV_DBG_ERROR(dev, txt, ...) \
17 dev_err(dev, "[%d] %s() ### ERROR: " txt, \
18 task_pid_vnr(current), \
19 __func__, \
20 ##__VA_ARGS__)
21
22/* dummy function helper macro. */
23#define DUMMY_FUNCTION() do {} while (0)
24
25#if defined(DEBUG)
26
27/* #define DEBUG_VERBOSE */
28#if defined(DEBUG_VERBOSE)
29#define MCDRV_DBG_VERBOSE MCDRV_DBG
30#else
31#define MCDRV_DBG_VERBOSE(...) DUMMY_FUNCTION()
32#endif
33
34#define MCDRV_DBG(dev, txt, ...) \
35 dev_info(dev, "[%d on CPU%d] %s(): " txt, \
36 task_pid_vnr(current), \
37 raw_smp_processor_id(), \
38 __func__, \
39 ##__VA_ARGS__)
40
41#define MCDRV_DBG_WARN(dev, txt, ...) \
42 dev_warn(dev, "[%d] %s() WARNING: " txt, \
43 task_pid_vnr(current), \
44 __func__, \
45 ##__VA_ARGS__)
46
47#define MCDRV_ASSERT(cond) \
48 do { \
49 if (unlikely(!(cond))) { \
50 panic("Assertion failed: %s:%d\n", \
51 __FILE__, __LINE__); \
52 } \
53 } while (0)
54
55#else
56
57#define MCDRV_DBG_VERBOSE(...) DUMMY_FUNCTION()
58#define MCDRV_DBG(...) DUMMY_FUNCTION()
59#define MCDRV_DBG_WARN(...) DUMMY_FUNCTION()
60
61#define MCDRV_ASSERT(...) DUMMY_FUNCTION()
62
63#endif /* [not] defined(DEBUG) */
64
65#endif /* _MC_DEBUG_H_ */