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: 9765613 X-Patchwork-Delegate: bhelgaas@google.com 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 E05ED60364 for ; Mon, 5 Jun 2017 06:28:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D319526538 for ; Mon, 5 Jun 2017 06:28:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7DA127D4D; Mon, 5 Jun 2017 06:28:12 +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=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 446AE26538 for ; Mon, 5 Jun 2017 06:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751276AbdFEG2I (ORCPT ); Mon, 5 Jun 2017 02:28:08 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:53434 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751262AbdFEG2H (ORCPT ); Mon, 5 Jun 2017 02:28:07 -0400 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 CC: , , , , Ryder Lee 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 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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)