From patchwork Wed Apr 20 01:06:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 8884301 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 44A039F36E for ; Wed, 20 Apr 2016 01:08:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4698B201BC for ; Wed, 20 Apr 2016 01:08:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 46309201C0 for ; Wed, 20 Apr 2016 01:08:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1asgbV-0001mA-0T; Wed, 20 Apr 2016 01:06:53 +0000 Received: from mail.kernel.org ([198.145.29.136]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1asgbS-0001eS-FB for linux-arm-kernel@lists.infradead.org; Wed, 20 Apr 2016 01:06:51 +0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 693CE201BC; Wed, 20 Apr 2016 01:06:29 +0000 (UTC) Received: from localhost (unknown [69.71.1.1]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 329A120165; Wed, 20 Apr 2016 01:06:28 +0000 (UTC) Date: Tue, 19 Apr 2016 20:06:27 -0500 From: Bjorn Helgaas To: Murali Karicheri Subject: Re: [PATCH next v2 2/2] PCI: keystone: remove unnecessary goto statement Message-ID: <20160420010627.GJ17863@localhost> References: <1460386231-8377-1-git-send-email-m-karicheri2@ti.com> <1460386231-8377-2-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1460386231-8377-2-git-send-email-m-karicheri2@ti.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160419_180650_555923_90C351D7 X-CRM114-Status: GOOD ( 24.20 ) X-Spam-Score: -5.2 (-----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bhelgaas@google.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Murali, On Mon, Apr 11, 2016 at 10:50:31AM -0400, Murali Karicheri wrote: > Fix the misuse of goto statement in ks_pcie_get_irq_controller_info() > as simple return is more appropriate for this function. While at > it add an error log for absence of interrupt controller node. > > Signed-off-by: Murali Karicheri > Cc: Rob Herring > Cc: Pawel Moll > Cc: Mark Rutland > Cc: Ian Campbell > Cc: Kumar Gala > Cc: Bjorn Helgaas > > --- > v2 - removed an unnecessary extra line added in the previous version > v1 - same as before initial version > drivers/pci/host/pci-keystone.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/pci/host/pci-keystone.c b/drivers/pci/host/pci-keystone.c > index 299f2f0..0234828 100644 > --- a/drivers/pci/host/pci-keystone.c > +++ b/drivers/pci/host/pci-keystone.c > @@ -181,11 +181,13 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, > *np_temp = of_find_node_by_name(np_pcie, controller); > if (!(*np_temp)) { > dev_err(dev, "Node for %s is absent\n", controller); > - goto out; > + return ret; > } > temp = of_irq_count(*np_temp); > - if (!temp) > - goto out; > + if (!temp) { > + dev_err(dev, "No entries in %s\n", controller); > + return ret; > + } > if (temp > max_host_irqs) > dev_warn(dev, "Too many %s interrupts defined %u\n", > (legacy ? "legacy" : "MSI"), temp); > @@ -203,7 +205,6 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, > *num_irqs = temp; > ret = 0; > } > -out: > return ret; I really like these cleanups; thanks for doing them. I went a step further because I think we always know the value of "ret" at each of these places, so I inserted those and dropped "ret" altogether. I applied the patch below to pci/host-keystone for v4.7. commit a7ed67a22484f70b8d0c33c76ad7faeac97222a7 Author: Murali Karicheri Date: Mon Apr 11 10:50:31 2016 -0400 PCI: keystone: Remove unnecessary goto statement Fix the misuse of goto statement in ks_pcie_get_irq_controller_info() as simple return is more appropriate for this function. While at it add an error log for absence of interrupt controller node. [bhelgaas: drop "ret" altogether since we always know the return value] Signed-off-by: Murali Karicheri Signed-off-by: Bjorn Helgaas CC: Rob Herring CC: Pawel Moll CC: Mark Rutland CC: Ian Campbell CC: Kumar Gala diff --git a/drivers/pci/host/pci-keystone.c b/drivers/pci/host/pci-keystone.c index 6868918..95a66f77 100644 --- a/drivers/pci/host/pci-keystone.c +++ b/drivers/pci/host/pci-keystone.c @@ -160,7 +160,7 @@ static void ks_pcie_legacy_irq_handler(struct irq_desc *desc) static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, char *controller, int *num_irqs) { - int temp, max_host_irqs, legacy = 1, *host_irqs, ret = -EINVAL; + int temp, max_host_irqs, legacy = 1, *host_irqs; struct device *dev = ks_pcie->pp.dev; struct device_node *np_pcie = dev->of_node, **np_temp; @@ -181,11 +181,15 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, *np_temp = of_find_node_by_name(np_pcie, controller); if (!(*np_temp)) { dev_err(dev, "Node for %s is absent\n", controller); - goto out; + return -EINVAL; } + temp = of_irq_count(*np_temp); - if (!temp) - goto out; + if (!temp) { + dev_err(dev, "No IRQ entries in %s\n", controller); + return -EINVAL; + } + if (temp > max_host_irqs) dev_warn(dev, "Too many %s interrupts defined %u\n", (legacy ? "legacy" : "MSI"), temp); @@ -199,12 +203,13 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, if (!host_irqs[temp]) break; } + if (temp) { *num_irqs = temp; - ret = 0; + return 0; } -out: - return ret; + + return -EINVAL; } static void ks_pcie_setup_interrupts(struct keystone_pcie *ks_pcie) @@ -345,7 +350,7 @@ static int __init ks_add_pcie_port(struct keystone_pcie *ks_pcie, return ret; } - return ret; + return 0; } static const struct of_device_id ks_pcie_of_match[] = { @@ -374,7 +379,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev) struct resource *res; void __iomem *reg_p; struct phy *phy; - int ret = 0; + int ret; ks_pcie = devm_kzalloc(&pdev->dev, sizeof(*ks_pcie), GFP_KERNEL);