usbhist.h revision 1.7
1/* $NetBSD: usbhist.h,v 1.7 2021/04/17 01:53:58 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 49extern 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_LINK_STATIC(NAME) KERNHIST_LINK_STATIC(NAME) 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_CALLARGS(NAME,FMT,A,B,C,D) do { \ 72 if ((NAME) != 0) { \ 73 KERNHIST_CALLARGS(usbhist,FMT,A,B,C,D); \ 74 } \ 75} while (0) 76#define USBHIST_CALLARGSN(NAME,N,FMT,A,B,C,D) do { \ 77 if ((NAME) >= (N)) { \ 78 KERNHIST_CALLARGS(usbhist,FMT,A,B,C,D); \ 79 } \ 80} while (0) 81#define USBHIST_FUNC() KERNHIST_FUNC(__func__) 82 83USBHIST_DECL(usbhist); 84 85#else 86 87#define USBHIST_DECL(NAME) 88#define USBHIST_DEFINE(NAME) 89#define USBHIST_INIT(NAME,N) 90#define USBHIST_LINK_STATIC(NAME) 91#define USBHIST_LOGN(N,NAME,FMT,A,B,C,D) do { } while(0) 92#define USBHIST_LOGM(N,NAME,FMT,A,B,C,D) do { } while(0) 93#define USBHIST_LOG(NAME,FMT,A,B,C,D) do { } while(0) 94#define USBHIST_CALLARGS(NAME,FMT,A,B,C,D) 95#define USBHIST_CALLARGSN(NAME,N,FMT,A,B,C,D) 96#define USBHIST_CALLED(NAME) 97#define USBHIST_FUNC() 98 99#endif 100 101#endif /* _DEV_USBUSB_HIST_H_ */ 102