esas2r_log.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * linux/drivers/scsi/esas2r/esas2r_log.h
  3. * For use with ATTO ExpressSAS R6xx SAS/SATA RAID controllers
  4. *
  5. * Copyright (c) 2001-2013 ATTO Technology, Inc.
  6. * (mailto:linuxdrivers@attotech.com)
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * NO WARRANTY
  19. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  20. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  21. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  22. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  23. * solely responsible for determining the appropriateness of using and
  24. * distributing the Program and assumes all risks associated with its
  25. * exercise of rights under this Agreement, including but not limited to
  26. * the risks and costs of program errors, damage to or loss of data,
  27. * programs or equipment, and unavailability or interruption of operations.
  28. *
  29. * DISCLAIMER OF LIABILITY
  30. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  33. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  35. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  36. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  37. *
  38. * You should have received a copy of the GNU General Public License
  39. * along with this program; if not, write to the Free Software
  40. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  41. * USA.
  42. */
  43. #ifndef __esas2r_log_h__
  44. #define __esas2r_log_h__
  45. struct device;
  46. enum {
  47. ESAS2R_LOG_NONE = 0, /* no events logged */
  48. ESAS2R_LOG_CRIT = 1, /* critical events */
  49. ESAS2R_LOG_WARN = 2, /* warning events */
  50. ESAS2R_LOG_INFO = 3, /* info events */
  51. ESAS2R_LOG_DEBG = 4, /* debugging events */
  52. ESAS2R_LOG_TRCE = 5, /* tracing events */
  53. #ifdef ESAS2R_TRACE
  54. ESAS2R_LOG_DFLT = ESAS2R_LOG_TRCE
  55. #else
  56. ESAS2R_LOG_DFLT = ESAS2R_LOG_WARN
  57. #endif
  58. };
  59. int esas2r_log(const long level, const char *format, ...);
  60. int esas2r_log_dev(const long level,
  61. const struct device *dev,
  62. const char *format,
  63. ...);
  64. int esas2r_log_hexdump(const long level,
  65. const void *buf,
  66. size_t len);
  67. /*
  68. * the following macros are provided specifically for debugging and tracing
  69. * messages. esas2r_debug() is provided for generic non-hardware layer
  70. * debugging and tracing events. esas2r_hdebug is provided specifically for
  71. * hardware layer debugging and tracing events.
  72. */
  73. #ifdef ESAS2R_DEBUG
  74. #define esas2r_debug(f, args ...) esas2r_log(ESAS2R_LOG_DEBG, f, ## args)
  75. #define esas2r_hdebug(f, args ...) esas2r_log(ESAS2R_LOG_DEBG, f, ## args)
  76. #else
  77. #define esas2r_debug(f, args ...)
  78. #define esas2r_hdebug(f, args ...)
  79. #endif /* ESAS2R_DEBUG */
  80. /*
  81. * the following macros are provided in order to trace the driver and catch
  82. * some more serious bugs. be warned, enabling these macros may *severely*
  83. * impact performance.
  84. */
  85. #ifdef ESAS2R_TRACE
  86. #define esas2r_bugon() \
  87. do { \
  88. esas2r_log(ESAS2R_LOG_TRCE, "esas2r_bugon() called in %s:%d" \
  89. " - dumping stack and stopping kernel", __func__, \
  90. __LINE__); \
  91. dump_stack(); \
  92. BUG(); \
  93. } while (0)
  94. #define esas2r_trace_enter() esas2r_log(ESAS2R_LOG_TRCE, "entered %s (%s:%d)", \
  95. __func__, __FILE__, __LINE__)
  96. #define esas2r_trace_exit() esas2r_log(ESAS2R_LOG_TRCE, "exited %s (%s:%d)", \
  97. __func__, __FILE__, __LINE__)
  98. #define esas2r_trace(f, args ...) esas2r_log(ESAS2R_LOG_TRCE, "(%s:%s:%d): " \
  99. f, __func__, __FILE__, __LINE__, \
  100. ## args)
  101. #else
  102. #define esas2r_bugon()
  103. #define esas2r_trace_enter()
  104. #define esas2r_trace_exit()
  105. #define esas2r_trace(f, args ...)
  106. #endif /* ESAS2R_TRACE */
  107. #endif /* __esas2r_log_h__ */