]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
spi: Add missing error handling for CS GPIOs
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 3 Apr 2019 14:46:56 +0000 (16:46 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 31 May 2019 13:43:40 +0000 (06:43 -0700)
commit91b6a56451fdf7e881df7ab6512be0287c0948b7
treed3a9ab85290e7f8c3fdd45697f1ff0c89744f149
parent3c328af802c679f2fe556b1869a7d63988bda826
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>
drivers/spi/spi.c