Skip to content

Commit f4ea37a

Browse files
krzkbroonie
authored andcommitted
spi: cs42l43: Make handling missing spk-id GPIOs explicit
gpiod_get_array_optional() for spk-id GPIOs can return NULL, if they are missing, so do not pass the value to PTR_ERR but instead explicitly treat NULL as acceptable condition. The old code was correct, but misleading because PTR_ERR usually is used on errors. Reported by Smatch: drivers/spi/spi-cs42l43.c:241 cs42l43_get_speaker_id_gpios() warn: passing zero to 'PTR_ERR' Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Charles Keepax <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 075812e commit f4ea37a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/spi/spi-cs42l43.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ static int cs42l43_get_speaker_id_gpios(struct cs42l43_spi *priv, int *result)
237237
int i, ret;
238238

239239
descs = gpiod_get_array_optional(priv->dev, "spk-id", GPIOD_IN);
240-
if (IS_ERR_OR_NULL(descs))
240+
if (!descs)
241+
return 0;
242+
else if (IS_ERR(descs))
241243
return PTR_ERR(descs);
242244

243245
spkid = 0;

0 commit comments

Comments
 (0)