1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 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, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * 29 * $FreeBSD$ 30 */ 31 #ifndef _LINUX_MODULEPARAM_H_ 32 #define _LINUX_MODULEPARAM_H_ 33 34 #include <linux/types.h> 35 36 /* 37 * These are presently not hooked up to anything. In linux the parameters 38 * can be set when modules are loaded. On FreeBSD these could be mapped 39 * to kenv in the future. 40 */ 41 struct kernel_param; 42 43 typedef int (*param_set_fn)(const char *val, struct kernel_param *kp); 44 typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp); 45 46 struct kernel_param { 47 const char *name; 48 u16 perm; 49 u16 flags; 50 param_set_fn set; 51 param_get_fn get; 52 union { 53 void *arg; 54 struct kparam_string *str; 55 struct kparam_array *arr; 56 } un; 57 }; 58 59 #define KPARAM_ISBOOL 2 60 61 struct kparam_string { 62 unsigned int maxlen; 63 char *string; 64 }; 65 66 struct kparam_array 67 { 68 unsigned int max; 69 unsigned int *num; 70 param_set_fn set; 71 param_get_fn get; 72 unsigned int elemsize; 73 void *elem; 74 }; 75 76 static inline void 77 param_sysinit(struct kernel_param *param) 78 { 79 } 80 81 #define module_param_call(name, set, get, arg, perm) \ 82 static struct kernel_param __param_##name = \ 83 { #name, perm, 0, set, get, { arg } }; \ 84 SYSINIT(name##_param_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST, \ 85 param_sysinit, &__param_##name); 86 87 #define module_param_string(name, string, len, perm) 88 89 #define module_param_named(name, var, type, mode) \ 90 module_param_call(name, param_set_##type, param_get_##type, &var, mode) 91 92 #define module_param(var, type, mode) \ 93 module_param_named(var, var, type, mode) 94 95 #define module_param_array(var, type, addr_argc, mode) \ 96 module_param_named(var, var, type, mode) 97 98 #define MODULE_PARM_DESC(name, desc) 99 100 static inline int 101 param_set_byte(const char *val, struct kernel_param *kp) 102 { 103 104 return 0; 105 } 106 107 static inline int 108 param_get_byte(char *buffer, struct kernel_param *kp) 109 { 110 111 return 0; 112 } 113 114 115 static inline int 116 param_set_short(const char *val, struct kernel_param *kp) 117 { 118 119 return 0; 120 } 121 122 static inline int 123 param_get_short(char *buffer, struct kernel_param *kp) 124 { 125 126 return 0; 127 } 128 129 130 static inline int 131 param_set_ushort(const char *val, struct kernel_param *kp) 132 { 133 134 return 0; 135 } 136 137 static inline int 138 param_get_ushort(char *buffer, struct kernel_param *kp) 139 { 140 141 return 0; 142 } 143 144 145 static inline int 146 param_set_int(const char *val, struct kernel_param *kp) 147 { 148 149 return 0; 150 } 151 152 static inline int 153 param_get_int(char *buffer, struct kernel_param *kp) 154 { 155 156 return 0; 157 } 158 159 160 static inline int 161 param_set_uint(const char *val, struct kernel_param *kp) 162 { 163 164 return 0; 165 } 166 167 static inline int 168 param_get_uint(char *buffer, struct kernel_param *kp) 169 { 170 171 return 0; 172 } 173 174 175 static inline int 176 param_set_long(const char *val, struct kernel_param *kp) 177 { 178 179 return 0; 180 } 181 182 static inline int 183 param_get_long(char *buffer, struct kernel_param *kp) 184 { 185 186 return 0; 187 } 188 189 190 static inline int 191 param_set_ulong(const char *val, struct kernel_param *kp) 192 { 193 194 return 0; 195 } 196 197 static inline int 198 param_get_ulong(char *buffer, struct kernel_param *kp) 199 { 200 201 return 0; 202 } 203 204 205 static inline int 206 param_set_charp(const char *val, struct kernel_param *kp) 207 { 208 209 return 0; 210 } 211 212 static inline int 213 param_get_charp(char *buffer, struct kernel_param *kp) 214 { 215 216 return 0; 217 } 218 219 220 static inline int 221 param_set_bool(const char *val, struct kernel_param *kp) 222 { 223 224 return 0; 225 } 226 227 static inline int 228 param_get_bool(char *buffer, struct kernel_param *kp) 229 { 230 231 return 0; 232 } 233 234 #endif /* _LINUX_MODULEPARAM_H_ */ 235