summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/da9211-regulator.c
diff options
context:
space:
mode:
authorWaibel Georg <Georg.Waibel@sensor-technik.de>2019-06-20 21:37:08 +0000
committerMark Brown <broonie@kernel.org>2019-06-25 15:26:24 +0100
commit025bf37725f1929542361eef2245df30badf242e (patch)
treeabc73cfad4cc36287feb2cec37f69794ee1623d9 /drivers/regulator/da9211-regulator.c
parent65d80db2ee92330269e90313c6af782036f4d23d (diff)
downloadlinux-stable-025bf37725f1929542361eef2245df30badf242e.tar.gz
linux-stable-025bf37725f1929542361eef2245df30badf242e.tar.bz2
linux-stable-025bf37725f1929542361eef2245df30badf242e.zip
gpio: Fix return value mismatch of function gpiod_get_from_of_node()
In case the requested gpio property is not found in the device tree, some callers of gpiod_get_from_of_node() expect a return value of NULL, others expect -ENOENT. In particular devm_fwnode_get_index_gpiod_from_child() expects -ENOENT. Currently it gets a NULL, which breaks the loop that tries all gpio_suffixes. The result is that a gpio property is not found, even though it is there. This patch changes gpiod_get_from_of_node() to return -ENOENT instead of NULL when the requested gpio property is not found in the device tree. Additionally it modifies all calling functions to properly evaluate the return value. Another approach would be to leave the return value of gpiod_get_from_of_node() as is and fix the bug in devm_fwnode_get_index_gpiod_from_child(). Other callers would still need to be reworked. The effort would be the same as with the chosen solution. Signed-off-by: Georg Waibel <georg.waibel@sensor-technik.de> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/da9211-regulator.c')
-rw-r--r--drivers/regulator/da9211-regulator.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c
index da37b4ccd834..0309823d2c72 100644
--- a/drivers/regulator/da9211-regulator.c
+++ b/drivers/regulator/da9211-regulator.c
@@ -289,6 +289,8 @@ static struct da9211_pdata *da9211_parse_regulators_dt(
0,
GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE,
"da9211-enable");
+ if (IS_ERR(pdata->gpiod_ren[n]))
+ pdata->gpiod_ren[n] = NULL;
n++;
}