summaryrefstree
path: root/kernel/drivers/misc/tzdev/tzlog.h
blob: a574adc4593cdf5f7c6a9afdbe6e2c49898c3df9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Copyright (C) 2012-2017, Samsung Electronics Co., Ltd.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __TZLOG_H__
#define __TZLOG_H__

extern unsigned int tzdev_verbosity;
extern unsigned int tzdev_teec_verbosity;
extern unsigned int tzdev_kthread_verbosity;
extern unsigned int tzdev_uiwsock_verbosity;

enum {
	TZDEV_LOG_LEVEL_ERROR,
	TZDEV_LOG_LEVEL_INFO,
	TZDEV_LOG_LEVEL_DEBUG,
};

static inline const char *tz_print_prefix(unsigned int lvl)
{
	switch (lvl) {
	case TZDEV_LOG_LEVEL_ERROR:
		return "ERR";
	case TZDEV_LOG_LEVEL_INFO:
		return "INF";
	case TZDEV_LOG_LEVEL_DEBUG:
		return "DBG";
	default:
		return "???";
	}
}

#define tz_print(lvl, param, fmt, ...)						\
	do {									\
		if (lvl <= param)						\
			printk("TZDEV> %s %s(%d): "fmt,				\
					tz_print_prefix(lvl),			\
					__func__, __LINE__, ##__VA_ARGS__);	\
	} while (0)

#define tzdev_print(lvl, fmt, ...)	tz_print(lvl, tzdev_verbosity, fmt,  ##__VA_ARGS__)

#define tzdev_teec_debug(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_DEBUG, tzdev_teec_verbosity, fmt, ##__VA_ARGS__)
#define tzdev_teec_info(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_INFO, tzdev_teec_verbosity, fmt, ##__VA_ARGS__)
#define tzdev_teec_error(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_ERROR, tzdev_teec_verbosity, fmt, ##__VA_ARGS__)

#define tzdev_kthread_debug(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_DEBUG, tzdev_kthread_verbosity, fmt, ##__VA_ARGS__)
#define tzdev_kthread_info(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_INFO, tzdev_kthread_verbosity, fmt, ##__VA_ARGS__)
#define tzdev_kthread_error(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_ERROR, tzdev_kthread_verbosity, fmt, ##__VA_ARGS__)

#define tzdev_uiwsock_debug(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_DEBUG, tzdev_uiwsock_verbosity, fmt, ##__VA_ARGS__)
#define tzdev_uiwsock_info(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_INFO, tzdev_uiwsock_verbosity, fmt, ##__VA_ARGS__)
#define tzdev_uiwsock_error(fmt, ...)	tz_print(TZDEV_LOG_LEVEL_ERROR, tzdev_uiwsock_verbosity, fmt, ##__VA_ARGS__)

#endif /* __TZLOG_H__ */