Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6026153ybc; Wed, 27 Nov 2019 13:38:08 -0800 (PST) X-Google-Smtp-Source: APXvYqwRxOCsBeWR5mSsztrmKaP4fJbc8+ZHtruePHyx1XkDA2d5m1BNKhPvp+14sYKRWINyKy+v X-Received: by 2002:a17:906:d71:: with SMTP id s17mr50731586ejh.312.1574890688321; Wed, 27 Nov 2019 13:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890688; cv=none; d=google.com; s=arc-20160816; b=o6s5widrExK5qnKjibTJjgrspjOrFA6eqhbHII+wJa10QvBUQ4cAIo/gpHvkHD5czk b3yFV1Q7oOmAq+Ba78N07E+seYhi4xtY8anGQJ7JLBR/i3GJJBNnI4Q2HMKt4AuRPXck d9jNfcbjhiXws7MFVNd29umFZTal1Q2wqvD9LqztRqR2359FGM7o7jHIu/Bfs8RYKxAH ahqNmXM1kKWBxtDjRlcGKuY9h0+RoKqmzReZFjXOC5PxNoe654X7ro2xLi2xmIOYEGDn bRvkd1KTbAAsNhe119WH2W60JS3Ou+QcijzgSyM0G8LCCmKYJ+N4Hk69dY4GSxqql9QD QGwQ== 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=iE6ggiCLjqTCzmoP+AjJmdpfDg3TlR9YotlvPD0q9vk=; b=zZRO4SuIzWyar2BMhOYswQVabNLnR9XtbFE8ukX8WDoLMQtHQzDMx5lRGM1kAMK1Ni nvXtStgBsBa1l3EUsNhl/reZL5zJNWi+ze+nIAXYYbjF8pkYwO9PuKLY7q0890eDkEZE +Jv3WwCcblrGUKxiWIQC7ODSltmllGzghqHm3CHlIg0rkue0VGrYNj9qu+vNLegIBE2o HImRzttCRaVLy9mZmRTjx1GC2bw9P4a/+mmbYS5XEXshNWQ+Cclr7C/8KBpAZQV1bQu2 LAxGlbtlm50bdgUqJ15HU+Dwd4sYBp7Jo+Y5uinjKvN6jJ2yhlSaFxnUJZdn/8m2TTgp WlCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p8b0uwHu; 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 c22si10465428eja.111.2019.11.27.13.37.44; Wed, 27 Nov 2019 13:38:08 -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=p8b0uwHu; 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 S1730688AbfK0VdR (ORCPT + 99 others); Wed, 27 Nov 2019 16:33:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:39860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730600AbfK0UwW (ORCPT ); Wed, 27 Nov 2019 15:52:22 -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 901D021871; Wed, 27 Nov 2019 20:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887942; bh=NTM8CJ9PHb5mufU8UMamaiDxsdIWtBjO8nryc/eljy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p8b0uwHud0mal4Ugki8jBMPg7IaxWSVDSHh8GiEeVhEWulnB1c0DsszRwgY5TzkjF YOWu6QLe71yitJm/wA05+oUQhb0+BGZvaBuBEl3SOKl6XF42Ah1A1Vgob4qsxa2K3y Jr5TP+XxeRD7FxuTimWi8Y1LDyeCKT3tZRPyKLp8= 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.14 155/211] pinctrl: qcom: spmi-gpio: fix gpio-hog related boot issues Date: Wed, 27 Nov 2019 21:31:28 +0100 Message-Id: <20191127203108.647142057@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@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 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