From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D02BBC43215 for ; Sat, 16 Nov 2019 16:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A926720874 for ; Sat, 16 Nov 2019 16:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573920397; bh=NTM8CJ9PHb5mufU8UMamaiDxsdIWtBjO8nryc/eljy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fMI8CqFyZrVyhS15Bv/ozpYx4fJrIVKE8o07isJvLS18LLvwsWBdDK8KPbTbWHlPU 8tcCRLNeu8lEpDQ53EAat4yZgi7r7AidCVT0kXNOs58hex2v5rS7Cm5pLFu36b24IU qOS2rxOiPpNl9Ebrp65xtfRoQbeP4PUF0Mf0zVPU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730611AbfKPPup (ORCPT ); Sat, 16 Nov 2019 10:50:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:59034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730606AbfKPPuo (ORCPT ); Sat, 16 Nov 2019 10:50:44 -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 E0D7A214E0; Sat, 16 Nov 2019 15:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919444; bh=NTM8CJ9PHb5mufU8UMamaiDxsdIWtBjO8nryc/eljy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h2F55KcF+aN2jNMLE+Tnawq56CnrzAKDII1h77x92PcmCz+PxJ1V3qNW7uRbKBvDL 0bEHf5NJRNvrtbHp8rMvi7b+YNAQRh/bak6+SCpfURr0OtrhgWRQmVJ/QJEtxdmUFN T0f5Dm0qDkNi9A/oPiyIXPplrghYBdNcU3hlT6r4= 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.14 142/150] pinctrl: qcom: spmi-gpio: fix gpio-hog related boot issues Date: Sat, 16 Nov 2019 10:47:20 -0500 Message-Id: <20191116154729.9573-142-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154729.9573-1-sashal@kernel.org> References: <20191116154729.9573-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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 22aaf4375fac0..0f0049dfaa3a1 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -1023,10 +1023,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