Skip to contentSkip to conversation

ASoC: drop bogus container_of() error handling

PATCH In review Johan Hovold 5 participants 8 messages Dec 19, 2025 – Dec 22, 2025

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

cover ASoC: drop bogus container_of() error handling

The dev_to_sdw_dev() helper uses container_of() to return the containing soundwire device structure of its pointer argument and will never return NULL.

Johan

Johan (3):
ASoC: codecs: pm4125: drop bogus container_of() error handling
ASoC: codecs: wcd937x: drop bogus container_of() error handling
ASoC: soc_sdw_utils: drop bogus container_of() error handling

 sound/soc/codecs/pm4125.c           | 6 ------
 sound/soc/codecs/wcd937x.c          | 5 -----
 sound/soc/sdw_utils/soc_sdw_utils.c | 4 ----
 3 files changed, 15 deletions(-)
Signature · 1 line
2.51.2
#1 lore raw

PATCH 1/3 ASoC: codecs: pm4125: drop bogus container_of() error handling

The dev_to_sdw_dev() helper uses container_of() to return the containing soundwire device structure of its pointer argument and will never return NULL.

Fixes 8ad529484937 ("ASoC: codecs: add new pm4125 audio codec driver")
Cc Alexey Klimov <[email protected]>
---
 sound/soc/codecs/pm4125.c | 6 ------
 1 file changed, 6 deletions(-)
sound/soc/codecs/pm4125.c +0 -6
index 43dcafff6c77..1f0a3f5389f1 100644
@@ -1533,13 +1533,7 @@ static int pm4125_bind(struct device *dev)
 
 	pm4125->sdw_priv[AIF1_CAP] = dev_get_drvdata(pm4125->txdev);
 	pm4125->sdw_priv[AIF1_CAP]->pm4125 = pm4125;
-
 	pm4125->tx_sdw_dev = dev_to_sdw_dev(pm4125->txdev);
-	if (!pm4125->tx_sdw_dev) {
-		dev_err(dev, "could not get txslave with matching of dev\n");
-		ret = -EINVAL;
-		goto error_put_tx;
-	}
 
 	/*
 	 * As TX is the main CSR reg interface, which should not be suspended first.
Signature · 1 line
2.51.2
#3 lore raw

PATCH 2/3 ASoC: codecs: wcd937x: drop bogus container_of() error handling

In reply to Johan Hovold

The dev_to_sdw_dev() helper uses container_of() to return the containing soundwire device structure of its pointer argument and will never return NULL.

Fixes 9be3ec196da4 ("ASoC: codecs: wcd937x: add wcd937x codec driver")
Cc Prasad Kumpatla <[email protected]>
---
 sound/soc/codecs/wcd937x.c | 5 -----
 1 file changed, 5 deletions(-)
sound/soc/codecs/wcd937x.c +0 -5
index f4dbcf04be49..10a2d598caa7 100644
@@ -2763,11 +2763,6 @@ static int wcd937x_bind(struct device *dev)
 	wcd937x->sdw_priv[AIF1_CAP] = dev_get_drvdata(wcd937x->txdev);
 	wcd937x->sdw_priv[AIF1_CAP]->wcd937x = wcd937x;
 	wcd937x->tx_sdw_dev = dev_to_sdw_dev(wcd937x->txdev);
-	if (!wcd937x->tx_sdw_dev) {
-		dev_err(dev, "could not get txslave with matching of dev\n");
-		ret = -EINVAL;
-		goto err_put_txdev;
-	}
 
 	/*
 	 * As TX is the main CSR reg interface, which should not be suspended first.
Signature · 1 line
2.51.2
#4 lore raw

PATCH 3/3 ASoC: soc_sdw_utils: drop bogus container_of() error handling

In reply to Johan Hovold

The dev_to_sdw_dev() helper uses container_of() to return the containing soundwire device structure of its pointer argument and will never return NULL.

Fixes 4f8ef33dd44a ("ASoC: soc_sdw_utils: skip the endpoint that doesn't present")
Cc Bard Liao <[email protected]>
---
 sound/soc/sdw_utils/soc_sdw_utils.c | 4 ----
 1 file changed, 4 deletions(-)
sound/soc/sdw_utils/soc_sdw_utils.c +0 -4
index 6c656b2f7f3a..f62e291c089f 100644
@@ -1414,10 +1414,6 @@ static int is_sdca_endpoint_present(struct device *dev,
 	}
 
 	slave = dev_to_sdw_dev(sdw_dev);
-	if (!slave) {
-		ret = -EINVAL;
-		goto put_device;
-	}
 
 	/* Make sure BIOS provides SDCA properties */
 	if (!slave->sdca_data.interface_revision) {
Signature · 1 line
2.51.2
Reviewed-by on v1 3/3
#5 lore raw

Re: [PATCH 3/3] ASoC: soc_sdw_utils: drop bogus container_of() error handling

Quoted 8 lines · Johan Hovold

The dev_to_sdw_dev() helper uses container_of() to return the containing soundwire device structure of its pointer argument and will never return NULL.

Fixes 4f8ef33dd44a ("ASoC: soc_sdw_utils: skip the endpoint that doesn't present")
Cc Bard Liao <[email protected]>

---

Konrad

Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] ASoC: codecs: pm4125: drop bogus container_of() error handling

In reply to Johan Hovold
Quoted 7 lines · Johan Hovold

The dev_to_sdw_dev() helper uses container_of() to return the containing soundwire device structure of its pointer argument and will never return NULL.

Fixes 8ad529484937 ("ASoC: codecs: add new pm4125 audio codec driver")
Cc Alexey Klimov <[email protected]>

I was about to ask to check other drivers/codecs, most likely wcd937x as one of the reference points to pm4125 codec, but you already did. Thank you for checking this.

Best regards,
Alexey

maintainer
#7 lore raw
In reply to Johan Hovold
Quoted 8 lines · Johan Hovold

The dev_to_sdw_dev() helper uses container_of() to return the containing soundwire device structure of its pointer argument and will never return NULL.

Johan

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: codecs: pm4125: drop bogus container_of() error handling

      commit: 54fa71f5f965fa3ec8846cef9d1154bcb2ba2850
[2/3] ASoC: codecs: wcd937x: drop bogus container_of() error handling
      commit: 61a50d6f58b41e8a7e68d8fc8fc6bfbe30d790d8
[3/3] ASoC: soc_sdw_utils: drop bogus container_of() error handling
      commit: 870b10f61d527fec594e0888f18cc4f32c47433d

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