1 /* $NetBSD: usbhist.h,v 1.8 2021/12/11 19:24:21 mrg 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 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #ifndef _DEV_USB_USBHIST_H_ 30 #define _DEV_USB_USBHIST_H_ 31 32 #if defined(_KERNEL_OPT) 33 #include "opt_usb.h" 34 #endif 35 36 /* 37 * Make USBHIST_PRINT force on KERNHIST_PRINT for at least USBHIST_* usage. 38 */ 39 #if defined(USBHIST_PRINT) && !defined(KERNHIST_PRINT) 40 #define KERNHIST_PRINT 1 41 #endif 42 43 #include <sys/kernhist.h> 44 45 #ifdef USB_DEBUG 46 47 extern int usbdebug; 48 49 #define USBHIST_DECL(NAME) KERNHIST_DECL(NAME) 50 #define USBHIST_DEFINE(NAME) KERNHIST_DEFINE(NAME) 51 #define USBHIST_INIT(NAME,N) KERNHIST_INIT(NAME,N) 52 #define USBHIST_LINK_STATIC(NAME) KERNHIST_LINK_STATIC(NAME) 53 #define USBHIST_LOGN(NAME,N,FMT,A,B,C,D) do { \ 54 if ((NAME) >= (N)) { \ 55 KERNHIST_LOG(usbhist,FMT,A,B,C,D); \ 56 } \ 57 } while (0) 58 #define USBHIST_LOGM(NAME,N,FMT,A,B,C,D) do { \ 59 if ((NAME) & (N)) { \ 60 KERNHIST_LOG(usbhist,FMT,A,B,C,D); \ 61 } \ 62 } while (0) 63 #define USBHIST_LOG(NAME,FMT,A,B,C,D) USBHIST_LOGN(NAME,1,FMT,A,B,C,D) 64 #define USBHIST_CALLED(NAME) do { \ 65 if ((NAME) != 0) { \ 66 KERNHIST_CALLED(usbhist); \ 67 } \ 68 } while (0) 69 #define USBHIST_CALLARGS(NAME,FMT,A,B,C,D) do { \ 70 if ((NAME) != 0) { \ 71 KERNHIST_CALLARGS(usbhist,FMT,A,B,C,D); \ 72 } \ 73 } while (0) 74 #define USBHIST_CALLARGSN(NAME,N,FMT,A,B,C,D) do { \ 75 if ((NAME) >= (N)) { \ 76 KERNHIST_CALLARGS(usbhist,FMT,A,B,C,D); \ 77 } \ 78 } while (0) 79 #define USBHIST_FUNC() KERNHIST_FUNC(__func__) 80 81 USBHIST_DECL(usbhist); 82 83 #else 84 85 #define USBHIST_DECL(NAME) 86 #define USBHIST_DEFINE(NAME) 87 #define USBHIST_INIT(NAME,N) 88 #define USBHIST_LINK_STATIC(NAME) 89 #define USBHIST_LOGN(N,NAME,FMT,A,B,C,D) do { } while(0) 90 #define USBHIST_LOGM(N,NAME,FMT,A,B,C,D) do { } while(0) 91 #define USBHIST_LOG(NAME,FMT,A,B,C,D) do { } while(0) 92 #define USBHIST_CALLARGS(NAME,FMT,A,B,C,D) 93 #define USBHIST_CALLARGSN(NAME,N,FMT,A,B,C,D) 94 #define USBHIST_CALLED(NAME) 95 #define USBHIST_FUNC() 96 97 #endif 98 99 #endif /* _DEV_USBUSB_HIST_H_ */ 100