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: 10023147 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 A725B603FA for ; Mon, 23 Oct 2017 21:37:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 990E928822 for ; Mon, 23 Oct 2017 21:37:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D99428926; Mon, 23 Oct 2017 21:37:06 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 4988F28931 for ; Mon, 23 Oct 2017 21:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751344AbdJWVhE (ORCPT ); Mon, 23 Oct 2017 17:37:04 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59148 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282AbdJWVhD (ORCPT ); Mon, 23 Oct 2017 17:37:03 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 530EF606B7; 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 Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Bjorn Helgaas , linux-kernel@vger.kernel.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 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 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); }