| 1 | /* $NetBSD: usbhist.h,v 1.4 2016/04/23 10:15:32 skrll Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (c) 2012 Matthew R. Green |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * 3. The name of the author may not be used to endorse or promote products |
| 16 | * derived from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | * SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #ifndef _DEV_USB_USBHIST_H_ |
| 32 | #define _DEV_USB_USBHIST_H_ |
| 33 | |
| 34 | #if defined(_KERNEL_OPT) |
| 35 | #include "opt_usb.h" |
| 36 | #endif |
| 37 | |
| 38 | /* |
| 39 | * Make USBHIST_PRINT force on KERNHIST_PRINT for at least USBHIST_* usage. |
| 40 | */ |
| 41 | #if defined(USBHIST_PRINT) && !defined(KERNHIST_PRINT) |
| 42 | #define KERNHIST_PRINT 1 |
| 43 | #endif |
| 44 | |
| 45 | #include <sys/kernhist.h> |
| 46 | |
| 47 | #ifdef USB_DEBUG |
| 48 | |
| 49 | extern int usbdebug; |
| 50 | |
| 51 | #define USBHIST_DECL(NAME) KERNHIST_DECL(NAME) |
| 52 | #define USBHIST_DEFINE(NAME) KERNHIST_DEFINE(NAME) |
| 53 | #define USBHIST_INIT(NAME,N) KERNHIST_INIT(NAME,N) |
| 54 | #define USBHIST_INIT_STATIC(NAME,BUF) KERNHIST_INIT_STATIC(NAME,BUF) |
| 55 | #define USBHIST_LINK_STATIC(NAME) KERNHIST_LINK_STATIC(NAME) |
| 56 | #define USBHIST_LOGN(NAME,N,FMT,A,B,C,D) do { \ |
| 57 | if ((NAME) >= (N)) { \ |
| 58 | KERNHIST_LOG(usbhist,FMT,A,B,C,D); \ |
| 59 | } \ |
| 60 | } while (0) |
| 61 | #define USBHIST_LOGM(NAME,N,FMT,A,B,C,D) do { \ |
| 62 | if ((NAME) & (N)) { \ |
| 63 | KERNHIST_LOG(usbhist,FMT,A,B,C,D); \ |
| 64 | } \ |
| 65 | } while (0) |
| 66 | #define USBHIST_LOG(NAME,FMT,A,B,C,D) USBHIST_LOGN(NAME,1,FMT,A,B,C,D) |
| 67 | #define USBHIST_CALLED(NAME) do { \ |
| 68 | if ((NAME) != 0) { \ |
| 69 | KERNHIST_CALLED(usbhist); \ |
| 70 | } \ |
| 71 | } while (0) |
| 72 | #define USBHIST_FUNC() KERNHIST_FUNC(__func__) |
| 73 | |
| 74 | USBHIST_DECL(usbhist); |
| 75 | |
| 76 | #else |
| 77 | |
| 78 | #define USBHIST_DECL(NAME) |
| 79 | #define USBHIST_DEFINE(NAME) |
| 80 | #define USBHIST_INIT(NAME,N) |
| 81 | #define USBHIST_INIT_STATIC(NAME,BUF) |
| 82 | #define USBHIST_LINK_STATIC(NAME) |
| 83 | #define USBHIST_LOGN(N,NAME,FMT,A,B,C,D) do { } while(0) |
| 84 | #define USBHIST_LOGM(N,NAME,FMT,A,B,C,D) do { } while(0) |
| 85 | #define USBHIST_LOG(NAME,FMT,A,B,C,D) do { } while(0) |
| 86 | #define USBHIST_CALLED(NAME) |
| 87 | #define USBHIST_FUNC() |
| 88 | |
| 89 | #endif |
| 90 | |
| 91 | #endif /* _DEV_USBUSB_HIST_H_ */ |
| 92 | |