usbhist.h revision 1.1.2.1 1 /* $NetBSD: usbhist.h,v 1.1.2.1 2015/03/09 13:55:49 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 USBHIST
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_LOGN(NAME,N,FMT,A,B,C,D) do { \
56 if ((NAME) >= (N)) { \
57 KERNHIST_LOG(usbhist,FMT,A,B,C,D); \
58 } \
59 } while (0)
60 #define USBHIST_LOGM(NAME,N,FMT,A,B,C,D) do { \
61 if ((NAME) & (N)) { \
62 KERNHIST_LOG(usbhist,FMT,A,B,C,D); \
63 } \
64 } while (0)
65 #define USBHIST_LOG(NAME,FMT,A,B,C,D) USBHIST_LOGN(NAME,1,FMT,A,B,C,D)
66 #define USBHIST_CALLED(NAME) do { \
67 if ((NAME) != 0) { \
68 KERNHIST_CALLED(usbhist); \
69 } \
70 } while (0)
71 #define USBHIST_FUNC() KERNHIST_FUNC(__func__)
72
73 USBHIST_DECL(usbhist);
74
75 #else
76
77 #define USBHIST_DECL(NAME)
78 #define USBHIST_DEFINE(NAME)
79 #define USBHIST_INIT(NAME,N)
80 #define USBHIST_INIT_STATIC(NAME,BUF)
81 #define USBHIST_LOGN(N,NAME,FMT,A,B,C,D) do { } while(0)
82 #define USBHIST_LOG(NAME,FMT,A,B,C,D) do { } while(0)
83 #define USBHIST_CALLED(NAME)
84 #define USBHIST_FUNC()
85
86 #endif
87
88 #endif /* _DEV_USBUSB_HIST_H_ */
89