Merge tag 'drm/tegra/for-4.5-rc7' of git://anongit.freedesktop.org/tegra/linux into...
[deliverable/linux.git] / tools / perf / builtin-config.c
1 /*
2 * builtin-config.c
3 *
4 * Copyright (C) 2015, Taeung Song <treeze.taeung@gmail.com>
5 *
6 */
7 #include "builtin.h"
8
9 #include "perf.h"
10
11 #include "util/cache.h"
12 #include <subcmd/parse-options.h>
13 #include "util/util.h"
14 #include "util/debug.h"
15
16 static const char * const config_usage[] = {
17 "perf config [options]",
18 NULL
19 };
20
21 enum actions {
22 ACTION_LIST = 1
23 } actions;
24
25 static struct option config_options[] = {
26 OPT_SET_UINT('l', "list", &actions,
27 "show current config variables", ACTION_LIST),
28 OPT_END()
29 };
30
31 static int show_config(const char *key, const char *value,
32 void *cb __maybe_unused)
33 {
34 if (value)
35 printf("%s=%s\n", key, value);
36 else
37 printf("%s\n", key);
38
39 return 0;
40 }
41
42 int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
43 {
44 int ret = 0;
45
46 argc = parse_options(argc, argv, config_options, config_usage,
47 PARSE_OPT_STOP_AT_NON_OPTION);
48
49 switch (actions) {
50 case ACTION_LIST:
51 if (argc) {
52 pr_err("Error: takes no arguments\n");
53 parse_options_usage(config_usage, config_options, "l", 1);
54 } else {
55 ret = perf_config(show_config, NULL);
56 if (ret < 0)
57 pr_err("Nothing configured, "
58 "please check your ~/.perfconfig file\n");
59 }
60 break;
61 default:
62 usage_with_options(config_usage, config_options);
63 }
64
65 return ret;
66 }
This page took 0.031773 seconds and 5 git commands to generate.