summaryrefstree
path: root/kernel/drivers/net/ethernet/aquantia/atlantic-fwd/atl_log.h
blob: 3f158f5a746bf44fae346a80de7701411c0e2057 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
/* SPDX-License-Identifier: GPL-2.0-only */
/* Atlantic Network Driver
 *
 * Copyright (C) 2019 aQuantia Corporation
 * Copyright (C) 2019-2020 Marvell International Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef _ATL_LOG_H_
#define _ATL_LOG_H_

#ifdef __KERNEL__

#include <linux/device.h>

/* Logging conveniency macros.
 *
 * atl_dev_xxx are for low-level contexts and implicitly reference
 * struct atl_hw *hw;
 *
 * atl_nic_xxx are for high-level contexts and implicitly reference
 * struct atl_nic *nic;
 */
#define atl_dev_dbg(fmt, args...)			\
	dev_dbg(&hw->pdev->dev, fmt, ## args)
#define atl_dev_info(fmt, args...)			\
	dev_info(&hw->pdev->dev, fmt, ## args)
#define atl_dev_warn(fmt, args...)			\
	dev_warn(&hw->pdev->dev, fmt, ## args)
#define atl_dev_err(fmt, args...)			\
	dev_err(&hw->pdev->dev, fmt, ## args)

#define atl_nic_dbg(fmt, args...)		\
	dev_dbg(&nic->hw.pdev->dev, fmt, ## args)
#define atl_nic_info(fmt, args...)		\
	dev_info(&nic->hw.pdev->dev, fmt, ## args)
#define atl_nic_warn(fmt, args...)		\
	dev_warn(&nic->hw.pdev->dev, fmt, ## args)
#define atl_nic_err(fmt, args...)		\
	dev_err(&nic->hw.pdev->dev, fmt, ## args)

#define atl_dev_init_warn(fmt, args...)					\
do {									\
	if (hw)								\
		atl_dev_warn(fmt, ## args);				\
	else								\
		printk(KERN_WARNING "%s: " fmt, atl_driver_name, ##args); \
} while (0)

#define atl_dev_init_err(fmt, args...)					\
do {									\
	if (hw)								\
		atl_dev_err(fmt, ## args);				\
	else								\
		printk(KERN_ERR "%s: " fmt, atl_driver_name, ##args);	\
} while (0)

#else /* __KERNEL__ */

/* Logging is disabled in case of unit tests */
#define atl_dev_dbg(fmt, args...)
#define atl_dev_info(fmt, args...)
#define atl_dev_warn(fmt, args...)
#define atl_dev_err(fmt, args...)
#define atl_nic_dbg(fmt, args...)
#define atl_nic_info(fmt, args...)
#define atl_nic_warn(fmt, args...)
#define atl_nic_err(fmt, args...)
#define atl_dev_init_warn(fmt, args...)
#define atl_dev_init_err(fmt, args...)

#endif /* __KERNEL__ */

#endif /* _ATL_LOG_H_ */