From patchwork Wed Aug 16 12:52:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 9903639 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 50C3E6038C for ; Wed, 16 Aug 2017 12:54:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42CFE289DD for ; Wed, 16 Aug 2017 12:54:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 379CD289E0; Wed, 16 Aug 2017 12:54:37 +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 D10A7289CD for ; Wed, 16 Aug 2017 12:54:36 +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 1dhxoI-0008Vg-Ju; Wed, 16 Aug 2017 12:52:34 +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-0008Ha-4k for xen-devel@lists.xenproject.org; Wed, 16 Aug 2017 12:52:33 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 0E/CD-02181-01044995; Wed, 16 Aug 2017 12:52:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVyuP0Ov66Aw5R Ig86fohbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aCPfdYCtaJVfw8c4y5gfEFfxcjJ4eEgJHE 24n/mEBsIYFjjBKfpzuA2GwCqhIbrp9iBbFFBJQk7q2aDFbDLOAq0fB7KVhcWCBb4ubz7WBxF qD6lpblLCA2r4CJxKyVL9kg5stLdByYDBbnBIpP3nCMBWKXscT2nkb2CYzcCxgZVjGqF6cWla UW6ZroJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhXrJefnbmIE+pYBCHYwNn5xOsQoycGkJMo bpDUlUogvKT+lMiOxOCO+qDQntfgQowwHh5IE7yI7oJxgUWp6akVaZg4wyGDSEhw8SiK8abZA ad7igsTc4sx0iNQpRl2OVxP+f2MSYsnLz0uVEufNBJkhAFKUUZoHNwIW8JcYZaWEeRmBjhLiK Ugtys0sQZV/xSjOwagkzHsVZApPZl4J3KZXQEcwAR1xpX0SyBEliQgpqQZGFnftv2tWNviuj3 4j+elY8G+3vQtK/LxTo0IDr/avmJdmv8nedI5p0q5Jqns+LPjK7tc316ec8bUsw49vLn1OqbV nnLdGSt3vPua3blM/y7Njs132zX2T/qie3XVZSXOmvZ724QbH6SwlkQ2yU9h/maY3uqpnP48M fXnKYfl0kTyHE9cu6e5XYinOSDTUYi4qTgQAah2zYnMCAAA= X-Env-Sender: jgross@suse.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1502887952!52190311!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 64181 invoked from network); 16 Aug 2017 12:52:32 -0000 Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by server-4.tower-31.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 16 Aug 2017 12:52:32 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1693DAE9C for ; Wed, 16 Aug 2017 12:52:32 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 16 Aug 2017 14:52:01 +0200 Message-Id: <20170816125219.5255-35-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 34/52] xen/drivers/passthrough/pci.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/passthrough/pci.c to indicate whether the parameter value was parsed successfully. Cc: Jan Beulich Signed-off-by: Juergen Gross --- V3: - cosmetic changes (Jan Beulich) - dont modify option value in parsing funtion --- xen/drivers/passthrough/pci.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 27bdb7163c..fdc53aef12 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -149,17 +149,18 @@ static struct phantom_dev { } phantom_devs[8]; static unsigned int nr_phantom_devs; -static void __init parse_phantom_dev(char *str) { +static int __init parse_phantom_dev(const char *str) +{ const char *s = str; unsigned int seg, bus, slot; struct phantom_dev phantom; if ( !s || !*s || nr_phantom_devs >= ARRAY_SIZE(phantom_devs) ) - return; + return -EINVAL; s = parse_pci(s, &seg, &bus, &slot, NULL); if ( !s || *s != ',' ) - return; + return -EINVAL; phantom.seg = seg; phantom.bus = bus; @@ -170,10 +171,12 @@ static void __init parse_phantom_dev(char *str) { case 1: case 2: case 4: if ( *s ) default: - return; + return -EINVAL; } phantom_devs[nr_phantom_devs++] = phantom; + + return 0; } custom_param("pci-phantom", parse_phantom_dev); @@ -189,9 +192,10 @@ static u16 __read_mostly bridge_ctl_mask; * perr don't suppress parity errors (default) * no-perr suppress parity errors */ -static void __init parse_pci_param(char *s) +static int __init parse_pci_param(const char *s) { - char *ss; + const char *ss; + int rc = 0; do { bool_t on = !!strncmp(s, "no-", 3); @@ -201,19 +205,21 @@ static void __init parse_pci_param(char *s) s += 3; ss = strchr(s, ','); - if ( ss ) - *ss = '\0'; + if ( !ss ) + ss = strchr(s, '\0'); - if ( !strcmp(s, "serr") ) + if ( !strncmp(s, "serr", ss - s) ) { cmd_mask = PCI_COMMAND_SERR; brctl_mask = PCI_BRIDGE_CTL_SERR | PCI_BRIDGE_CTL_DTMR_SERR; } - else if ( !strcmp(s, "perr") ) + else if ( !strncmp(s, "perr", ss - s) ) { cmd_mask = PCI_COMMAND_PARITY; brctl_mask = PCI_BRIDGE_CTL_PARITY; } + else + rc = -EINVAL; if ( on ) { @@ -227,7 +233,9 @@ static void __init parse_pci_param(char *s) } s = ss + 1; - } while ( ss ); + } while ( *ss ); + + return rc; } custom_param("pci", parse_pci_param);