trace.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #ifndef __REALTEK_RTSX_TRACE_H
  24. #define __REALTEK_RTSX_TRACE_H
  25. #define _MSG_TRACE
  26. #ifdef _MSG_TRACE
  27. static inline char *filename(char *path)
  28. {
  29. char *ptr;
  30. if (path == NULL)
  31. return NULL;
  32. ptr = path;
  33. while (*ptr != '\0') {
  34. if ((*ptr == '\\') || (*ptr == '/'))
  35. path = ptr + 1;
  36. ptr++;
  37. }
  38. return path;
  39. }
  40. #define TRACE_RET(chip, ret) \
  41. do { \
  42. char *_file = filename(__FILE__); \
  43. dev_dbg(rtsx_dev(chip), "[%s][%s]:[%d]\n", _file, \
  44. __func__, __LINE__); \
  45. (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
  46. strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
  47. strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
  48. get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf, TIME_VAL_LEN); \
  49. (chip)->trace_msg[(chip)->msg_idx].valid = 1; \
  50. (chip)->msg_idx++; \
  51. if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \
  52. (chip)->msg_idx = 0; \
  53. } \
  54. return ret; \
  55. } while (0)
  56. #define TRACE_GOTO(chip, label) \
  57. do { \
  58. char *_file = filename(__FILE__); \
  59. dev_dbg(rtsx_dev(chip), "[%s][%s]:[%d]\n", _file, \
  60. __func__, __LINE__); \
  61. (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
  62. strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
  63. strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
  64. get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf, TIME_VAL_LEN); \
  65. (chip)->trace_msg[(chip)->msg_idx].valid = 1; \
  66. (chip)->msg_idx++; \
  67. if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \
  68. (chip)->msg_idx = 0; \
  69. } \
  70. goto label; \
  71. } while (0)
  72. #else
  73. #define TRACE_RET(chip, ret) return ret
  74. #define TRACE_GOTO(chip, label) goto label
  75. #endif
  76. #endif /* __REALTEK_RTSX_TRACE_H */