From patchwork Tue Dec 6 17:53:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 9463013 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 BA2A360231 for ; Tue, 6 Dec 2016 17:55:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A977E2847D for ; Tue, 6 Dec 2016 17:55:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B8612848D; Tue, 6 Dec 2016 17:55:41 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 221DF2847D for ; Tue, 6 Dec 2016 17:55:41 +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 1cEJvp-0004Lz-Hl; Tue, 06 Dec 2016 17:53: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 1cEJvo-0004Lm-JL for xen-devel@lists.xenproject.org; Tue, 06 Dec 2016 17:53:32 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id EF/A5-12362-B1BF6485; Tue, 06 Dec 2016 17:53:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeJIrShJLcpLzFFi42Lxqg1y0ZX47RZ hMP+SusX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvHtzSTWgnM8FT9ndLI2MDZydDFycQgJzGSU uNfRxwzisAhcYpHY/+wWaxcjJ4eEwDsWiaMTyroYOYDsGIn9B2shwuUSX5fdBCsRElCSeL1zM xPEoFlMEpMuv2IBSbAJGEjsf/eEHcQWASq6t2oyE4jNLGAose3ySbAaYaCZX2Z9ZwOZzyKgKv HlhS1ImFfAWeL5x58sELvkJG6e62SewMi3gJFhFaNGcWpRWWqRrpGBXlJRZnpGSW5iZo6uoYG xXm5qcXFiempOYlKxXnJ+7iZGYJjUMzAw7mBsPuF3iFGSg0lJlPfBa7cIIb6k/JTKjMTijPii 0pzU4kOMMhwcShK8Kr+AcoJFqempFWmZOcCAhUlLcPAoifCm/ARK8xYXJOYWZ6ZDpE4x6nLs6 FzzlEmIJS8/L1VKnFcBZIYASFFGaR7cCFj0XGKUlRLmZWRgYBDiKUgtys0sQZV/xSjOwagkzG sJMoUnM68EbtMroCOYgI44cdwZ5IiSRISUVAOjvZhJoZvdhaISqVh1VeUMtfnOsdX//CW/uH0 6+oPjsPZ8nlMf1/7ROCBiVnq6dcfqDjmLop17+C6yswbc+jj7SrWf8cVlv7oyyvJ7n057/rSr +cHz+Xza5me22sjcbGQoi5zJbvDR6/mU07qrha/FOwsXNn5ljhcvuPLkc+Wt2KtPUv6FBWUrs RRnJBpqMRcVJwIAXcmdepkCAAA= X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1481046808!70759640!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38784 invoked from network); 6 Dec 2016 17:53:28 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-15.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Dec 2016 17:53:28 -0000 Received: by mail-wm0-f68.google.com with SMTP id u144so22897176wmu.0 for ; Tue, 06 Dec 2016 09:53:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=0OeqyqhmvvCbieH8XeyZjk+PHCnk9HS8b2ZtYnq5zgM=; b=oUc8+dwn1ciY2IXMdCKx1baUV0L9GPkfN8sy3gWn0ZL4ygj/K7Ebt3W9RFVmCYKIJl BMvT7+fxOaJLsi8jeh3DzHqTCKlVD67IE7fx2fF4eUo0qjOfFaciWfvrQqcBer2IEWTC FGL5zrGKR5nOAcRxALETDn7az2RVt/x/K7ZlgwtwtRSLu/46+T7zbpmU0CiCeH49owP6 Rhb9FWgtPdZ7ejnaxG1ymlgc2RtXd3rHNeR0MRtyIkCG0lU/EDv7pU5kxHEn3j4AayiM a7TFOa3hVm39Q/z1kWx9r7Kl1cCW3gjtnpjTp+KQz84pIQnp5itvkCgtMJlTDaMuI4jz idZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0OeqyqhmvvCbieH8XeyZjk+PHCnk9HS8b2ZtYnq5zgM=; b=XpztInaux2F2A9/82unBCYgRY4YvuWAVFzoQHGVbD+oB4tydWuFDikyWYoaebmhMHn BGLmHnv7FC8Ps+W8INwfe6NRV3iLlMk3qK2AaRK6GL3HP+ef/5tfoIJt5qECbIYXwKYK 90NYIJ//oIcVrblwuCcWh6z/fS270PhtVxGL2YY4KcDDgWs1kSwf2SMEifXOUFNTy05i VSp4lOrPiDook6wbLjJ4D0ATaXqCjIcruS24uVx+5Oh74r72nRbL6G49j3yNgOewxM85 s/6vi/8KmqXFVBdsMUDG9qkFVsyhUnMH1LBeOMTPsR4gX6k516SbSN2eyRn2Y81pbGrK HWQg== X-Gm-Message-State: AKaTC02EiOD3rysga3v/rhehT0m6tvMTZKh/85fM9DCvoKJY2tGMElgkvLs9UXt8HamcCQ== X-Received: by 10.28.35.14 with SMTP id j14mr3748127wmj.24.1481046808169; Tue, 06 Dec 2016 09:53:28 -0800 (PST) Received: from otyshchenko.kyiv.epam.com (ll-53.209.223.85.sovam.net.ua. [85.223.209.53]) by smtp.gmail.com with ESMTPSA id d8sm5148072wmi.21.2016.12.06.09.53.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Dec 2016 09:53:27 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Tue, 6 Dec 2016 19:53:20 +0200 Message-Id: <1481046800-10809-1-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: julien.grall@arm.com, sstabellini@kernel.org Subject: [Xen-devel] [PATCH v1] arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if" 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 From: Oleksandr Tyshchenko Remove one layer of "if" by reordering the check in route_irq_to_guest() to make code more clearer. Signed-off-by: Oleksandr Tyshchenko CC: Julien Grall Reviewed-by: Julien Grall --- xen/arch/arm/irq.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 508028b..6d7e44e 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -481,21 +481,17 @@ int route_irq_to_guest(struct domain *d, unsigned int virq, { struct domain *ad = irq_get_domain(desc); - if ( d == ad ) - { - if ( irq_get_guest_info(desc)->virq != virq ) - { - printk(XENLOG_G_ERR - "d%u: IRQ %u is already assigned to vIRQ %u\n", - d->domain_id, irq, irq_get_guest_info(desc)->virq); - retval = -EBUSY; - } - } - else + if ( d != ad ) { printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n", irq, ad->domain_id); retval = -EBUSY; + } else if ( irq_get_guest_info(desc)->virq != virq ) + { + printk(XENLOG_G_ERR + "d%u: IRQ %u is already assigned to vIRQ %u\n", + d->domain_id, irq, irq_get_guest_info(desc)->virq); + retval = -EBUSY; } } else