diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2010-08-12 01:04:37 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-08-11 09:34:37 -0400 |
commit | c8ba6c52e19c13c2b6fb9ca9e5188799c753914c (patch) | |
tree | af3d9cd6fd8082421013f59f6d436ad63f7fc614 /drivers/char | |
parent | 886275ce41a9751117367fb387ed171049eb6148 (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/char')
-rw-r--r-- | drivers/char/ipmi/ipmi_watchdog.c | 42 |
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 | */ |
197 | static int start_now; | 197 | static int start_now; |
198 | 198 | ||
199 | static int set_param_int(const char *val, struct kernel_param *kp) | 199 | static 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 | ||
218 | static int get_param_int(char *buffer, struct kernel_param *kp) | 218 | static 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 | ||
223 | typedef int (*action_fn)(const char *intval, char *outval); | 224 | typedef int (*action_fn)(const char *intval, char *outval); |
224 | 225 | ||
@@ -227,7 +228,7 @@ static int preaction_op(const char *inval, char *outval); | |||
227 | static int preop_op(const char *inval, char *outval); | 228 | static int preop_op(const char *inval, char *outval); |
228 | static void check_parms(void); | 229 | static void check_parms(void); |
229 | 230 | ||
230 | static int set_param_str(const char *val, struct kernel_param *kp) | 231 | static 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 | ||
254 | static int get_param_str(char *buffer, struct kernel_param *kp) | 255 | static 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 | ||
266 | static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp) | 267 | static 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 | ||
279 | module_param_call(ifnum_to_use, set_param_wdog_ifnum, get_param_int, | 280 | static 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 | |||
287 | static struct kernel_param_ops param_ops_str = { | ||
288 | .set = set_param_str, | ||
289 | .get = get_param_str, | ||
290 | }; | ||
291 | |||
292 | module_param(ifnum_to_use, wdog_ifnum, 0644); | ||
281 | MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog " | 293 | MODULE_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 | ||
285 | module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644); | 297 | module_param(timeout, timeout, 0644); |
286 | MODULE_PARM_DESC(timeout, "Timeout value in seconds."); | 298 | MODULE_PARM_DESC(timeout, "Timeout value in seconds."); |
287 | 299 | ||
288 | module_param_call(pretimeout, set_param_int, get_param_int, &pretimeout, 0644); | 300 | module_param(pretimeout, timeout, 0644); |
289 | MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds."); | 301 | MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds."); |
290 | 302 | ||
291 | module_param_call(action, set_param_str, get_param_str, action_op, 0644); | 303 | module_param_cb(action, ¶m_ops_str, action_op, 0644); |
292 | MODULE_PARM_DESC(action, "Timeout action. One of: " | 304 | MODULE_PARM_DESC(action, "Timeout action. One of: " |
293 | "reset, none, power_cycle, power_off."); | 305 | "reset, none, power_cycle, power_off."); |
294 | 306 | ||
295 | module_param_call(preaction, set_param_str, get_param_str, preaction_op, 0644); | 307 | module_param_cb(preaction, ¶m_ops_str, preaction_op, 0644); |
296 | MODULE_PARM_DESC(preaction, "Pretimeout action. One of: " | 308 | MODULE_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 | ||
299 | module_param_call(preop, set_param_str, get_param_str, preop_op, 0644); | 311 | module_param_cb(preop, ¶m_ops_str, preop_op, 0644); |
300 | MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: " | 312 | MODULE_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 | ||