[PATCH] sound: soc: codec: tlv320adcx140: fix 'ti,gpio-config' DT property init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Steffen Aschbacher <steffen.aschbacher@xxxxxxxx>

When the 'ti,gpio-config' property is not defined, the
device_property_count_u32() will return an error, rather than zero.

The current check, only handles a return value of zero, which assumes that
the property is defined and has no elements.

This change extends the check to also handle for an error case (most likely
to be hit by the case that the 'ti,gpio-config' is not defined).
Semantically, this would be the same as 'device_property_count_u32()'
returning zero.

In case that 'ti,gpio-config' is defined, and returns a 'gpio_count' value
that is incorrect, there is an 'if (gpio_count != ADCX140_NUM_GPIO_CFGS)'
check, a few lines lower that will return -EINVAL.
This means that someone tried to define 'ti,gpio-config', but with the
wrong number of GPIOs.

Signed-off-by: Steffen Aschbacher <steffen.aschbacher@xxxxxxxx>
Signed-off-by: Alexandru Ardelean <alex@xxxxxxxxxxx>
---
 sound/soc/codecs/tlv320adcx140.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index 91a22d927915..530f321d08e9 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -925,7 +925,7 @@ static int adcx140_configure_gpio(struct adcx140_priv *adcx140)
 
 	gpio_count = device_property_count_u32(adcx140->dev,
 			"ti,gpio-config");
-	if (gpio_count == 0)
+	if (gpio_count <= 0)
 		return 0;
 
 	if (gpio_count != ADCX140_NUM_GPIO_CFGS)
-- 
2.34.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux