Commit bad4da12 authored by Brian Masney's avatar Brian Masney Committed by Greg Kroah-Hartman

pinctrl: qcom: spmi-gpio: fix gpio-hog related boot issues

[ Upstream commit 149a9604 ]

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 a86caa9b ("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: default avatarBrian Masney <masneyb@onstation.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c24fe780
...@@ -1028,11 +1028,24 @@ static int pmic_gpio_probe(struct platform_device *pdev) ...@@ -1028,11 +1028,24 @@ static int pmic_gpio_probe(struct platform_device *pdev)
return ret; return ret;
} }
ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins); /*
* 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) { if (ret) {
dev_err(dev, "failed to add pin range\n"); dev_err(dev, "failed to add pin range\n");
goto err_range; goto err_range;
} }
}
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment