aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2010-08-12 01:04:37 -0400
committerRusty Russell <rusty@rustcorp.com.au>2010-08-11 09:34:37 -0400
commitc8ba6c52e19c13c2b6fb9ca9e5188799c753914c (patch)
treeaf3d9cd6fd8082421013f59f6d436ad63f7fc614 /drivers
parent886275ce41a9751117367fb387ed171049eb6148 (diff)
param: update drivers/char/ipmi/ipmi_watchdog.c to new scheme
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
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 82bcdb262a3a..654d566ca57c 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -196,7 +196,7 @@ static void ipmi_unregister_watchdog(int ipmi_intf);
196 */ 196 */
197static int start_now; 197static int start_now;
198 198
199static int set_param_int(const char *val, struct kernel_param *kp) 199static int set_param_timeout(const char *val, const struct kernel_param *kp)
200{ 200{
201 char *endp; 201 char *endp;
202 int l; 202 int l;
@@ -215,10 +215,11 @@ static int set_param_int(const char *val, struct kernel_param *kp)
215 return rv; 215 return rv;
216} 216}
217 217
218static int get_param_int(char *buffer, struct kernel_param *kp) 218static struct kernel_param_ops param_ops_timeout = {
219{ 219 .set = set_param_timeout,
220 return sprintf(buffer, "%i", *((int *)kp->arg)); 220 .get = param_get_int,
221} 221};
222#define param_check_timeout param_check_int
222 223
223typedef int (*action_fn)(const char *intval, char *outval); 224typedef int (*action_fn)(const char *intval, char *outval);
224 225
@@ -227,7 +228,7 @@ static int preaction_op(const char *inval, char *outval);
227static int preop_op(const char *inval, char *outval); 228static int preop_op(const char *inval, char *outval);
228static void check_parms(void); 229static void check_parms(void);
229 230
230static int set_param_str(const char *val, struct kernel_param *kp) 231static int set_param_str(const char *val, const struct kernel_param *kp)
231{ 232{
232 action_fn fn = (action_fn) kp->arg; 233 action_fn fn = (action_fn) kp->arg;
233 int rv = 0; 234 int rv = 0;
@@ -251,7 +252,7 @@ static int set_param_str(const char *val, struct kernel_param *kp)
251 return rv; 252 return rv;
252} 253}
253 254
254static int get_param_str(char *buffer, struct kernel_param *kp) 255static int get_param_str(char *buffer, const struct kernel_param *kp)
255{ 256{
256 action_fn fn = (action_fn) kp->arg; 257 action_fn fn = (action_fn) kp->arg;
257 int rv; 258 int rv;
@@ -263,7 +264,7 @@ static int get_param_str(char *buffer, struct kernel_param *kp)
263} 264}
264 265
265 266
266static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp) 267static int set_param_wdog_ifnum(const char *val, const struct kernel_param *kp)
267{ 268{
268 int rv = param_set_int(val, kp); 269 int rv = param_set_int(val, kp);
269 if (rv) 270 if (rv)
@@ -276,27 +277,38 @@ static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp)
276 return 0; 277 return 0;
277} 278}
278 279
279module_param_call(ifnum_to_use, set_param_wdog_ifnum, get_param_int, 280static struct kernel_param_ops param_ops_wdog_ifnum = {
280 &ifnum_to_use, 0644); 281 .set = set_param_wdog_ifnum,
282 .get = param_get_int,
283};
284
285#define param_check_wdog_ifnum param_check_int
286
287static struct kernel_param_ops param_ops_str = {
288 .set = set_param_str,
289 .get = get_param_str,
290};
291
292module_param(ifnum_to_use, wdog_ifnum, 0644);
281MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog " 293MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
282 "timer. Setting to -1 defaults to the first registered " 294 "timer. Setting to -1 defaults to the first registered "
283 "interface"); 295 "interface");
284 296
285module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644); 297module_param(timeout, timeout, 0644);
286MODULE_PARM_DESC(timeout, "Timeout value in seconds."); 298MODULE_PARM_DESC(timeout, "Timeout value in seconds.");
287 299
288module_param_call(pretimeout, set_param_int, get_param_int, &pretimeout, 0644); 300module_param(pretimeout, timeout, 0644);
289MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds."); 301MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds.");
290 302
291module_param_call(action, set_param_str, get_param_str, action_op, 0644); 303module_param_cb(action, &param_ops_str, action_op, 0644);
292MODULE_PARM_DESC(action, "Timeout action. One of: " 304MODULE_PARM_DESC(action, "Timeout action. One of: "
293 "reset, none, power_cycle, power_off."); 305 "reset, none, power_cycle, power_off.");
294 306
295module_param_call(preaction, set_param_str, get_param_str, preaction_op, 0644); 307module_param_cb(preaction, &param_ops_str, preaction_op, 0644);
296MODULE_PARM_DESC(preaction, "Pretimeout action. One of: " 308MODULE_PARM_DESC(preaction, "Pretimeout action. One of: "
297 "pre_none, pre_smi, pre_nmi, pre_int."); 309 "pre_none, pre_smi, pre_nmi, pre_int.");
298 310
299module_param_call(preop, set_param_str, get_param_str, preop_op, 0644); 311module_param_cb(preop, &param_ops_str, preop_op, 0644);
300MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: " 312MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: "
301 "preop_none, preop_panic, preop_give_data."); 313 "preop_none, preop_panic, preop_give_data.");
302 314