staging: rts5208: add support for rts5208 and rts5288
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / staging / rts5208 / trace.h
1 /* Driver for Realtek PCI-Express card reader
2  * Header file
3  *
4  * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
5  *
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.
10  *
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.
15  *
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/>.
18  *
19  * Author:
20  *   Wei WANG (wei_wang@realsil.com.cn)
21  *   Micky Ching (micky_ching@realsil.com.cn)
22  */
23
24 #ifndef __REALTEK_RTSX_TRACE_H
25 #define __REALTEK_RTSX_TRACE_H
26
27 #define _MSG_TRACE
28
29 #ifdef _MSG_TRACE
30 static inline char *filename(char *path)
31 {
32         char *ptr;
33
34         if (path == NULL)
35                 return NULL;
36
37         ptr = path;
38
39         while (*ptr != '\0') {
40                 if ((*ptr == '\\') || (*ptr == '/'))
41                         path = ptr + 1;
42
43                 ptr++;
44         }
45
46         return path;
47 }
48
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)
64
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
84
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
92
93 #endif  /* __REALTEK_RTSX_TRACE_H */