18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * linux/drivers/scsi/esas2r/esas2r_log.h 38c2ecf20Sopenharmony_ci * For use with ATTO ExpressSAS R6xx SAS/SATA RAID controllers 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2001-2013 ATTO Technology, Inc. 68c2ecf20Sopenharmony_ci * (mailto:linuxdrivers@attotech.com) 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or 98c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License 108c2ecf20Sopenharmony_ci * as published by the Free Software Foundation; either version 2 118c2ecf20Sopenharmony_ci * of the License, or (at your option) any later version. 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, 148c2ecf20Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 158c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 168c2ecf20Sopenharmony_ci * GNU General Public License for more details. 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * NO WARRANTY 198c2ecf20Sopenharmony_ci * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 208c2ecf20Sopenharmony_ci * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 218c2ecf20Sopenharmony_ci * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 228c2ecf20Sopenharmony_ci * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 238c2ecf20Sopenharmony_ci * solely responsible for determining the appropriateness of using and 248c2ecf20Sopenharmony_ci * distributing the Program and assumes all risks associated with its 258c2ecf20Sopenharmony_ci * exercise of rights under this Agreement, including but not limited to 268c2ecf20Sopenharmony_ci * the risks and costs of program errors, damage to or loss of data, 278c2ecf20Sopenharmony_ci * programs or equipment, and unavailability or interruption of operations. 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * DISCLAIMER OF LIABILITY 308c2ecf20Sopenharmony_ci * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 318c2ecf20Sopenharmony_ci * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 328c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 338c2ecf20Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 348c2ecf20Sopenharmony_ci * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 358c2ecf20Sopenharmony_ci * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 368c2ecf20Sopenharmony_ci * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License 398c2ecf20Sopenharmony_ci * along with this program; if not, write to the Free Software 408c2ecf20Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 418c2ecf20Sopenharmony_ci * USA. 428c2ecf20Sopenharmony_ci */ 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#ifndef __esas2r_log_h__ 458c2ecf20Sopenharmony_ci#define __esas2r_log_h__ 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistruct device; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cienum { 508c2ecf20Sopenharmony_ci ESAS2R_LOG_NONE = 0, /* no events logged */ 518c2ecf20Sopenharmony_ci ESAS2R_LOG_CRIT = 1, /* critical events */ 528c2ecf20Sopenharmony_ci ESAS2R_LOG_WARN = 2, /* warning events */ 538c2ecf20Sopenharmony_ci ESAS2R_LOG_INFO = 3, /* info events */ 548c2ecf20Sopenharmony_ci ESAS2R_LOG_DEBG = 4, /* debugging events */ 558c2ecf20Sopenharmony_ci ESAS2R_LOG_TRCE = 5, /* tracing events */ 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#ifdef ESAS2R_TRACE 588c2ecf20Sopenharmony_ci ESAS2R_LOG_DFLT = ESAS2R_LOG_TRCE 598c2ecf20Sopenharmony_ci#else 608c2ecf20Sopenharmony_ci ESAS2R_LOG_DFLT = ESAS2R_LOG_WARN 618c2ecf20Sopenharmony_ci#endif 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci__printf(2, 3) int esas2r_log(const long level, const char *format, ...); 658c2ecf20Sopenharmony_ci__printf(3, 4) int esas2r_log_dev(const long level, 668c2ecf20Sopenharmony_ci const struct device *dev, 678c2ecf20Sopenharmony_ci const char *format, 688c2ecf20Sopenharmony_ci ...); 698c2ecf20Sopenharmony_ciint esas2r_log_hexdump(const long level, 708c2ecf20Sopenharmony_ci const void *buf, 718c2ecf20Sopenharmony_ci size_t len); 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* 748c2ecf20Sopenharmony_ci * the following macros are provided specifically for debugging and tracing 758c2ecf20Sopenharmony_ci * messages. esas2r_debug() is provided for generic non-hardware layer 768c2ecf20Sopenharmony_ci * debugging and tracing events. esas2r_hdebug is provided specifically for 778c2ecf20Sopenharmony_ci * hardware layer debugging and tracing events. 788c2ecf20Sopenharmony_ci */ 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#ifdef ESAS2R_DEBUG 818c2ecf20Sopenharmony_ci#define esas2r_debug(f, args ...) esas2r_log(ESAS2R_LOG_DEBG, f, ## args) 828c2ecf20Sopenharmony_ci#define esas2r_hdebug(f, args ...) esas2r_log(ESAS2R_LOG_DEBG, f, ## args) 838c2ecf20Sopenharmony_ci#else 848c2ecf20Sopenharmony_ci#define esas2r_debug(f, args ...) 858c2ecf20Sopenharmony_ci#define esas2r_hdebug(f, args ...) 868c2ecf20Sopenharmony_ci#endif /* ESAS2R_DEBUG */ 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* 898c2ecf20Sopenharmony_ci * the following macros are provided in order to trace the driver and catch 908c2ecf20Sopenharmony_ci * some more serious bugs. be warned, enabling these macros may *severely* 918c2ecf20Sopenharmony_ci * impact performance. 928c2ecf20Sopenharmony_ci */ 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#ifdef ESAS2R_TRACE 958c2ecf20Sopenharmony_ci#define esas2r_bugon() \ 968c2ecf20Sopenharmony_ci do { \ 978c2ecf20Sopenharmony_ci esas2r_log(ESAS2R_LOG_TRCE, "esas2r_bugon() called in %s:%d" \ 988c2ecf20Sopenharmony_ci " - dumping stack and stopping kernel", __func__, \ 998c2ecf20Sopenharmony_ci __LINE__); \ 1008c2ecf20Sopenharmony_ci dump_stack(); \ 1018c2ecf20Sopenharmony_ci BUG(); \ 1028c2ecf20Sopenharmony_ci } while (0) 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#define esas2r_trace_enter() esas2r_log(ESAS2R_LOG_TRCE, "entered %s (%s:%d)", \ 1058c2ecf20Sopenharmony_ci __func__, __FILE__, __LINE__) 1068c2ecf20Sopenharmony_ci#define esas2r_trace_exit() esas2r_log(ESAS2R_LOG_TRCE, "exited %s (%s:%d)", \ 1078c2ecf20Sopenharmony_ci __func__, __FILE__, __LINE__) 1088c2ecf20Sopenharmony_ci#define esas2r_trace(f, args ...) esas2r_log(ESAS2R_LOG_TRCE, "(%s:%s:%d): " \ 1098c2ecf20Sopenharmony_ci f, __func__, __FILE__, __LINE__, \ 1108c2ecf20Sopenharmony_ci ## args) 1118c2ecf20Sopenharmony_ci#else 1128c2ecf20Sopenharmony_ci#define esas2r_bugon() 1138c2ecf20Sopenharmony_ci#define esas2r_trace_enter() 1148c2ecf20Sopenharmony_ci#define esas2r_trace_exit() 1158c2ecf20Sopenharmony_ci#define esas2r_trace(f, args ...) 1168c2ecf20Sopenharmony_ci#endif /* ESAS2R_TRACE */ 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci#endif /* __esas2r_log_h__ */ 119