Skip to content

Commit

Permalink
param: update drivers/char/ipmi/ipmi_watchdog.c to new scheme
Browse files Browse the repository at this point in the history
This is one of the most interesting users of module parameters in the
tree, so weaning it off the old-style non-const module_param_call
scheme is a useful exercise.

I was confused by set_param_int/get_param_int (vs. the normal
param_set_int and param_get_int), so I renamed set_param_int to
set_param_timeout, and re-used param_get_int directly instead of
get_param_int.  I also implemented param_check_wdog_ifnum and
param_check_timeout, so now the ifnum_to_use and timeout/pretimeout
parameters can just use plain module_param().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Corey Minyard <minyard@acm.org>
Cc: openipmi-developer@lists.sourceforge.net
  • Loading branch information
Rusty Russell committed Aug 11, 2010
1 parent 886275c commit c8ba6c5
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions drivers/char/ipmi/ipmi_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static void ipmi_unregister_watchdog(int ipmi_intf);
*/
static int start_now;

static int set_param_int(const char *val, struct kernel_param *kp)
static int set_param_timeout(const char *val, const struct kernel_param *kp)
{
char *endp;
int l;
Expand All @@ -215,10 +215,11 @@ static int set_param_int(const char *val, struct kernel_param *kp)
return rv;
}

static int get_param_int(char *buffer, struct kernel_param *kp)
{
return sprintf(buffer, "%i", *((int *)kp->arg));
}
static struct kernel_param_ops param_ops_timeout = {
.set = set_param_timeout,
.get = param_get_int,
};
#define param_check_timeout param_check_int

typedef int (*action_fn)(const char *intval, char *outval);

Expand All @@ -227,7 +228,7 @@ static int preaction_op(const char *inval, char *outval);
static int preop_op(const char *inval, char *outval);
static void check_parms(void);

static int set_param_str(const char *val, struct kernel_param *kp)
static int set_param_str(const char *val, const struct kernel_param *kp)
{
action_fn fn = (action_fn) kp->arg;
int rv = 0;
Expand All @@ -251,7 +252,7 @@ static int set_param_str(const char *val, struct kernel_param *kp)
return rv;
}

static int get_param_str(char *buffer, struct kernel_param *kp)
static int get_param_str(char *buffer, const struct kernel_param *kp)
{
action_fn fn = (action_fn) kp->arg;
int rv;
Expand All @@ -263,7 +264,7 @@ static int get_param_str(char *buffer, struct kernel_param *kp)
}


static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp)
static int set_param_wdog_ifnum(const char *val, const struct kernel_param *kp)
{
int rv = param_set_int(val, kp);
if (rv)
Expand All @@ -276,27 +277,38 @@ static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp)
return 0;
}

module_param_call(ifnum_to_use, set_param_wdog_ifnum, get_param_int,
&ifnum_to_use, 0644);
static struct kernel_param_ops param_ops_wdog_ifnum = {
.set = set_param_wdog_ifnum,
.get = param_get_int,
};

#define param_check_wdog_ifnum param_check_int

static struct kernel_param_ops param_ops_str = {
.set = set_param_str,
.get = get_param_str,
};

module_param(ifnum_to_use, wdog_ifnum, 0644);
MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
"timer. Setting to -1 defaults to the first registered "
"interface");

module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644);
module_param(timeout, timeout, 0644);
MODULE_PARM_DESC(timeout, "Timeout value in seconds.");

module_param_call(pretimeout, set_param_int, get_param_int, &pretimeout, 0644);
module_param(pretimeout, timeout, 0644);
MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds.");

module_param_call(action, set_param_str, get_param_str, action_op, 0644);
module_param_cb(action, &param_ops_str, action_op, 0644);
MODULE_PARM_DESC(action, "Timeout action. One of: "
"reset, none, power_cycle, power_off.");

module_param_call(preaction, set_param_str, get_param_str, preaction_op, 0644);
module_param_cb(preaction, &param_ops_str, preaction_op, 0644);
MODULE_PARM_DESC(preaction, "Pretimeout action. One of: "
"pre_none, pre_smi, pre_nmi, pre_int.");

module_param_call(preop, set_param_str, get_param_str, preop_op, 0644);
module_param_cb(preop, &param_ops_str, preop_op, 0644);
MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: "
"preop_none, preop_panic, preop_give_data.");

Expand Down

0 comments on commit c8ba6c5

Please sign in to comment.