FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

module_param: remove support for bool parameters which are really int. · fabgithub/linux@8b82528 · GitHub

Repository navigation

Commit 8b82528

Browse files
committed
module_param: remove support for bool parameters which are really int.
module_param(bool) used to counter-intuitively take an int. In fddd520 (mid-2009) we allowed bool or int/unsigned int using a messy trick. This eliminates that code (though leaves the flags field in the struct, for impending use). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 02608be commit 8b82528

2 files changed

Lines changed: 8 additions & 34 deletions

File tree

‎include/linux/moduleparam.h‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ struct kernel_param_ops {
4747
void (*free)(void *arg);
4848
};
4949

50-
/* Flag bits for kernel_param.flags */
51-
#define KPARAM_ISBOOL 2
52-
5350
struct kernel_param {
5451
const char *name;
5552
const struct kernel_param_ops *ops;
@@ -131,8 +128,7 @@ struct kparam_array
131128
* The ops can have NULL set or get functions.
132129
*/
133130
#define module_param_cb(name, ops, arg, perm) \
134-
__module_param_call(MODULE_PARAM_PREFIX, \
135-
name, ops, arg, __same_type((arg), bool *), perm)
131+
__module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm)
136132

137133
/* On alpha, ia64 and ppc64 relocations to global data cannot go into
138134
read-only sections (which is part of respective UNIX ABI on these
@@ -146,7 +142,7 @@ struct kparam_array
146142

147143
/* This is the fundamental function for registering boot/module
148144
parameters. */
149-
#define __module_param_call(prefix, name, ops, arg, isbool, perm) \
145+
#define __module_param_call(prefix, name, ops, arg, perm) \
150146
/* Default value instead of permissions? */ \
151147
static int __param_perm_check_##name __attribute__((unused)) = \
152148
BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \
@@ -155,16 +151,14 @@ struct kparam_array
155151
static struct kernel_param __moduleparam_const __param_##name \
156152
__used \
157153
__attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
158-
= { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0, \
159-
{ arg } }
154+
= { __param_str_##name, ops, perm, 0, { arg } }
160155

161156
/* Obsolete - use module_param_cb() */
162157
#define module_param_call(name, set, get, arg, perm) \
163158
static struct kernel_param_ops __param_ops_##name = \
164159
{ (void *)set, (void *)get }; \
165160
__module_param_call(MODULE_PARAM_PREFIX, \
166161
name, &__param_ops_##name, arg, \
167-
__same_type(arg, bool *), \
168162
(perm) + sizeof(__check_old_set_param(set))*0)
169163

170164
/* We don't get oldget: it's often a new-style param_get_uint, etc. */
@@ -245,8 +239,7 @@ static inline void __kernel_param_unlock(void)
245239
*/
246240
#define core_param(name, var, type, perm) \
247241
param_check_##type(name, &(var)); \
248-
__module_param_call("", name, &param_ops_##type, \
249-
&var, __same_type(var, bool), perm)
242+
__module_param_call("", name, &param_ops_##type, &var, perm)
250243
#endif /* !MODULE */
251244

252245
/**
@@ -264,7 +257,7 @@ static inline void __kernel_param_unlock(void)
264257
= { len, string }; \
265258
__module_param_call(MODULE_PARAM_PREFIX, name, \
266259
&param_ops_string, \
267-
.str = &__param_string_##name, 0, perm); \
260+
.str = &__param_string_##name, perm); \
268261
__MODULE_PARM_TYPE(name, "string")
269262

270263
/**
@@ -403,7 +396,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
403396
__module_param_call(MODULE_PARAM_PREFIX, name, \
404397
&param_array_ops, \
405398
.arr = &__param_arr_##name, \
406-
__same_type(array[0], bool), perm); \
399+
perm); \
407400
__MODULE_PARM_TYPE(name, "array of " #type)
408401

409402
extern struct kernel_param_ops param_array_ops;

‎kernel/params.c‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -297,35 +297,18 @@ EXPORT_SYMBOL(param_ops_charp);
297297
/* Actually could be a bool or an int, for historical reasons. */
298298
int param_set_bool(const char *val, const struct kernel_param *kp)
299299
{
300-
bool v;
301-
int ret;
302-
303300
/* No equals means "set"... */
304301
if (!val) val = "1";
305302

306303
/* One of =[yYnN01] */
307-
ret = strtobool(val, &v);
308-
if (ret)
309-
return ret;
310-
311-
if (kp->flags & KPARAM_ISBOOL)
312-
*(bool *)kp->arg = v;
313-
else
314-
*(int *)kp->arg = v;
315-
return 0;
304+
return strtobool(val, kp->arg);
316305
}
317306
EXPORT_SYMBOL(param_set_bool);
318307

319308
int param_get_bool(char *buffer, const struct kernel_param *kp)
320309
{
321-
bool val;
322-
if (kp->flags & KPARAM_ISBOOL)
323-
val = *(bool *)kp->arg;
324-
else
325-
val = *(int *)kp->arg;
326-
327310
/* Y and N chosen as being relatively non-coder friendly */
328-
return sprintf(buffer, "%c", val ? 'Y' : 'N');
311+
return sprintf(buffer, "%c", *(bool *)kp->arg ? 'Y' : 'N');
329312
}
330313
EXPORT_SYMBOL(param_get_bool);
331314

@@ -343,7 +326,6 @@ int param_set_invbool(const char *val, const struct kernel_param *kp)
343326
struct kernel_param dummy;
344327

345328
dummy.arg = &boolval;
346-
dummy.flags = KPARAM_ISBOOL;
347329
ret = param_set_bool(val, &dummy);
348330
if (ret == 0)
349331
*(bool *)kp->arg = !boolval;
@@ -372,7 +354,6 @@ int param_set_bint(const char *val, const struct kernel_param *kp)
372354
/* Match bool exactly, by re-using it. */
373355
boolkp = *kp;
374356
boolkp.arg = &v;
375-
boolkp.flags |= KPARAM_ISBOOL;
376357

377358
ret = param_set_bool(val, &boolkp);
378359
if (ret == 0)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL