Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp766314ybc; Sat, 16 Nov 2019 08:19:05 -0800 (PST) X-Google-Smtp-Source: APXvYqyYEjXVsheBuCD5mPwiQQJo4voILuBPw+nn4od0ZgfwJdcwHBZdgEpsiLaXa3Zlig2f019f X-Received: by 2002:a1c:7f54:: with SMTP id a81mr21479154wmd.48.1573921145601; Sat, 16 Nov 2019 08:19:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921145; cv=none; d=google.com; s=arc-20160816; b=Wn7mRN54zbF/YgOymNyawcLm4R72mC1XecuNok2l12Iqaytr0H7lxLYrHbKCsd1onq HYcVmOAeyciyWnvOMs8B2n5G4LqMEJMEJP6Lb/abfup+ne9BDMnD75OkpZ4u4MM39udy Utxnh42k1i0UFivBafQhZK5gPHe/xL/Tyvu74QxEl94NFfDUxFVKvz8qv3HD7NJrvWLz BH0fx0tazcp77ccc0OsgwJ30hYFOoLjkhdMuS8XnFIhK5H5yE5hZh4a0ZUIYEZGvsIqw qMObd999G/4eir/Rsnhyhmkn2uBi6TEuRgsywqiiBmTFwvRwiwILv90OLb+7OfsJHEPm U23g== 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=svdmmRxGRjvILmudTNqagfpGy4J+Nugnoo45FtMASfU=; b=skBpDZ1alw0eaST8AoLe1uvHxqvECM61PXp6GstHqHgcGZB0+coR1sbtP9FLJ0ENTd 7fk1+DH2iBrlP0SacRxS/ysMItrmmeHO/Qj89yO8OqKu5OfnvngkErtPQB7xFmURt0s5 ufr018oqnmWrAMHGIMjtthzaoKGujRPRWErwE9yIdBAi282EiVZMMpGQnGfMH7ic+WMR n50H4Y0FcpqPCy8w9v4ux2Bu425Q2xXtqDol85PWElKLbt+OfBk+SWGf/AIBjfD9Dwfi BahTECN/XLYoYePAqYBTjFUMZcJ9/6HWM0mxzvARtapPGLevuUKKM4+s1qkTjsefT9ln 1n5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XnBauPPr; 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 c5si8989700edc.246.2019.11.16.08.18.40; Sat, 16 Nov 2019 08:19:05 -0800 (PST) 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=XnBauPPr; 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 S1731952AbfKPQQS (ORCPT + 99 others); Sat, 16 Nov 2019 11:16:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:53682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728892AbfKPPrD (ORCPT ); Sat, 16 Nov 2019 10:47:03 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (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 0833520855; Sat, 16 Nov 2019 15:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919223; bh=/UtcM2CJ+MzcFJltihVFYIShK9Fi91fdbH/dA9RjkHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XnBauPPrY73SBV8wpD2xyd2vISE6Cuob0YSM1O22s9myl0RGwSRVWbGvZ2BkXthOG H5iilzB4n6/rASJ/r6vM1BsQWqDTUVZE/zyoFBs3loH7y+g/YkAoNf9hFo7SSJ+VqM Y2XTW2rjkggV/Z2ywOAKjyKSwkHJzcE0GhHsDn8E= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Brian Masney , Linus Walleij , Sasha Levin , linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 227/237] pinctrl: qcom: spmi-gpio: fix gpio-hog related boot issues Date: Sat, 16 Nov 2019 10:41:02 -0500 Message-Id: <20191116154113.7417-227-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-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: Brian Masney [ Upstream commit 149a96047237574b756d872007c006acd0cc6687 ] When attempting to setup up a gpio hog, device probing would repeatedly fail with -EPROBE_DEFERED errors. It was caused by a circular dependency between the gpio and pinctrl frameworks. If the gpio-ranges property is present in device tree, then the gpio framework will handle the gpio pin registration and eliminate the circular dependency. See Christian Lamparter's commit a86caa9ba5d7 ("pinctrl: msm: fix gpio-hog related boot issues") for a detailed commit message that explains the issue in much more detail. The code comment in this commit came from Christian's commit. Signed-off-by: Brian Masney Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index cf82db78e69e6..0c30f5eb4c714 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -1028,10 +1028,23 @@ static int pmic_gpio_probe(struct platform_device *pdev) return ret; } - ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins); - if (ret) { - dev_err(dev, "failed to add pin range\n"); - goto err_range; + /* + * For DeviceTree-supported systems, the gpio core checks the + * pinctrl's device node for the "gpio-ranges" property. + * If it is present, it takes care of adding the pin ranges + * for the driver. In this case the driver can skip ahead. + * + * In order to remain compatible with older, existing DeviceTree + * files which don't set the "gpio-ranges" property or systems that + * utilize ACPI the driver has to call gpiochip_add_pin_range(). + */ + if (!of_property_read_bool(dev->of_node, "gpio-ranges")) { + ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, + npins); + if (ret) { + dev_err(dev, "failed to add pin range\n"); + goto err_range; + } } return 0; -- 2.20.1