From patchwork Thu Sep 26 12:54:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 11162743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 437F9912 for ; Thu, 26 Sep 2019 12:55:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CC0B222C0 for ; Thu, 26 Sep 2019 12:55:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbfIZMzQ (ORCPT ); Thu, 26 Sep 2019 08:55:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34386 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbfIZMzP (ORCPT ); Thu, 26 Sep 2019 08:55:15 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16DBA18C8906; Thu, 26 Sep 2019 12:55:15 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 570B160A97; Thu, 26 Sep 2019 12:55:12 +0000 (UTC) From: Prarit Bhargava To: platform-driver-x86@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Prarit Bhargava , Srinivas Pandruvada Subject: [PATCH 2/7] intel-speed-select: Make process_command generic Date: Thu, 26 Sep 2019 08:54:56 -0400 Message-Id: <20190926125501.1616-3-prarit@redhat.com> In-Reply-To: <20190926125501.1616-1-prarit@redhat.com> References: <20190926125501.1616-1-prarit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Thu, 26 Sep 2019 12:55:15 +0000 (UTC) Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org 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: Prarit Bhargava Cc: Srinivas Pandruvada --- .../x86/intel-speed-select/isst-config.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 9f2798caead9..bb6f8f5986c9 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -1498,7 +1498,9 @@ static struct process_cmd_help_struct isst_help_cmds[] = { { 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; char *feature = argv[optind]; @@ -1509,9 +1511,9 @@ void process_command(int argc, char **argv) debug_printf("feature name [%s] command [%s]\n", feature, cmd); if (!strcmp(cmd, "-h") || !strcmp(cmd, "--help")) { - while (isst_help_cmds[i].feature) { - if (!strcmp(isst_help_cmds[i].feature, feature)) { - isst_help_cmds[i].process_fn(); + while (help_cmds[i].feature) { + if (!strcmp(help_cmds[i].feature, feature)) { + help_cmds[i].process_fn(); exit(0); } ++i; @@ -1521,11 +1523,11 @@ void process_command(int argc, char **argv) create_cpu_map(); i = 0; - while (isst_cmds[i].feature) { - if (!strcmp(isst_cmds[i].feature, feature) && - !strcmp(isst_cmds[i].command, cmd)) { + while (cmds[i].feature) { + if (!strcmp(cmds[i].feature, feature) && + !strcmp(cmds[i].command, cmd)) { 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; break; } @@ -1646,7 +1648,7 @@ static void cmdline(int argc, char **argv) if (ret) goto out; - process_command(argc, argv); + process_command(argc, argv, isst_help_cmds, isst_cmds); out: free_cpu_set(present_cpumask); free_cpu_set(target_cpumask);