diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dynamic_debug.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 02afc2533728..84d103c474e4 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -429,6 +429,27 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, | |||
429 | return 0; | 429 | return 0; |
430 | } | 430 | } |
431 | 431 | ||
432 | static int ddebug_exec_query(char *query_string) | ||
433 | { | ||
434 | unsigned int flags = 0, mask = 0; | ||
435 | struct ddebug_query query; | ||
436 | #define MAXWORDS 9 | ||
437 | int nwords; | ||
438 | char *words[MAXWORDS]; | ||
439 | |||
440 | nwords = ddebug_tokenize(query_string, words, MAXWORDS); | ||
441 | if (nwords <= 0) | ||
442 | return -EINVAL; | ||
443 | if (ddebug_parse_query(words, nwords-1, &query)) | ||
444 | return -EINVAL; | ||
445 | if (ddebug_parse_flags(words[nwords-1], &flags, &mask)) | ||
446 | return -EINVAL; | ||
447 | |||
448 | /* actually go and implement the change */ | ||
449 | ddebug_change(&query, flags, mask); | ||
450 | return 0; | ||
451 | } | ||
452 | |||
432 | /* | 453 | /* |
433 | * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the | 454 | * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the |
434 | * command text from userspace, parses and executes it. | 455 | * command text from userspace, parses and executes it. |
@@ -436,12 +457,8 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, | |||
436 | static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, | 457 | static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, |
437 | size_t len, loff_t *offp) | 458 | size_t len, loff_t *offp) |
438 | { | 459 | { |
439 | unsigned int flags = 0, mask = 0; | ||
440 | struct ddebug_query query; | ||
441 | #define MAXWORDS 9 | ||
442 | int nwords; | ||
443 | char *words[MAXWORDS]; | ||
444 | char tmpbuf[256]; | 460 | char tmpbuf[256]; |
461 | int ret; | ||
445 | 462 | ||
446 | if (len == 0) | 463 | if (len == 0) |
447 | return 0; | 464 | return 0; |
@@ -455,16 +472,9 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, | |||
455 | printk(KERN_INFO "%s: read %d bytes from userspace\n", | 472 | printk(KERN_INFO "%s: read %d bytes from userspace\n", |
456 | __func__, (int)len); | 473 | __func__, (int)len); |
457 | 474 | ||
458 | nwords = ddebug_tokenize(tmpbuf, words, MAXWORDS); | 475 | ret = ddebug_exec_query(tmpbuf); |
459 | if (nwords <= 0) | 476 | if (ret) |
460 | return -EINVAL; | 477 | return ret; |
461 | if (ddebug_parse_query(words, nwords-1, &query)) | ||
462 | return -EINVAL; | ||
463 | if (ddebug_parse_flags(words[nwords-1], &flags, &mask)) | ||
464 | return -EINVAL; | ||
465 | |||
466 | /* actually go and implement the change */ | ||
467 | ddebug_change(&query, flags, mask); | ||
468 | 478 | ||
469 | *offp += len; | 479 | *offp += len; |
470 | return len; | 480 | return len; |