From patchwork Tue Jul 14 20:10:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 6789111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4EF28C05AC for ; Tue, 14 Jul 2015 20:14:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5306C20709 for ; Tue, 14 Jul 2015 20:14:27 +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 28AA3206F8 for ; Tue, 14 Jul 2015 20:14:26 +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 1ZF6Y4-0006bx-Fn; Tue, 14 Jul 2015 20:11:28 +0000 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZF6Y1-0006Z2-8r for linux-arm-kernel@lists.infradead.org; Tue, 14 Jul 2015 20:11:25 +0000 Received: by oiab3 with SMTP id b3so14301356oia.1 for ; Tue, 14 Jul 2015 13:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=JRo6lTt9bN/I/yKPiw48+81xAPrwbs/+vKazH81iG9A=; b=V6oOKBXgD2zKvFdwBTOmHBe1I5aJDMUkp2MsE+sNnx8PBlSAiazDrVAQGMFWlXCgjN x+C1k80seeQOlqtDvdyh+AAi37IYNF05xOmYg9LufVwlthI6NuhPz39skn2y55yoNTeZ r5J+F34oS8YmboD2EUtjwEKZkBVuXB4d929gNmWw2Fp/YzYJ8oqX3IzGu7aAyPaer476 a3pvWkbuQSa04Zd/R0C4cTjyVy+0YSHCsa0sOZT2b8xnL/7/0laVIHOpfbsV7PYesLE8 GW5x3OsYi0QpVpQF094/vt4U1hJBhUydtq3I9hWfkEw1vCDwpXEufGzObMEgpO8WAwKj oF3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=JRo6lTt9bN/I/yKPiw48+81xAPrwbs/+vKazH81iG9A=; b=iQMIKnIH2LlzVEiA7l15dUcTgSO0ZmQrWZEofi1UbCN/SwOCZ1d5HRHyt7iCNyS4Ax DunjrKec3uld347GVPsONdaP/fSY0v/D1vZHUvMv5bvs7Vt5Tw9MJzjTQQ0YtH59NTRm 9x5HkKS+ZfeX+qfu1ndNnqrN8BBOuvHb6buN1dpE3mym0Z0FXvb8trpe6yDFxRODW6xB 2+adeCsp/9dDR0YH0iZzfYSEDCrpOavLJ9bw4JIB0F2qw8yCZc8atXHpWmeuX4n3m48r fORR8iQW0JFt9hs/36ZNnGy/NcNGVrbZTkrFIp78Ujh8QS+jVWhrMTAMI1e6YeOiRBgA b9Nw== X-Gm-Message-State: ALoCoQn+G5AzKyuB5//2c9zd1nNMSlj+54+tcjYIRaoMZAMFM+7nDofPSq/ygmFNR+FNE/3KU2dI X-Received: by 10.60.136.131 with SMTP id qa3mr304805oeb.34.1436904664068; Tue, 14 Jul 2015 13:11:04 -0700 (PDT) Received: from google.com ([69.71.1.1]) by smtp.gmail.com with ESMTPSA id j1sm1068929obj.19.2015.07.14.13.11.01 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 14 Jul 2015 13:11:02 -0700 (PDT) Date: Tue, 14 Jul 2015 15:10:59 -0500 From: Bjorn Helgaas To: SF Markus Elfring Subject: Re: [PATCH] PCI-iproc: Delete unnecessary checks before two function calls Message-ID: <20150714201059.GG24416@google.com> References: <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <55900A20.5070407@users.sourceforge.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <55900A20.5070407@users.sourceforge.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150714_131125_415061_EFA37252 X-CRM114-Status: GOOD ( 23.52 ) X-Spam-Score: -4.1 (----) 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: Scott Branden , Ray Jui , kernel-janitors@vger.kernel.org, LKML , Julia Lawall , bcm-kernel-feedback-list@broadcom.com, Hauke Mehrtens , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, 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 On Sun, Jun 28, 2015 at 04:52:16PM +0200, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 28 Jun 2015 16:42:04 +0200 > > The functions phy_exit() and phy_power_off() test whether their argument > is NULL and then return immediately. > Thus the test around the calls is not needed. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring I haven't seen a followup to Ray's review, but in the interest of making progress, I updated and applied the patch as appended. I also reviewed other phy_*() calls under drivers/pci, and they all look OK (with no unnecessary tests for NULL). This is on the pci/host-iproc branch for v4.3. > --- > drivers/pci/host/pcie-iproc.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c > index d77481e..f875821 100644 > --- a/drivers/pci/host/pcie-iproc.c > +++ b/drivers/pci/host/pcie-iproc.c > @@ -239,12 +239,9 @@ err_rm_root_bus: > pci_remove_root_bus(bus); > > err_power_off_phy: > - if (pcie->phy) > - phy_power_off(pcie->phy); > + phy_power_off(pcie->phy); > err_exit_phy: > - if (pcie->phy) > - phy_exit(pcie->phy); > - > + phy_exit(pcie->phy); > return ret; > } > EXPORT_SYMBOL(iproc_pcie_setup); > -- > 2.4.4 commit 55b5e16332eb9ffc1cbaf975585f4521417ab427 Author: Markus Elfring Date: Sun Jun 28 16:42:04 2015 +0200 PCI: iproc: Delete unnecessary checks before phy calls The functions phy_exit() and phy_power_off() test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed. This issue was detected by using the Coccinelle software. [bhelgaas: also phy_init() and phy_power_on(), as Ray Jui suggested] [bhelgaas: also remove tests in iproc_pcie_remove()] Signed-off-by: Markus Elfring Signed-off-by: Bjorn Helgaas Reviewed-by: Ray Jui diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index d77481e..9a00dca 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c @@ -191,19 +191,16 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) if (!pcie || !pcie->dev || !pcie->base) return -EINVAL; - if (pcie->phy) { - ret = phy_init(pcie->phy); - if (ret) { - dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); - return ret; - } - - ret = phy_power_on(pcie->phy); - if (ret) { - dev_err(pcie->dev, "unable to power on PCIe PHY\n"); - goto err_exit_phy; - } + ret = phy_init(pcie->phy); + if (ret) { + dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); + return ret; + } + ret = phy_power_on(pcie->phy); + if (ret) { + dev_err(pcie->dev, "unable to power on PCIe PHY\n"); + goto err_exit_phy; } iproc_pcie_reset(pcie); @@ -239,12 +236,9 @@ err_rm_root_bus: pci_remove_root_bus(bus); err_power_off_phy: - if (pcie->phy) - phy_power_off(pcie->phy); + phy_power_off(pcie->phy); err_exit_phy: - if (pcie->phy) - phy_exit(pcie->phy); - + phy_exit(pcie->phy); return ret; } EXPORT_SYMBOL(iproc_pcie_setup); @@ -254,10 +248,8 @@ int iproc_pcie_remove(struct iproc_pcie *pcie) pci_stop_root_bus(pcie->root_bus); pci_remove_root_bus(pcie->root_bus); - if (pcie->phy) { - phy_power_off(pcie->phy); - phy_exit(pcie->phy); - } + phy_power_off(pcie->phy); + phy_exit(pcie->phy); return 0; }