Skip to contentSkip to conversation

ASoC: cpcap: use the platform OF node setter

PATCH In review Yige Jiang 2 participants 2 messages Nov 4 – Nov 5

Subsystems (2)
lore
Share & tools
lore

Yige Jiang

author
#0 lore raw

PATCH 1/1 ASoC: cpcap: use the platform OF node setter

cpcap_codec_probe() gets the audio-codec child node and assigns it only to dev.of_node. Platform device release now puts dev.fwnode, so the acquired node reference is never returned.

Use platform_device_set_of_node() to synchronize both fields and give the device its own reference, then put the local lookup reference. The device keeps the node until it is replaced or the platform device is released; a probe retry also drops the old device-owned reference.

Fixes 7b5b51b2b05c ("driver core: platform: count references to all kinds of firmware nodes")
Assisted-by LLM

---
Based on linux-next next-20261102 (2637bdec0535).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y. COMPILE_TEST=y.
Baseline and patched target objects built from this exact base. No full kernel/module-link, hardware or runtime test was performed. AI assistance: Codex (LLM) for ownership analysis, code and changelog.

 sound/soc/codecs/cpcap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/cpcap.c +2 -1
index eaaf141dea57..eda72fe830ae 100644
@@ -1761,7 +1761,8 @@ static int cpcap_codec_probe(struct platform_device *pdev)
 	if (!codec_node)
 		return -ENODEV;
 
-	pdev->dev.of_node = codec_node;
+	platform_device_set_of_node(pdev, codec_node);
+	of_node_put(codec_node);
 
 	cpcap = devm_kzalloc(&pdev->dev, sizeof(*cpcap), GFP_KERNEL);
 	if (!cpcap)

base-commit: 2637bdec0535a2044cd830eba9a79363651d9043

#1 lore raw
Quoted 29 lines · Yige Jiang

cpcap_codec_probe() gets the audio-codec child node and assigns it only to dev.of_node. Platform device release now puts dev.fwnode, so the acquired node reference is never returned.

Use platform_device_set_of_node() to synchronize both fields and give the device its own reference, then put the local lookup reference. The device keeps the node until it is replaced or the platform device is released; a probe retry also drops the old device-owned reference.

Fixes 7b5b51b2b05c ("driver core: platform: count references to all kinds of firmware nodes")
Assisted-by LLM

---
Based on linux-next next-20261102 (2637bdec0535).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y. COMPILE_TEST=y.
Baseline and patched target objects built from this exact base. No full kernel/module-link, hardware or runtime test was performed. AI assistance: Codex (LLM) for ownership analysis, code and changelog.

 sound/soc/codecs/cpcap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/cpcap.c +0 -0
index eaaf141dea57..eda72fe830ae 100644

sound/soc/codecs/cpcap.c static int cpcap_codec_probe(struct platform_device *pdev) · line 1766

Quoted 7 lines
sound/soc/codecs/cpcap.c +2 -1
@@ -1761,7 +1761,8 @@ static int cpcap_codec_probe(struct platform_device *pdev)
 	if (!codec_node)
 		return -ENODEV;
 
-	pdev->dev.of_node = codec_node;
+	platform_device_set_of_node(pdev, codec_node);
+	of_node_put(codec_node);
 

Just use __free(device_node) when calling of_get_child_by_name() and avoid having to call of_node_put().

Bart