diff options
Diffstat (limited to 'include/linux/moduleparam.h')
| -rw-r--r-- | include/linux/moduleparam.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 6d48831fe7d2..ca74a3402d63 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
| @@ -130,6 +130,62 @@ __check_old_set_param(int (*oldset)(const char *, struct kernel_param *)) | |||
| 130 | #define module_param(name, type, perm) \ | 130 | #define module_param(name, type, perm) \ |
| 131 | module_param_named(name, name, type, perm) | 131 | module_param_named(name, name, type, perm) |
| 132 | 132 | ||
| 133 | /** | ||
| 134 | * kparam_block_sysfs_write - make sure a parameter isn't written via sysfs. | ||
| 135 | * @name: the name of the parameter | ||
| 136 | * | ||
| 137 | * There's no point blocking write on a paramter that isn't writable via sysfs! | ||
| 138 | */ | ||
| 139 | #define kparam_block_sysfs_write(name) \ | ||
| 140 | do { \ | ||
| 141 | BUG_ON(!(__param_##name.perm & 0222)); \ | ||
| 142 | __kernel_param_lock(); \ | ||
| 143 | } while (0) | ||
| 144 | |||
| 145 | /** | ||
| 146 | * kparam_unblock_sysfs_write - allows sysfs to write to a parameter again. | ||
| 147 | * @name: the name of the parameter | ||
| 148 | */ | ||
| 149 | #define kparam_unblock_sysfs_write(name) \ | ||
| 150 | do { \ | ||
| 151 | BUG_ON(!(__param_##name.perm & 0222)); \ | ||
| 152 | __kernel_param_unlock(); \ | ||
| 153 | } while (0) | ||
| 154 | |||
| 155 | /** | ||
| 156 | * kparam_block_sysfs_read - make sure a parameter isn't read via sysfs. | ||
| 157 | * @name: the name of the parameter | ||
| 158 | * | ||
| 159 | * This also blocks sysfs writes. | ||
| 160 | */ | ||
| 161 | #define kparam_block_sysfs_read(name) \ | ||
| 162 | do { \ | ||
| 163 | BUG_ON(!(__param_##name.perm & 0444)); \ | ||
| 164 | __kernel_param_lock(); \ | ||
| 165 | } while (0) | ||
| 166 | |||
| 167 | /** | ||
| 168 | * kparam_unblock_sysfs_read - allows sysfs to read a parameter again. | ||
| 169 | * @name: the name of the parameter | ||
| 170 | */ | ||
| 171 | #define kparam_unblock_sysfs_read(name) \ | ||
| 172 | do { \ | ||
| 173 | BUG_ON(!(__param_##name.perm & 0444)); \ | ||
| 174 | __kernel_param_unlock(); \ | ||
| 175 | } while (0) | ||
| 176 | |||
| 177 | #ifdef CONFIG_SYSFS | ||
| 178 | extern void __kernel_param_lock(void); | ||
| 179 | extern void __kernel_param_unlock(void); | ||
| 180 | #else | ||
| 181 | static inline void __kernel_param_lock(void) | ||
| 182 | { | ||
| 183 | } | ||
| 184 | static inline void __kernel_param_unlock(void) | ||
| 185 | { | ||
| 186 | } | ||
| 187 | #endif | ||
| 188 | |||
| 133 | #ifndef MODULE | 189 | #ifndef MODULE |
| 134 | /** | 190 | /** |
| 135 | * core_param - define a historical core kernel parameter. | 191 | * core_param - define a historical core kernel parameter. |
