diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2019-04-03 17:46:56 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-31 16:43:40 +0300 |
commit | 91b6a56451fdf7e881df7ab6512be0287c0948b7 (patch) | |
tree | d3a9ab85290e7f8c3fdd45697f1ff0c89744f149 /drivers/spi | |
parent | 3c328af802c679f2fe556b1869a7d63988bda826 (diff) | |
download | linux-91b6a56451fdf7e881df7ab6512be0287c0948b7.tar.xz |
spi: Add missing error handling for CS GPIOs
[ Upstream commit 1723fdec5fcbc4de3d26bbb23a9e1704ee258955 ]
While devm_gpiod_get_index_optional() returns NULL if the GPIO is not
present (i.e. -ENOENT), it may still return other error codes, like
-EPROBE_DEFER. Currently these are not handled, leading to
unrecoverable failures later in case of probe deferral:
gpiod_set_consumer_name: invalid GPIO (errorpointer)
gpiod_direction_output: invalid GPIO (errorpointer)
gpiod_set_value_cansleep: invalid GPIO (errorpointer)
gpiod_set_value_cansleep: invalid GPIO (errorpointer)
gpiod_set_value_cansleep: invalid GPIO (errorpointer)
Detect and propagate errors to fix this.
Fixes: f3186dd876697e69 ("spi: Optionally use GPIO descriptors for CS GPIOs")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d17f68775a4b..e3f2e15b75ad 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2195,6 +2195,8 @@ static int spi_get_gpio_descs(struct spi_controller *ctlr) */ cs[i] = devm_gpiod_get_index_optional(dev, "cs", i, GPIOD_OUT_LOW); + if (IS_ERR(cs[i])) + return PTR_ERR(cs[i]); if (cs[i]) { /* |