diff options
author | Jan Beulich <jbeulich@novell.com> | 2007-10-17 02:29:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:42:56 -0400 |
commit | 22e48eaf587d044ba311a73c6fe0d0deaa8fdb63 (patch) | |
tree | 8407d8f3f9a69b275e9008249e678499ce92253d /include | |
parent | d5aa0daf6d9f327a9c13bc3a203bfac2b8707e2f (diff) |
constify string/array kparam tracking structures
.. in an effort to make read-only whatever can be made, so that
CONFIG_DEBUG_RODATA can catch as many issues as possible.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/moduleparam.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index c83588c8d08b..13410b20600f 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h | |||
@@ -38,7 +38,11 @@ struct kernel_param { | |||
38 | unsigned int perm; | 38 | unsigned int perm; |
39 | param_set_fn set; | 39 | param_set_fn set; |
40 | param_get_fn get; | 40 | param_get_fn get; |
41 | void *arg; | 41 | union { |
42 | void *arg; | ||
43 | const struct kparam_string *str; | ||
44 | const struct kparam_array *arr; | ||
45 | }; | ||
42 | }; | 46 | }; |
43 | 47 | ||
44 | /* Special one for strings we want to copy into */ | 48 | /* Special one for strings we want to copy into */ |
@@ -66,11 +70,11 @@ struct kparam_array | |||
66 | /* Default value instead of permissions? */ \ | 70 | /* Default value instead of permissions? */ \ |
67 | static int __param_perm_check_##name __attribute__((unused)) = \ | 71 | static int __param_perm_check_##name __attribute__((unused)) = \ |
68 | BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ | 72 | BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ |
69 | static char __param_str_##name[] = prefix #name; \ | 73 | static const char __param_str_##name[] = prefix #name; \ |
70 | static struct kernel_param const __param_##name \ | 74 | static struct kernel_param const __param_##name \ |
71 | __attribute_used__ \ | 75 | __attribute_used__ \ |
72 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ | 76 | __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ |
73 | = { __param_str_##name, perm, set, get, arg } | 77 | = { __param_str_##name, perm, set, get, { arg } } |
74 | 78 | ||
75 | #define module_param_call(name, set, get, arg, perm) \ | 79 | #define module_param_call(name, set, get, arg, perm) \ |
76 | __module_param_call(MODULE_PARAM_PREFIX, name, set, get, arg, perm) | 80 | __module_param_call(MODULE_PARAM_PREFIX, name, set, get, arg, perm) |
@@ -88,10 +92,10 @@ struct kparam_array | |||
88 | 92 | ||
89 | /* Actually copy string: maxlen param is usually sizeof(string). */ | 93 | /* Actually copy string: maxlen param is usually sizeof(string). */ |
90 | #define module_param_string(name, string, len, perm) \ | 94 | #define module_param_string(name, string, len, perm) \ |
91 | static struct kparam_string __param_string_##name \ | 95 | static const struct kparam_string __param_string_##name \ |
92 | = { len, string }; \ | 96 | = { len, string }; \ |
93 | module_param_call(name, param_set_copystring, param_get_string, \ | 97 | module_param_call(name, param_set_copystring, param_get_string, \ |
94 | &__param_string_##name, perm); \ | 98 | .str = &__param_string_##name, perm); \ |
95 | __MODULE_PARM_TYPE(name, "string") | 99 | __MODULE_PARM_TYPE(name, "string") |
96 | 100 | ||
97 | /* Called on module insert or kernel boot */ | 101 | /* Called on module insert or kernel boot */ |
@@ -149,11 +153,11 @@ extern int param_get_invbool(char *buffer, struct kernel_param *kp); | |||
149 | 153 | ||
150 | /* Comma-separated array: *nump is set to number they actually specified. */ | 154 | /* Comma-separated array: *nump is set to number they actually specified. */ |
151 | #define module_param_array_named(name, array, type, nump, perm) \ | 155 | #define module_param_array_named(name, array, type, nump, perm) \ |
152 | static struct kparam_array __param_arr_##name \ | 156 | static const struct kparam_array __param_arr_##name \ |
153 | = { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type,\ | 157 | = { ARRAY_SIZE(array), nump, param_set_##type, param_get_##type,\ |
154 | sizeof(array[0]), array }; \ | 158 | sizeof(array[0]), array }; \ |
155 | module_param_call(name, param_array_set, param_array_get, \ | 159 | module_param_call(name, param_array_set, param_array_get, \ |
156 | &__param_arr_##name, perm); \ | 160 | .arr = &__param_arr_##name, perm); \ |
157 | __MODULE_PARM_TYPE(name, "array of " #type) | 161 | __MODULE_PARM_TYPE(name, "array of " #type) |
158 | 162 | ||
159 | #define module_param_array(name, type, nump, perm) \ | 163 | #define module_param_array(name, type, nump, perm) \ |