xref: /dflybsd-src/sys/dev/drm/include/linux/moduleparam.h (revision 040b675479d5bacef62d0e32dc35ddb07fe91574)
1*040b6754SFrançois Tigeot /*
2*040b6754SFrançois Tigeot  * Copyright (c) 2020 François Tigeot <ftigeot@wolfpond.org>
372c6c9b8SFrançois Tigeot  * All rights reserved.
472c6c9b8SFrançois Tigeot  *
572c6c9b8SFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
672c6c9b8SFrançois Tigeot  * modification, are permitted provided that the following conditions
772c6c9b8SFrançois Tigeot  * are met:
872c6c9b8SFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
972c6c9b8SFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
1072c6c9b8SFrançois Tigeot  *    disclaimer.
1172c6c9b8SFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
1272c6c9b8SFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
1372c6c9b8SFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
1472c6c9b8SFrançois Tigeot  *
1572c6c9b8SFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1672c6c9b8SFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1772c6c9b8SFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1872c6c9b8SFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1972c6c9b8SFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2072c6c9b8SFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2172c6c9b8SFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2272c6c9b8SFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2372c6c9b8SFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2472c6c9b8SFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2572c6c9b8SFrançois Tigeot  */
2672c6c9b8SFrançois Tigeot 
2772c6c9b8SFrançois Tigeot #ifndef _LINUX_MODULEPARAM_H_
2872c6c9b8SFrançois Tigeot #define _LINUX_MODULEPARAM_H_
2972c6c9b8SFrançois Tigeot 
3039cfddd2SFrançois Tigeot #include <linux/init.h>
3139cfddd2SFrançois Tigeot #include <linux/stringify.h>
3239cfddd2SFrançois Tigeot #include <linux/kernel.h>
3372c6c9b8SFrançois Tigeot 
3472c6c9b8SFrançois Tigeot #define MODULE_PARM_DESC(name, desc)
3572c6c9b8SFrançois Tigeot 
36*040b6754SFrançois Tigeot #define _TUNABLE_PREFIX			__stringify(KBUILD_MODNAME)
37*040b6754SFrançois Tigeot #define _TUNABLE_VAR(name)		_TUNABLE_PREFIX#name
3872c6c9b8SFrançois Tigeot 
39*040b6754SFrançois Tigeot #define TUNABLE_int(name, var)		TUNABLE_INT( _TUNABLE_VAR(.name), &(var))
4072c6c9b8SFrançois Tigeot 
41*040b6754SFrançois Tigeot #define TUNABLE_bool(name, var)		TUNABLE_INT( _TUNABLE_VAR(.name), (int *)&(var))
4272c6c9b8SFrançois Tigeot 
43*040b6754SFrançois Tigeot #define TUNABLE_uint(name, var)		TUNABLE_INT( _TUNABLE_VAR(.name), (int *)&(var))
4472c6c9b8SFrançois Tigeot 
45*040b6754SFrançois Tigeot #define TUNABLE_charp(name, var)	/* kgetenv() could be useful here */
4672c6c9b8SFrançois Tigeot 
47*040b6754SFrançois Tigeot #define module_param(var, type, mode) \
48*040b6754SFrançois Tigeot 	TUNABLE_##type(name, var)
4972c6c9b8SFrançois Tigeot 
50*040b6754SFrançois Tigeot #define module_param_unsafe(var, type, mode)	module_param(var, type, mode)
5172c6c9b8SFrançois Tigeot 
52*040b6754SFrançois Tigeot #define module_param_named(name, var, type, mode) \
53*040b6754SFrançois Tigeot 	TUNABLE_##type(name, var)
5472c6c9b8SFrançois Tigeot 
55*040b6754SFrançois Tigeot #define module_param_named_unsafe(name, var, type, mode) \
56*040b6754SFrançois Tigeot 	TUNABLE_##type((name), (var))
5772c6c9b8SFrançois Tigeot 
5872c6c9b8SFrançois Tigeot #endif	/* _LINUX_MODULEPARAM_H_ */
59