Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3099490ybi; Fri, 5 Jul 2019 01:54:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMO2cLBdx1+InNoRZoCw7f2Wu44JnIgfozrMGk4KtVBc0sGJd7DQ3cbYd9QOJ76fz8JkQh X-Received: by 2002:a63:6f8d:: with SMTP id k135mr4036085pgc.118.1562316875470; Fri, 05 Jul 2019 01:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562316875; cv=none; d=google.com; s=arc-20160816; b=0QEpdODlVLs6hVhVUW67sPqcvXQ4kt711YgElxmTJt0fcG+UdI/p+gIQHol8NEstTR N1Gt4/EPXg4ux1bY9n7tla4U5qWoWufIJAl0G7mA9H7Se0ZfA3Tv4HCghCLwenurAsHo LjhW3I+cWlqxtxnRBzNZrc8S2unUTcLD+lNFiTOn134Cenxe/tnKZB1d/IoiVLLN1uqX vnpnoSlc6SBq8xxtoNphb+hHA7oV2YdBGNteLOYFhg/+dESmhmHCkKHpBN6pN8e8ezyk jrlC7WglIvbLpOK7V/eorNcHlKigcTd+57AtN3+Tu82jwMlfIrQMn6xmUjiswAOE4mk9 XZVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:message-id :date:subject:cc:to:from; bh=tBHCslONGNXrTuqR08BQriljhrvSbQNaMiL9a/TIMAo=; b=zB6e9ZRCKwEah/gj47ghQOyTmO7oMAUXLbnDknjz449V9JfTzmWmpAertb55Pppu/y DwmL5Zz6gC0Qv4dXfGU391MAf4XzcPzzcm/O4bUS92O8WRQ6slHLyW7o859lxuGN9LPu nrtZ6Ee8v/6Exu4D7NQOjaiYSz57IIbV0tRTyUH2kmTMf4baMpSqXg+1DkMEwU/yKNDm p6DSA9emunY9FywqKgVPTQy1n1gAO0ILtWTq2DVmNDFhfYYK4iYY4jz/Uq8TV80Xxhcu itMRNZwnnTxWb+4tUv6rVlPIMrPLFLCR5jtt147OHoIP0A8yP77laibODfbsL0/0yIkZ NWYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=mJAWtXLu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si8375137pfa.17.2019.07.05.01.54.19; Fri, 05 Jul 2019 01:54:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=mJAWtXLu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbfGEItG (ORCPT + 99 others); Fri, 5 Jul 2019 04:49:06 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:8397 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbfGEItG (ORCPT ); Fri, 5 Jul 2019 04:49:06 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 05 Jul 2019 01:49:09 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 05 Jul 2019 01:49:05 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 05 Jul 2019 01:49:05 -0700 Received: from HQMAIL106.nvidia.com (172.18.146.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 5 Jul 2019 08:49:05 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Fri, 5 Jul 2019 08:49:04 +0000 Received: from moonraker.nvidia.com (Not Verified[10.26.11.221]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 05 Jul 2019 01:49:04 -0700 From: Jon Hunter To: Thierry Reding , Lorenzo Pieralisi , Bjorn Helgaas CC: , , , Manikanta Maddireddy , Jon Hunter Subject: [PATCH] PCI: tegra: Fix support for GPIO based PERST# Date: Fri, 5 Jul 2019 09:48:50 +0100 Message-ID: <20190705084850.30777-1-jonathanh@nvidia.com> X-Mailer: git-send-email 2.17.1 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1562316549; bh=tBHCslONGNXrTuqR08BQriljhrvSbQNaMiL9a/TIMAo=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: X-NVConfidentiality:MIME-Version:Content-Type; b=mJAWtXLuY1JNrR9BMi1//luoq7N7RQzV7q4o2a8v/v9v1QaqQkNEVTrOdJkZyYWzN Bzizezio0/QJN6c1IDzuk1IuqK0EfHChlCErUvY+domCQXoS4JCMwOlaCutYlg+9yG H0OVifUDuhYmON08B9tW0YDOctONAb8JcZnhliFI+QzSOtIoxObXOMrhQqCZz9Dnx9 QlKEYZRPco8SWFYg2cUNWa0NIO1zsqZ8KuG4u9nSIt0Y6H/7lKX0G81/6Wzl7hfCt1 TnFr/kHpaOnpH0+nyn5IyYskyB2V8wflU2jOrFfAIMQlUCJc1vGBnuebN1zqr0Nue9 68PX0w28Noe7w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 5e5e9c23f82a ("PCI: tegra: Add support for GPIO based PERST#") calls the function devm_gpiod_get_from_of_node() to request a GPIO. Unfortunately, around the same time this was merged, commit 025bf37725f1 ("gpio: Fix return value mismatch of function gpiod_get_from_of_node()") was also merged to fix the return value of the function devm_gpiod_get_from_of_node() that was incorrectly returning NULL instead of an error pointer encoded with -ENOENT if no GPIO was found. When this fix for the GPIO subsystem was merged, PCI support for Tegra devices that did not provide a GPIO for the PERST# (which is optional) broke because the Tegra PCI driver was expecting NULL to be returned if no GPIO was present and not -ENOENT. Fix this by checking to see if -ENOENT is returned from the function devm_gpiod_get_from_of_node(), to indicate there is no GPIO for PERST# present, and if this is the case set the variable 'reset_gpio' to NULL. If the variable 'reset_gpio' is NULL then the Tegra PCI driver will fallback to using the AFI register to toggle the PERST#. Finally, correct the comment now that NULL is no longer returned from devm_gpiod_get_from_of_node(). Fixes: 5e5e9c23f82a ("PCI: tegra: Add support for GPIO based PERST#") Signed-off-by: Jon Hunter --- drivers/pci/controller/pci-tegra.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c index 9cc03a2549c0..ff8a346f3e04 100644 --- a/drivers/pci/controller/pci-tegra.c +++ b/drivers/pci/controller/pci-tegra.c @@ -2295,18 +2295,22 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) } /* - * Returns null if reset-gpios property is not populated and - * fall back to using AFI per port register to toggle PERST# - * SFIO line. + * Returns -ENOENT if reset-gpios property is not populated + * and in this case fall back to using AFI per port register + * to toggle PERST# SFIO line. */ rp->reset_gpio = devm_gpiod_get_from_of_node(dev, port, "reset-gpios", 0, GPIOD_OUT_LOW, label); if (IS_ERR(rp->reset_gpio)) { - err = PTR_ERR(rp->reset_gpio); - dev_err(dev, "failed to get reset GPIO: %d\n", err); - return err; + if (PTR_ERR(rp->reset_gpio) == -ENOENT) { + rp->reset_gpio = NULL; + } else { + dev_err(dev, "failed to get reset GPIO: %d\n", + err); + return PTR_ERR(rp->reset_gpio); + } } list_add_tail(&rp->list, &pcie->ports); -- 2.17.1