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