Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751337AbdFEG2I (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 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 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1182 Lines: 39 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) -- 1.9.1