PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / staging / rts5208 / trace.h
blob0f177fbaaf1f64daf82e0014a806681e2d6825c9
1 /* Driver for Realtek PCI-Express card reader
2 * Header file
4 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, see <http://www.gnu.org/licenses/>.
19 * Author:
20 * Wei WANG (wei_wang@realsil.com.cn)
21 * Micky Ching (micky_ching@realsil.com.cn)
24 #ifndef __REALTEK_RTSX_TRACE_H
25 #define __REALTEK_RTSX_TRACE_H
27 #define _MSG_TRACE
29 #ifdef _MSG_TRACE
30 static inline char *filename(char *path)
32 char *ptr;
34 if (path == NULL)
35 return NULL;
37 ptr = path;
39 while (*ptr != '\0') {
40 if ((*ptr == '\\') || (*ptr == '/'))
41 path = ptr + 1;
43 ptr++;
46 return path;
49 #define TRACE_RET(chip, ret) \
50 do { \
51 char *_file = filename(__FILE__); \
52 RTSX_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \
53 (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
54 strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
55 strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
56 get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf, TIME_VAL_LEN); \
57 (chip)->trace_msg[(chip)->msg_idx].valid = 1; \
58 (chip)->msg_idx++; \
59 if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \
60 (chip)->msg_idx = 0; \
61 } \
62 return ret; \
63 } while (0)
65 #define TRACE_GOTO(chip, label) \
66 do { \
67 char *_file = filename(__FILE__); \
68 RTSX_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \
69 (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
70 strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
71 strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
72 get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf, TIME_VAL_LEN); \
73 (chip)->trace_msg[(chip)->msg_idx].valid = 1; \
74 (chip)->msg_idx++; \
75 if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \
76 (chip)->msg_idx = 0; \
77 } \
78 goto label; \
79 } while (0)
80 #else
81 #define TRACE_RET(chip, ret) return ret
82 #define TRACE_GOTO(chip, label) goto label
83 #endif
85 #ifdef CONFIG_RTS5208_DEBUG
86 #define RTSX_DUMP(buf, buf_len) \
87 print_hex_dump(KERN_DEBUG, RTSX_STOR, DUMP_PREFIX_NONE, \
88 16, 1, (buf), (buf_len), false)
89 #else
90 #define RTSX_DUMP(buf, buf_len)
91 #endif
93 #endif /* __REALTEK_RTSX_TRACE_H */