From patchwork Mon Jun 5 06:27:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 9765615 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 2A5A860364 for ; Mon, 5 Jun 2017 06:28:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D4C026538 for ; Mon, 5 Jun 2017 06:28:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11C4327D4D; Mon, 5 Jun 2017 06:28:36 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B9FBB26538 for ; Mon, 5 Jun 2017 06:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=P2tPsp7XFbF9Qa/81FN5wjqunkIGfYgZ7M/catRtBwo=; b=E4NdHlyxyMBbCs iVbQzvRlvXRy2nde/FdbYT0xCTEQnv1hkRpAUJro7MGJVXii8gtulqouwliMLDfqDMHcRoFhN/ES6 r8GFYE4+6VCOLMHTbxPUijCJFORvj4IBujafPxJo7KDYAAjOmvToGgnDND+/k6YoymnkrS5FISIm3 yXmAZ8RYe0CH9e3nvdgTFNaZWR3uthIkI5vBSzTNXGW8xu2SVQ2MMGk3L5ckgpdDhYGjMpnw05dk+ B/tgpmzlTyUn/h4rS0CYeneuufcRB76H+2cLenstYn6t2keWzVruuweDDNsArSOA4S+Vc0O15+T5b dM/lgeWblweuR9OFqzrg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dHlVC-00048s-LZ; Mon, 05 Jun 2017 06:28:34 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dHlV8-00046e-PU; Mon, 05 Jun 2017 06:28:33 +0000 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 937224135; Mon, 05 Jun 2017 14:28:02 +0800 Received: from mtkexhb01.mediatek.inc (172.21.101.102) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 5 Jun 2017 14:28:01 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by mtkexhb01.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 5 Jun 2017 14:28:01 +0800 From: Ryder Lee To: Bjorn Helgaas Subject: [PATCH] PCI: mediatek: fix error handling in mtk_pcie_parse_and_add_res() Date: Mon, 5 Jun 2017 14:27:58 +0800 Message-ID: <1496644078-27122-1-git-send-email-ryder.lee@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170604_232830_971422_128D731A X-CRM114-Status: GOOD ( 13.21 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pci@vger.kernel.org, Ryder Lee , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The 'linkup' variable would always increment by one whether the link status is true or not. Therefore, this patch fixes the return value in mtk_pcie_parse_and_add_res() and removes unnecessary 'linkup' variable. Signed-off-by: Ryder Lee --- drivers/pci/host/pcie-mediatek.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/host/pcie-mediatek.c b/drivers/pci/host/pcie-mediatek.c index 8ec8fa8..3baafa8 100644 --- a/drivers/pci/host/pcie-mediatek.c +++ b/drivers/pci/host/pcie-mediatek.c @@ -373,7 +373,7 @@ static int mtk_pcie_parse_and_add_res(struct mtk_pcie *pcie) struct of_pci_range_parser parser; struct of_pci_range range; struct resource res; - int err, linkup = 0; + int err; /* parse shared resources */ err = mtk_pcie_handle_shared_resource(pcie); @@ -444,11 +444,11 @@ static int mtk_pcie_parse_and_add_res(struct mtk_pcie *pcie) /* enable each port, and then check link status */ err = mtk_pcie_enable_ports(port); - if (!err) - linkup++; + if (err) + return err; } - return !linkup; + return 0; } static int mtk_pcie_request_resources(struct mtk_pcie *pcie)