From patchwork Wed Aug 16 12:51:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 9903629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2AD96038C for ; Wed, 16 Aug 2017 12:54:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4842289CD for ; Wed, 16 Aug 2017 12:54:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C996A289E0; Wed, 16 Aug 2017 12:54:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6BC32289CD for ; Wed, 16 Aug 2017 12:54:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhxoH-0008S3-C6; Wed, 16 Aug 2017 12:52:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhxoH-0008P7-0f for xen-devel@lists.xenproject.org; Wed, 16 Aug 2017 12:52:33 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 66/C8-22472-01044995; Wed, 16 Aug 2017 12:52:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVyuP0Ovy6/w5R Ig/+bNCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyFq74xFtxVqPjXyN/AOEOyi5GTQ0LASOLt xH9MXYxcHEICxxgltt5+yQySYBNQldhw/RQriC0ioCRxb9VkJhCbWcBVouH3UrC4sEC2xIrHT ewgNgtQ/c97X8DivAImEouazjBDLJCX6DgwmQXE5gSKT95wDMwWEjCW2N7TyD6BkXsBI8MqRo 3i1KKy1CJdQ0O9pKLM9IyS3MTMHF1DA2O93NTi4sT01JzEpGK95PzcTYxA7zIAwQ7G1b+dDjF KcjApifIGaU2JFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBO8cWKCdYlJqeWpGWmQMMM5i0BAeP kghvGkiat7ggMbc4Mx0idYpRl+PVhP/fmIRY8vLzUqXEeZ+CFAmAFGWU5sGNgIX8JUZZKWFeR qCjhHgKUotyM0tQ5V8xinMwKgnzrgWZwpOZVwK36RXQEUxAR1xpnwRyREkiQkqqgdH7ctAXJ8 78VH/PnT+49ZdXtEdLtvds+bblvpD8j/q3/o8WZJhm/LNtsotWs7G09Qr5fWzuvEMLVmQ1T5v y6FVdEe+tpQeO2WmVN7/XXapa1eL2ITLYwTpTcd49nyKZ55fWX/4tNtv0Zqiiy+UD83YGZLoY WPlfOjtj15RpM9k2TZVxdH4mzK7EUpyRaKjFXFScCAAA1HPzdAIAAA== X-Env-Sender: jgross@suse.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1502887951!54784765!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39292 invoked from network); 16 Aug 2017 12:52:31 -0000 Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by server-9.tower-31.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 16 Aug 2017 12:52:31 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 64996AE57 for ; Wed, 16 Aug 2017 12:52:31 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 16 Aug 2017 14:51:58 +0200 Message-Id: <20170816125219.5255-32-jgross@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170816125219.5255-1-jgross@suse.com> References: <20170816125219.5255-1-jgross@suse.com> Cc: Juergen Gross , Jan Beulich Subject: [Xen-devel] [PATCH v3 31/52] xen/drivers/cpufreq/cpufreq.c: let custom parameter parsing routines return errno X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Modify the custom parameter parsing routines in: xen/drivers/cpufreq/cpufreq.c to indicate whether the parameter value was parsed successfully. Cc: Jan Beulich Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V3: - dont modify option value in handling function - remove prototype of cpufreq_cmdline_parse() from cpufreq.h and make it static --- xen/drivers/cpufreq/cpufreq.c | 37 +++++++++++++++++++++++++------------ xen/include/acpi/cpufreq/cpufreq.h | 2 -- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index fd82ef5dce..216ad32350 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -62,37 +62,41 @@ LIST_HEAD_READ_MOSTLY(cpufreq_governor_list); /* set xen as default cpufreq */ enum cpufreq_controller cpufreq_controller = FREQCTL_xen; -static void __init setup_cpufreq_option(char *str) +static int __init cpufreq_cmdline_parse(const char *s); + +static int __init setup_cpufreq_option(const char *str) { - char *arg = strpbrk(str, ",:"); + const char *arg = strpbrk(str, ",:"); int choice; - if ( arg ) - *arg++ = '\0'; + if ( !arg ) + arg = strchr(str, '\0'); choice = parse_bool(str); - if ( choice < 0 && !strcmp(str, "dom0-kernel") ) + if ( choice < 0 && !strncmp(str, "dom0-kernel", arg - str) ) { xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX; cpufreq_controller = FREQCTL_dom0_kernel; opt_dom0_vcpus_pin = 1; - return; + return 0; } - if ( choice == 0 || !strcmp(str, "none") ) + if ( choice == 0 || !strncmp(str, "none", arg - str) ) { xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX; cpufreq_controller = FREQCTL_none; - return; + return 0; } - if ( choice > 0 || !strcmp(str, "xen") ) + if ( choice > 0 || !strncmp(str, "xen", arg - str) ) { xen_processor_pmbits |= XEN_PROCESSOR_PM_PX; cpufreq_controller = FREQCTL_xen; - if ( arg && *arg ) - cpufreq_cmdline_parse(arg); + if ( *arg && *(arg + 1) ) + return cpufreq_cmdline_parse(arg + 1); } + + return (choice < 0) ? -EINVAL : 0; } custom_param("cpufreq", setup_cpufreq_option); @@ -571,7 +575,7 @@ static int __init cpufreq_handle_common_option(const char *name, const char *val return 0; } -void __init cpufreq_cmdline_parse(char *str) +static int __init cpufreq_cmdline_parse(const char *s) { static struct cpufreq_governor *__initdata cpufreq_governors[] = { @@ -581,8 +585,12 @@ void __init cpufreq_cmdline_parse(char *str) &cpufreq_gov_performance, &cpufreq_gov_powersave }; + static char buf[128]; + char *str = buf; unsigned int gov_index = 0; + int rc = 0; + strlcpy(buf, s, sizeof(buf)); do { char *val, *end = strchr(str, ','); unsigned int i; @@ -611,11 +619,16 @@ void __init cpufreq_cmdline_parse(char *str) if (str && !cpufreq_handle_common_option(str, val) && (!cpufreq_governors[gov_index]->handle_option || !cpufreq_governors[gov_index]->handle_option(str, val))) + { printk(XENLOG_WARNING "cpufreq/%s: option '%s' not recognized\n", cpufreq_governors[gov_index]->name, str); + rc = -EINVAL; + } str = end; } while (str); + + return rc; } static int cpu_callback( diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/cpufreq.h index 48ad1d0004..a5cd7d08a1 100644 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -79,8 +79,6 @@ DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); extern int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy); -void cpufreq_cmdline_parse(char *); - #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ #define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ #define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */