module_param: remove support for bool parameters which are really int.
module_param(bool) used to counter-intuitively take an int. In
fddd5201
(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>
This commit is contained in:
Родитель
02608bef8f
Коммит
8b8252813d
|
@ -47,9 +47,6 @@ struct kernel_param_ops {
|
||||||
void (*free)(void *arg);
|
void (*free)(void *arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Flag bits for kernel_param.flags */
|
|
||||||
#define KPARAM_ISBOOL 2
|
|
||||||
|
|
||||||
struct kernel_param {
|
struct kernel_param {
|
||||||
const char *name;
|
const char *name;
|
||||||
const struct kernel_param_ops *ops;
|
const struct kernel_param_ops *ops;
|
||||||
|
@ -131,8 +128,7 @@ struct kparam_array
|
||||||
* The ops can have NULL set or get functions.
|
* The ops can have NULL set or get functions.
|
||||||
*/
|
*/
|
||||||
#define module_param_cb(name, ops, arg, perm) \
|
#define module_param_cb(name, ops, arg, perm) \
|
||||||
__module_param_call(MODULE_PARAM_PREFIX, \
|
__module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm)
|
||||||
name, ops, arg, __same_type((arg), bool *), perm)
|
|
||||||
|
|
||||||
/* On alpha, ia64 and ppc64 relocations to global data cannot go into
|
/* On alpha, ia64 and ppc64 relocations to global data cannot go into
|
||||||
read-only sections (which is part of respective UNIX ABI on these
|
read-only sections (which is part of respective UNIX ABI on these
|
||||||
|
@ -146,7 +142,7 @@ struct kparam_array
|
||||||
|
|
||||||
/* This is the fundamental function for registering boot/module
|
/* This is the fundamental function for registering boot/module
|
||||||
parameters. */
|
parameters. */
|
||||||
#define __module_param_call(prefix, name, ops, arg, isbool, perm) \
|
#define __module_param_call(prefix, name, ops, arg, perm) \
|
||||||
/* Default value instead of permissions? */ \
|
/* Default value instead of permissions? */ \
|
||||||
static int __param_perm_check_##name __attribute__((unused)) = \
|
static int __param_perm_check_##name __attribute__((unused)) = \
|
||||||
BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \
|
BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \
|
||||||
|
@ -155,8 +151,7 @@ struct kparam_array
|
||||||
static struct kernel_param __moduleparam_const __param_##name \
|
static struct kernel_param __moduleparam_const __param_##name \
|
||||||
__used \
|
__used \
|
||||||
__attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
|
__attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
|
||||||
= { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0, \
|
= { __param_str_##name, ops, perm, 0, { arg } }
|
||||||
{ arg } }
|
|
||||||
|
|
||||||
/* Obsolete - use module_param_cb() */
|
/* Obsolete - use module_param_cb() */
|
||||||
#define module_param_call(name, set, get, arg, perm) \
|
#define module_param_call(name, set, get, arg, perm) \
|
||||||
|
@ -164,7 +159,6 @@ struct kparam_array
|
||||||
{ (void *)set, (void *)get }; \
|
{ (void *)set, (void *)get }; \
|
||||||
__module_param_call(MODULE_PARAM_PREFIX, \
|
__module_param_call(MODULE_PARAM_PREFIX, \
|
||||||
name, &__param_ops_##name, arg, \
|
name, &__param_ops_##name, arg, \
|
||||||
__same_type(arg, bool *), \
|
|
||||||
(perm) + sizeof(__check_old_set_param(set))*0)
|
(perm) + sizeof(__check_old_set_param(set))*0)
|
||||||
|
|
||||||
/* We don't get oldget: it's often a new-style param_get_uint, etc. */
|
/* 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)
|
||||||
*/
|
*/
|
||||||
#define core_param(name, var, type, perm) \
|
#define core_param(name, var, type, perm) \
|
||||||
param_check_##type(name, &(var)); \
|
param_check_##type(name, &(var)); \
|
||||||
__module_param_call("", name, ¶m_ops_##type, \
|
__module_param_call("", name, ¶m_ops_##type, &var, perm)
|
||||||
&var, __same_type(var, bool), perm)
|
|
||||||
#endif /* !MODULE */
|
#endif /* !MODULE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,7 +257,7 @@ static inline void __kernel_param_unlock(void)
|
||||||
= { len, string }; \
|
= { len, string }; \
|
||||||
__module_param_call(MODULE_PARAM_PREFIX, name, \
|
__module_param_call(MODULE_PARAM_PREFIX, name, \
|
||||||
¶m_ops_string, \
|
¶m_ops_string, \
|
||||||
.str = &__param_string_##name, 0, perm); \
|
.str = &__param_string_##name, perm); \
|
||||||
__MODULE_PARM_TYPE(name, "string")
|
__MODULE_PARM_TYPE(name, "string")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -403,7 +396,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
|
||||||
__module_param_call(MODULE_PARAM_PREFIX, name, \
|
__module_param_call(MODULE_PARAM_PREFIX, name, \
|
||||||
¶m_array_ops, \
|
¶m_array_ops, \
|
||||||
.arr = &__param_arr_##name, \
|
.arr = &__param_arr_##name, \
|
||||||
__same_type(array[0], bool), perm); \
|
perm); \
|
||||||
__MODULE_PARM_TYPE(name, "array of " #type)
|
__MODULE_PARM_TYPE(name, "array of " #type)
|
||||||
|
|
||||||
extern struct kernel_param_ops param_array_ops;
|
extern struct kernel_param_ops param_array_ops;
|
||||||
|
|
|
@ -297,35 +297,18 @@ EXPORT_SYMBOL(param_ops_charp);
|
||||||
/* Actually could be a bool or an int, for historical reasons. */
|
/* Actually could be a bool or an int, for historical reasons. */
|
||||||
int param_set_bool(const char *val, const struct kernel_param *kp)
|
int param_set_bool(const char *val, const struct kernel_param *kp)
|
||||||
{
|
{
|
||||||
bool v;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* No equals means "set"... */
|
/* No equals means "set"... */
|
||||||
if (!val) val = "1";
|
if (!val) val = "1";
|
||||||
|
|
||||||
/* One of =[yYnN01] */
|
/* One of =[yYnN01] */
|
||||||
ret = strtobool(val, &v);
|
return strtobool(val, kp->arg);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (kp->flags & KPARAM_ISBOOL)
|
|
||||||
*(bool *)kp->arg = v;
|
|
||||||
else
|
|
||||||
*(int *)kp->arg = v;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(param_set_bool);
|
EXPORT_SYMBOL(param_set_bool);
|
||||||
|
|
||||||
int param_get_bool(char *buffer, const struct kernel_param *kp)
|
int param_get_bool(char *buffer, const struct kernel_param *kp)
|
||||||
{
|
{
|
||||||
bool val;
|
|
||||||
if (kp->flags & KPARAM_ISBOOL)
|
|
||||||
val = *(bool *)kp->arg;
|
|
||||||
else
|
|
||||||
val = *(int *)kp->arg;
|
|
||||||
|
|
||||||
/* Y and N chosen as being relatively non-coder friendly */
|
/* Y and N chosen as being relatively non-coder friendly */
|
||||||
return sprintf(buffer, "%c", val ? 'Y' : 'N');
|
return sprintf(buffer, "%c", *(bool *)kp->arg ? 'Y' : 'N');
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(param_get_bool);
|
EXPORT_SYMBOL(param_get_bool);
|
||||||
|
|
||||||
|
@ -343,7 +326,6 @@ int param_set_invbool(const char *val, const struct kernel_param *kp)
|
||||||
struct kernel_param dummy;
|
struct kernel_param dummy;
|
||||||
|
|
||||||
dummy.arg = &boolval;
|
dummy.arg = &boolval;
|
||||||
dummy.flags = KPARAM_ISBOOL;
|
|
||||||
ret = param_set_bool(val, &dummy);
|
ret = param_set_bool(val, &dummy);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
*(bool *)kp->arg = !boolval;
|
*(bool *)kp->arg = !boolval;
|
||||||
|
@ -372,7 +354,6 @@ int param_set_bint(const char *val, const struct kernel_param *kp)
|
||||||
/* Match bool exactly, by re-using it. */
|
/* Match bool exactly, by re-using it. */
|
||||||
boolkp = *kp;
|
boolkp = *kp;
|
||||||
boolkp.arg = &v;
|
boolkp.arg = &v;
|
||||||
boolkp.flags |= KPARAM_ISBOOL;
|
|
||||||
|
|
||||||
ret = param_set_bool(val, &boolkp);
|
ret = param_set_bool(val, &boolkp);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче