Staging: rts5139: Fix Sparse Warning for Static Declarations in rts51x.c
[cascardo/linux.git] / drivers / staging / rts5139 / trace.h
1 /* Driver for Realtek RTS51xx USB card reader
2  * Header file
3  *
4  * Copyright(c) 2009 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  *   wwang (wei_wang@realsil.com.cn)
21  *   No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
22  * Maintainer:
23  *   Edwin Rong (edwin_rong@realsil.com.cn)
24  *   No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
25  */
26
27 #ifndef __RTS51X_TRACE_H
28 #define __RTS51X_TRACE_H
29
30 #include <linux/string.h>
31
32 #include "debug.h"
33
34 #define _MSG_TRACE
35
36 #ifdef _MSG_TRACE
37 #define TRACE_RET(chip, ret)                                            \
38 do {                                                                    \
39         const char *_file = kbasename(__FILE__);                        \
40         RTS51X_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__);    \
41         (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__);      \
42         strncpy((chip)->trace_msg[(chip)->msg_idx].func,                \
43                         __func__, MSG_FUNC_LEN-1);                      \
44         strncpy((chip)->trace_msg[(chip)->msg_idx].file,                \
45                         _file, MSG_FILE_LEN-1);                         \
46         get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf,\
47                         TIME_VAL_LEN);  \
48         (chip)->trace_msg[(chip)->msg_idx].valid = 1;                   \
49         (chip)->msg_idx++;                                              \
50         if ((chip)->msg_idx >= TRACE_ITEM_CNT) {                        \
51                 (chip)->msg_idx = 0;                                    \
52         }                                                               \
53         return ret;                                                     \
54 } while (0)
55
56 #define TRACE_GOTO(chip, label)                                         \
57 do {                                                                    \
58         const char *_file = kbasename(__FILE__);                        \
59         RTS51X_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__);    \
60         (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__);      \
61         strncpy((chip)->trace_msg[(chip)->msg_idx].func,                \
62                         __func__, MSG_FUNC_LEN-1);                      \
63         strncpy((chip)->trace_msg[(chip)->msg_idx].file,                \
64                         _file, MSG_FILE_LEN-1);                         \
65         get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf,\
66                         TIME_VAL_LEN);                                  \
67         (chip)->trace_msg[(chip)->msg_idx].valid = 1;                   \
68         (chip)->msg_idx++;                                              \
69         if ((chip)->msg_idx >= TRACE_ITEM_CNT) {                        \
70                 (chip)->msg_idx = 0;                                    \
71         }                                                               \
72         goto label;                                                     \
73 } while (0)
74 #else
75 #define TRACE_RET(chip, ret)    return (ret)
76 #define TRACE_GOTO(chip, label) goto label
77 #endif
78
79 #ifdef CONFIG_RTS5139_DEBUG
80 #define RTS51X_DUMP(buf, buf_len)                                       \
81         print_hex_dump(KERN_DEBUG, RTS51X_TIP, DUMP_PREFIX_NONE,        \
82                                 16, 1, (buf), (buf_len), false)
83
84 #define CATCH_TRIGGER(chip)                                     \
85 do {                                                            \
86         rts51x_ep0_write_register((chip), 0xFC31, 0x01, 0x01);  \
87         RTS51X_DEBUGP("Catch trigger!\n");                      \
88 } while (0)
89
90 #else
91 #define RTS51X_DUMP(buf, buf_len)
92 #define CATCH_TRIGGER(chip)
93 #endif
94
95 #endif /* __RTS51X_TRACE_H */