irqchip: Fix dependencies for archs w/o HAS_IOMEM
[linux/fpc-iii.git] / tools / perf / builtin-config.c
blobf04e804a9fadc6807a7bc74810fac5ddaad912b2
1 /*
2 * builtin-config.c
4 * Copyright (C) 2015, Taeung Song <treeze.taeung@gmail.com>
6 */
7 #include "builtin.h"
9 #include "perf.h"
11 #include "util/cache.h"
12 #include <subcmd/parse-options.h>
13 #include "util/util.h"
14 #include "util/debug.h"
16 static const char * const config_usage[] = {
17 "perf config [options]",
18 NULL
21 enum actions {
22 ACTION_LIST = 1
23 } actions;
25 static struct option config_options[] = {
26 OPT_SET_UINT('l', "list", &actions,
27 "show current config variables", ACTION_LIST),
28 OPT_END()
31 static int show_config(const char *key, const char *value,
32 void *cb __maybe_unused)
34 if (value)
35 printf("%s=%s\n", key, value);
36 else
37 printf("%s\n", key);
39 return 0;
42 int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused)
44 int ret = 0;
46 argc = parse_options(argc, argv, config_options, config_usage,
47 PARSE_OPT_STOP_AT_NON_OPTION);
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");
60 break;
61 default:
62 usage_with_options(config_usage, config_options);
65 return ret;