Skip to contentSkip to conversation

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

PATCH Superseded Alexandru Ardelean 2 participants 5 messages Feb 11, 2023 – Feb 14, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

From: Steffen Aschbacher <[email protected]>

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.

---
 sound/soc/codecs/tlv320adcx140.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tlv320adcx140.c +1 -1
index 91a22d927915..530f321d08e9 100644
@@ -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)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 sound: soc: codec: tlv320adcx140: fix 'ti,gpio-config' DT property init

From: Steffen Aschbacher <[email protected]>

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 nothing defined.

This change extends the check to also check for an error case (most likely to be hit by the case that the 'ti,gpio-config' is not defined).

In case that the 'ti,gpio-config' and the returned 'gpio_count' is not correct, there is a '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.

Fixes d5214321498a ("ASoC: tlv320adcx140: Add support for configuring GPIO pin")

---

Changelog v1 -> v2:
* https://lore.kernel.org/alsa-devel/[email protected]/
* Added 'Fixes:' tag; forgot it on the first patch (getting rusty with this)

 sound/soc/codecs/tlv320adcx140.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tlv320adcx140.c +1 -1
index 91a22d927915..530f321d08e9 100644
@@ -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)
Signature · 1 line
2.34.1
maintainer
#2 lore raw
Quoted 10 lines · Alexandru Ardelean

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 nothing defined.

This change extends the check to also check for an error case (most likely to be hit by the case that the 'ti,gpio-config' is not defined).

[...]

Applied to

broonie/sound.git for-next

Thanks!

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

      commit: 771725efe5e2e5396dd9d1220437e5f9d6b9ca9d

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

maintainer
#3 lore raw
In reply to Alexandru Ardelean
Quoted 4 lines · Alexandru Ardelean

From: Steffen Aschbacher <[email protected]>

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

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

#4 lore raw
Quoted 9 lines · Mark Brown
Quoted 4 lines · Alexandru Ardelean

From: Steffen Aschbacher <[email protected]>

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

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches.

Ack.

Quoted 2 lines

Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing.

Will do.

Quoted 1 line

There's no need to resubmit to fix this alone.

Thank you :)