diff options
Diffstat (limited to 'include/linux/wimax/debug.h')
-rw-r--r-- | include/linux/wimax/debug.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/include/linux/wimax/debug.h b/include/linux/wimax/debug.h index c703e0340423..57031b4d12f2 100644 --- a/include/linux/wimax/debug.h +++ b/include/linux/wimax/debug.h | |||
@@ -155,6 +155,7 @@ | |||
155 | 155 | ||
156 | #include <linux/types.h> | 156 | #include <linux/types.h> |
157 | #include <linux/device.h> | 157 | #include <linux/device.h> |
158 | #include <linux/slab.h> | ||
158 | 159 | ||
159 | 160 | ||
160 | /* Backend stuff */ | 161 | /* Backend stuff */ |
@@ -450,4 +451,76 @@ do { \ | |||
450 | }) | 451 | }) |
451 | 452 | ||
452 | 453 | ||
454 | static inline | ||
455 | void d_submodule_set(struct d_level *d_level, size_t d_level_size, | ||
456 | const char *submodule, u8 level, const char *tag) | ||
457 | { | ||
458 | struct d_level *itr, *top; | ||
459 | int index = -1; | ||
460 | |||
461 | for (itr = d_level, top = itr + d_level_size; itr < top; itr++) { | ||
462 | index++; | ||
463 | if (itr->name == NULL) { | ||
464 | printk(KERN_ERR "%s: itr->name NULL?? (%p, #%d)\n", | ||
465 | tag, itr, index); | ||
466 | continue; | ||
467 | } | ||
468 | if (!strcmp(itr->name, submodule)) { | ||
469 | itr->level = level; | ||
470 | return; | ||
471 | } | ||
472 | } | ||
473 | printk(KERN_ERR "%s: unknown submodule %s\n", tag, submodule); | ||
474 | } | ||
475 | |||
476 | |||
477 | /** | ||
478 | * d_parse_params - Parse a string with debug parameters from the | ||
479 | * command line | ||
480 | * | ||
481 | * @d_level: level structure (D_LEVEL) | ||
482 | * @d_level_size: number of items in the level structure | ||
483 | * (D_LEVEL_SIZE). | ||
484 | * @_params: string with the parameters; this is a space (not tab!) | ||
485 | * separated list of NAME:VALUE, where value is the debug level | ||
486 | * and NAME is the name of the submodule. | ||
487 | * @tag: string for error messages (example: MODULE.ARGNAME). | ||
488 | */ | ||
489 | static inline | ||
490 | void d_parse_params(struct d_level *d_level, size_t d_level_size, | ||
491 | const char *_params, const char *tag) | ||
492 | { | ||
493 | char submodule[130], *params, *params_orig, *token, *colon; | ||
494 | unsigned level, tokens; | ||
495 | |||
496 | if (_params == NULL) | ||
497 | return; | ||
498 | params_orig = kstrdup(_params, GFP_KERNEL); | ||
499 | params = params_orig; | ||
500 | while (1) { | ||
501 | token = strsep(¶ms, " "); | ||
502 | if (token == NULL) | ||
503 | break; | ||
504 | if (*token == '\0') /* eat joint spaces */ | ||
505 | continue; | ||
506 | /* kernel's sscanf %s eats until whitespace, so we | ||
507 | * replace : by \n so it doesn't get eaten later by | ||
508 | * strsep */ | ||
509 | colon = strchr(token, ':'); | ||
510 | if (colon != NULL) | ||
511 | *colon = '\n'; | ||
512 | tokens = sscanf(token, "%s\n%u", submodule, &level); | ||
513 | if (colon != NULL) | ||
514 | *colon = ':'; /* set back, for error messages */ | ||
515 | if (tokens == 2) | ||
516 | d_submodule_set(d_level, d_level_size, | ||
517 | submodule, level, tag); | ||
518 | else | ||
519 | printk(KERN_ERR "%s: can't parse '%s' as a " | ||
520 | "SUBMODULE:LEVEL (%d tokens)\n", | ||
521 | tag, token, tokens); | ||
522 | } | ||
523 | kfree(params_orig); | ||
524 | } | ||
525 | |||
453 | #endif /* #ifndef __debug__h__ */ | 526 | #endif /* #ifndef __debug__h__ */ |