Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6022174ybn; Sun, 29 Sep 2019 10:37:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxx3ETl1aDE7tdeoD6fwlBkS77jOqKl96Ff/SVkkeQBOrOzP7TR7NejsMsKLwWf3nLkRnsT X-Received: by 2002:a17:906:5644:: with SMTP id v4mr15897707ejr.52.1569778671301; Sun, 29 Sep 2019 10:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569778671; cv=none; d=google.com; s=arc-20160816; b=BFxA1F7qtN1v2SXPAVajFLuxmHU44HJKCsipcVPqXeAEDf/193Cf2YdJ/Ogal3hbyB JyHIkiAKUZvRON1cXP9CqJf3nVVe4U8lzl584S7RMhpP1fjGs4GDWciL3bsSP/3AxIVI EXz+DvsOL0421kQsRcmvn/bkNFCKQa0a6Vf+n2kmWeL1Mo6ITb1i+GY9YJEq8Y/2554x cOsx0WFkxDrWfbWRk0Np/YkKE9HDawEB9ORcn4VuvAAKMF7fKX8ETkJmAkUj1SLMUYdm Ezzqc3hKZlTe4jOSp3F+YXP+LHbzJSBMMvPrKrJn5m7lj5/dgu07xqPtZuU+86+foF1R ud7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lm91fZLmJRjs9zAfMdUsEvYSsh28iqxuJbvNZ2xhtbo=; b=rJ8wv499ygO5jVIsfpn8BRxhB9K/bP95vFgyvdl7/UX3WygJnjebJwhgqWmVWYRJTG taCgM4DKm2fwui2ZeUZQdyujbzoybvTLfnx0/BxpbFCFWCn6LRje1lNvdfuJb1/QzLxg kqlXwad6p2Ite6yF6dBGVTEAtQU7JdtrPGBnb9oON6ETNwUpGSwqLjajjpaG9oikn5BK 5LvTlyjQfODC5HzvbPFARAmqxmO5ZyasEosncrEkFyLC2cwQY6+JsZr3w2kR406k9Tyh DET/cE+eUxDp5auhjNJ6V6PDeClaMMzJpOaHds+B8DI5glsJFIRoaATp5r8PS2NTZBli 84PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ozmGs7cM; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c26si5862842edx.353.2019.09.29.10.37.27; Sun, 29 Sep 2019 10:37:51 -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=@kernel.org header.s=default header.b=ozmGs7cM; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729561AbfI2RfH (ORCPT + 99 others); Sun, 29 Sep 2019 13:35:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:47052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729207AbfI2Re5 (ORCPT ); Sun, 29 Sep 2019 13:34:57 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4534C21D56; Sun, 29 Sep 2019 17:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569778496; bh=BlvHyFvAAZGnC7hOjDp5jrec36iSCywnYRv27tgvF7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ozmGs7cM17WUI9eIXdLva4F8rZDBBmdC+oaNn0M9eXu76nqRMNy5wbn2WtX11QZ5g n4K0BFAsmGFP12rFl1StVVo1S8OZhMFDS+r0rZMJawygmeIhkMm5dCCQ30PlJ6CI/N xpv/+H+AhbTo/wujNbY+D/bhVw9Qk46ADPxwuTWU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thierry Reding , Heiko Stuebner , Lorenzo Pieralisi , Andrew Murray , Shawn Lin , linux-rockchip@lists.infradead.org, Sasha Levin , linux-pci@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 17/33] PCI: rockchip: Propagate errors for optional regulators Date: Sun, 29 Sep 2019 13:34:05 -0400 Message-Id: <20190929173424.9361-17-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190929173424.9361-1-sashal@kernel.org> References: <20190929173424.9361-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thierry Reding [ Upstream commit 0e3ff0ac5f71bdb6be2a698de0ed0c7e6e738269 ] regulator_get_optional() can fail for a number of reasons besides probe deferral. It can for example return -ENOMEM if it runs out of memory as it tries to allocate data structures. Propagating only -EPROBE_DEFER is problematic because it results in these legitimately fatal errors being treated as "regulator not specified in DT". What we really want is to ignore the optional regulators only if they have not been specified in DT. regulator_get_optional() returns -ENODEV in this case, so that's the special case that we need to handle. So we propagate all errors, except -ENODEV, so that real failures will still cause the driver to fail probe. Tested-by: Heiko Stuebner Signed-off-by: Thierry Reding Signed-off-by: Lorenzo Pieralisi Reviewed-by: Andrew Murray Reviewed-by: Heiko Stuebner Acked-by: Shawn Lin Cc: Shawn Lin Cc: Heiko Stuebner Cc: linux-rockchip@lists.infradead.org Signed-off-by: Sasha Levin --- drivers/pci/controller/pcie-rockchip-host.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip-host.c b/drivers/pci/controller/pcie-rockchip-host.c index 1372d270764f9..5ce8e63756875 100644 --- a/drivers/pci/controller/pcie-rockchip-host.c +++ b/drivers/pci/controller/pcie-rockchip-host.c @@ -608,29 +608,29 @@ static int rockchip_pcie_parse_host_dt(struct rockchip_pcie *rockchip) rockchip->vpcie12v = devm_regulator_get_optional(dev, "vpcie12v"); if (IS_ERR(rockchip->vpcie12v)) { - if (PTR_ERR(rockchip->vpcie12v) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (PTR_ERR(rockchip->vpcie12v) != -ENODEV) + return PTR_ERR(rockchip->vpcie12v); dev_info(dev, "no vpcie12v regulator found\n"); } rockchip->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3"); if (IS_ERR(rockchip->vpcie3v3)) { - if (PTR_ERR(rockchip->vpcie3v3) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (PTR_ERR(rockchip->vpcie3v3) != -ENODEV) + return PTR_ERR(rockchip->vpcie3v3); dev_info(dev, "no vpcie3v3 regulator found\n"); } rockchip->vpcie1v8 = devm_regulator_get_optional(dev, "vpcie1v8"); if (IS_ERR(rockchip->vpcie1v8)) { - if (PTR_ERR(rockchip->vpcie1v8) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (PTR_ERR(rockchip->vpcie1v8) != -ENODEV) + return PTR_ERR(rockchip->vpcie1v8); dev_info(dev, "no vpcie1v8 regulator found\n"); } rockchip->vpcie0v9 = devm_regulator_get_optional(dev, "vpcie0v9"); if (IS_ERR(rockchip->vpcie0v9)) { - if (PTR_ERR(rockchip->vpcie0v9) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (PTR_ERR(rockchip->vpcie0v9) != -ENODEV) + return PTR_ERR(rockchip->vpcie0v9); dev_info(dev, "no vpcie0v9 regulator found\n"); } -- 2.20.1