From patchwork Mon Oct 23 21:36:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10023153 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 41035603D7 for ; Mon, 23 Oct 2017 21:37:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30CEA28822 for ; Mon, 23 Oct 2017 21:37:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23FBF28931; Mon, 23 Oct 2017 21:37: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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED 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 A393A28822 for ; Mon, 23 Oct 2017 21:37: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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=s+x0MQFCaoMCfsWYAesoulFyld+TGgnGGT70NbRnRpY=; b=KHz 2iVFyxCjDVjH8wU4wQI9gBtlO0gms72cXQ2lE5YP+5IgWAvKE7tTAm7IvCEOjKNl3VrHZWpPzTpwd PRIw5QFfRH2cddptkPHpZV5Q/H3caXWLV7Uxg95PdVaaEdwiamhHAolC88Y77RUAR4NHa66H+IVCc qZ7+PACKqD6f3mO7LZ5zu2eUVzuLV/ubHZBAo0jELU++ZbKTIUtCm80UYZu0FYh1+ueGThtWGJfVm vWAcM42Md862RoHp3yvgyi5UkGBJhkOD6Qyb1LV8ksCZ352/9e1tbjIFax9sPol0l7uzeabpl5UBe n9l++zVmwKycTot/0cBypmGSj6PrFTA==; 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 1e6kPY-0002wt-9Y; Mon, 23 Oct 2017 21:37:28 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e6kPU-0002vx-22 for linux-arm-kernel@lists.infradead.org; Mon, 23 Oct 2017 21:37:25 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 624E960386; Mon, 23 Oct 2017 21:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1508794623; bh=s6P9ldTbyUsN6NszcbsBhRkbHvc68+V5LPsff62onoU=; h=From:To:Cc:Subject:Date:From; b=DVJbLGRYPCy4sYCO1eb4PQRzaXHRlZq8tUL9aPEH3GNFPXv7REP0UROEvc5Z8TExs I1TgnQJtQ6LFvauFtoXNO1/Xu0D3DwGOYDVVEwMlXheh9zAUfUldEDkcEpZT3vb+sr /I8AZtEyTPYPK4DFvu1dqCB9ub0h7vX1/XfXGpVU= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 508856034E; Mon, 23 Oct 2017 21:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1508794623; bh=s6P9ldTbyUsN6NszcbsBhRkbHvc68+V5LPsff62onoU=; h=From:To:Cc:Subject:Date:From; b=DVJbLGRYPCy4sYCO1eb4PQRzaXHRlZq8tUL9aPEH3GNFPXv7REP0UROEvc5Z8TExs I1TgnQJtQ6LFvauFtoXNO1/Xu0D3DwGOYDVVEwMlXheh9zAUfUldEDkcEpZT3vb+sr /I8AZtEyTPYPK4DFvu1dqCB9ub0h7vX1/XfXGpVU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 508856034E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org Subject: [PATCH] PCI: rework error checking in the reset path Date: Mon, 23 Oct 2017 17:36:48 -0400 Message-Id: <1508794608-15310-1-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171023_143724_129574_8B1B7BD6 X-CRM114-Status: GOOD ( 10.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sinan Kaya , linux-arm-msm@vger.kernel.org, Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 The return codes from various reset types are not consistent. The code is assuming that all reset types will return -ENOTTY when things go wrong. Instead of relying on negative error status, let's bail out if the operation is successful instead. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6078dfc..a753e07 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4200,20 +4200,20 @@ int __pci_reset_function_locked(struct pci_dev *dev) might_sleep(); rc = pci_dev_specific_reset(dev, 0); - if (rc != -ENOTTY) + if (!rc) return rc; if (pcie_has_flr(dev)) { pcie_flr(dev); return 0; } rc = pci_af_flr(dev, 0); - if (rc != -ENOTTY) + if (!rc) return rc; rc = pci_pm_reset(dev, 0); - if (rc != -ENOTTY) + if (!rc) return rc; rc = pci_dev_reset_slot_function(dev, 0); - if (rc != -ENOTTY) + if (!rc) return rc; return pci_parent_bus_reset(dev, 0); }