Commit 210369dc authored by Prarit Bhargava's avatar Prarit Bhargava Committed by Andy Shevchenko

tools/power/x86/intel-speed-select: Make process_command generic

Make the process_command take any help command and command list.  This
will make it easier to help commands and a command list for CascadeLake-N.
Signed-off-by: default avatarPrarit Bhargava <prarit@redhat.com>
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent ce1326a2
...@@ -1816,7 +1816,9 @@ static struct process_cmd_help_struct isst_help_cmds[] = { ...@@ -1816,7 +1816,9 @@ static struct process_cmd_help_struct isst_help_cmds[] = {
{ NULL, NULL } { NULL, NULL }
}; };
void process_command(int argc, char **argv) void process_command(int argc, char **argv,
struct process_cmd_help_struct *help_cmds,
struct process_cmd_struct *cmds)
{ {
int i = 0, matched = 0; int i = 0, matched = 0;
char *feature = argv[optind]; char *feature = argv[optind];
...@@ -1827,9 +1829,9 @@ void process_command(int argc, char **argv) ...@@ -1827,9 +1829,9 @@ void process_command(int argc, char **argv)
debug_printf("feature name [%s] command [%s]\n", feature, cmd); debug_printf("feature name [%s] command [%s]\n", feature, cmd);
if (!strcmp(cmd, "-h") || !strcmp(cmd, "--help")) { if (!strcmp(cmd, "-h") || !strcmp(cmd, "--help")) {
while (isst_help_cmds[i].feature) { while (help_cmds[i].feature) {
if (!strcmp(isst_help_cmds[i].feature, feature)) { if (!strcmp(help_cmds[i].feature, feature)) {
isst_help_cmds[i].process_fn(); help_cmds[i].process_fn();
exit(0); exit(0);
} }
++i; ++i;
...@@ -1839,11 +1841,11 @@ void process_command(int argc, char **argv) ...@@ -1839,11 +1841,11 @@ void process_command(int argc, char **argv)
create_cpu_map(); create_cpu_map();
i = 0; i = 0;
while (isst_cmds[i].feature) { while (cmds[i].feature) {
if (!strcmp(isst_cmds[i].feature, feature) && if (!strcmp(cmds[i].feature, feature) &&
!strcmp(isst_cmds[i].command, cmd)) { !strcmp(cmds[i].command, cmd)) {
parse_cmd_args(argc, optind + 1, argv); parse_cmd_args(argc, optind + 1, argv);
isst_cmds[i].process_fn(isst_cmds[i].arg); cmds[i].process_fn(cmds[i].arg);
matched = 1; matched = 1;
break; break;
} }
...@@ -1964,7 +1966,7 @@ static void cmdline(int argc, char **argv) ...@@ -1964,7 +1966,7 @@ static void cmdline(int argc, char **argv)
if (ret) if (ret)
goto out; goto out;
process_command(argc, argv); process_command(argc, argv, isst_help_cmds, isst_cmds);
out: out:
free_cpu_set(present_cpumask); free_cpu_set(present_cpumask);
free_cpu_set(target_cpumask); free_cpu_set(target_cpumask);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment