usbhist.h revision 1.3 1 /* $NetBSD: usbhist.h,v 1.3 2015/10/29 00:15:48 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 * 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_LOG(NAME,FMT,A,B,C,D) USBHIST_LOGN(NAME,1,FMT,A,B,C,D)
62 #define USBHIST_CALLED(NAME) do { \
63 if ((NAME) != 0) { \
64 KERNHIST_CALLED(usbhist); \
65 } \
66 } while (0)
67 #define USBHIST_FUNC() KERNHIST_FUNC(__func__)
68
69 USBHIST_DECL(usbhist);
70
71 #else
72
73 #define USBHIST_DECL(NAME)
74 #define USBHIST_DEFINE(NAME)
75 #define USBHIST_INIT(NAME,N)
76 #define USBHIST_INIT_STATIC(NAME,BUF)
77 #define USBHIST_LINK_STATIC(NAME)
78 #define USBHIST_LOGN(N,NAME,FMT,A,B,C,D) do { } while(0)
79 #define USBHIST_LOG(NAME,FMT,A,B,C,D) do { } while(0)
80 #define USBHIST_CALLED(NAME)
81 #define USBHIST_FUNC()
82
83 #endif
84
85 #endif /* _DEV_USBUSB_HIST_H_ */
86