• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
filename(char * path)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 		dev_dbg(rtsx_dev(chip), "[%s][%s]:[%d]\n", _file,	\
53 			__func__, __LINE__);				\
54 		(chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
55 		strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
56 		strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
57 		get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf, TIME_VAL_LEN);	\
58 		(chip)->trace_msg[(chip)->msg_idx].valid = 1;		\
59 		(chip)->msg_idx++;					\
60 		if ((chip)->msg_idx >= TRACE_ITEM_CNT) {		\
61 			(chip)->msg_idx = 0;				\
62 		}							\
63 		return ret;						\
64 	} while (0)
65 
66 #define TRACE_GOTO(chip, label)						\
67 	do {								\
68 		char *_file = filename(__FILE__);			\
69 		dev_dbg(rtsx_dev(chip), "[%s][%s]:[%d]\n", _file,	\
70 			__func__, __LINE__);				\
71 		(chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
72 		strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
73 		strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
74 		get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf, TIME_VAL_LEN);	\
75 		(chip)->trace_msg[(chip)->msg_idx].valid = 1;		\
76 		(chip)->msg_idx++;					\
77 		if ((chip)->msg_idx >= TRACE_ITEM_CNT) {		\
78 			(chip)->msg_idx = 0;				\
79 		}							\
80 		goto label;						\
81 	} while (0)
82 #else
83 #define TRACE_RET(chip, ret)	return ret
84 #define TRACE_GOTO(chip, label)	goto label
85 #endif
86 
87 #endif  /* __REALTEK_RTSX_TRACE_H */
88