Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6029736ybc; Wed, 27 Nov 2019 13:42:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyj/Qp/XHlErQe/4yaJjgC/qTrabTUPBUWcoXf+n7CJPpjnr6nXAYDrEOQCeKtEU4SKkmho X-Received: by 2002:a05:6402:54a:: with SMTP id i10mr33909981edx.230.1574890942129; Wed, 27 Nov 2019 13:42:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890942; cv=none; d=google.com; s=arc-20160816; b=e+kI32NRG/AnMSvzOh5ZMwR/5zzfJu3Jo3GdwuzIJ4yl+lyyw1OwJA+g4uy5Sjhb59 2/Wo8NS7T6l/Y02q5//lzz8erI0xkfvNIMhG3Y5j7BN05dFgLUsTkqfyAI9of21eksKy 8VrLppljiyY4sReWIOPinF/+fW54Fj9evLFd2W1+Kh+7CSoYOHo77aSyeeAKcMwSzUqA a9keTrHT2pj2jqew6Lii/S24WwU2Y/2vytIF656iF05AnivnvRlgFyPcAuSA0y3wi380 R1/U0KpzZrsnXOv20qqaaXSzcFK4/SdBGJX2fZ4BrIH5jRNf/CcNsu8BiOFtowlxW88s tBCw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LPP4uVor98VNDxdK6FyGFNKgaPgZpW6W1H7M3u8wwFc=; b=PT1tVmdiyZI2QpSmEULUjXWssWfiENCe27YM/GTbjL1lAimrFW1UKRYFDBgVGPyVtt 4nlIpCfMutvVm2jRCP0L6WzYGsxBkxwtmJNzuGKfyf6lN2/ToqL2pz1/X8vymt4YuwMQ qwWQyF1f9JJBfqGi9vky8rGw4GHOBewJX4TVobFTnwk76b0m+7yVmixC7HTTES2ERe59 IV+r8iEE/tKfrfmIZtDXWmBHNA6IkqrJE7YS1eXBSbZDHQiV7hW1vaDww45KjifpDK8B yaBATV74uDEv/RNmD19HkgVcqgkprGR54HbICd1Bp+EVVoHulrD/5yopKKy8fzR2xMvp my/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BzJn3cXL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19si10476004ejh.172.2019.11.27.13.41.58; Wed, 27 Nov 2019 13:42:22 -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=BzJn3cXL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729659AbfK0Vjp (ORCPT + 99 others); Wed, 27 Nov 2019 16:39:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:52142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729488AbfK0Unq (ORCPT ); Wed, 27 Nov 2019 15:43:46 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 566A521845; Wed, 27 Nov 2019 20:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887425; bh=McwXrVVkytzj+hSaqm76kPsOnhihjhaT2aayiNsJ2Nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BzJn3cXLEbPkFMmieMgS/j0toKLtkeJpQkqoInTZXaYfR/VlNigLItPOJuyKo4RFs OW24Aq9d+jofAIuDx0nHbqpvbI39FZV39VbRZZ2VQRsLGApKLVSWaA11xDTYEuozDj mc4PepKUvJd7Hpj9GdifoCTetlZyvnWfvLwBEt2Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Masney , Linus Walleij , Sasha Levin Subject: [PATCH 4.9 104/151] pinctrl: qcom: spmi-gpio: fix gpio-hog related boot issues Date: Wed, 27 Nov 2019 21:31:27 +0100 Message-Id: <20191127203040.453660098@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203000.773542911@linuxfoundation.org> References: <20191127203000.773542911@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 8093afd17aa4f..69641c9e7d179 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c @@ -790,10 +790,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