From bcd4fc8b4628893abdc7738afb815887ac8951d5 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Tue, 26 Mar 2024 17:38:38 +0100
Subject: ASoC: sun8i-codec: Set jack_type from DT in probe

Jack type needs to be set in probe so that it can be used later on.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 sound/soc/sunxi/sun8i-codec.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c
index 6a9e147a6a1b..b195ddc5d5cf 100644
--- a/sound/soc/sunxi/sun8i-codec.c
+++ b/sound/soc/sunxi/sun8i-codec.c
@@ -1602,14 +1602,9 @@ static void sun8i_codec_disable_jack_detect(struct snd_soc_component *component)
 
 static int sun8i_codec_component_get_jack_type(struct snd_soc_component *component)
 {
-	struct device_node *node = component->dev->of_node;
-
-	if (of_property_match_string(node, "jack-type", "headset") >= 0)
-		return SND_JACK_HEADSET | SUN8I_CODEC_BUTTONS;
-	else if (of_property_match_string(node, "jack-type", "headphone") >= 0)
-		return SND_JACK_HEADPHONE;
+	struct sun8i_codec *scodec = snd_soc_component_get_drvdata(component);
 
-	return 0;
+	return scodec->jack_type;
 }
 
 static int sun8i_codec_component_set_jack(struct snd_soc_component *component,
@@ -1671,6 +1666,11 @@ static int sun8i_codec_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, scodec);
 
+	if (of_property_match_string(pdev->dev.of_node, "jack-type", "headset") >= 0)
+		scodec->jack_type = SND_JACK_HEADSET | SUN8I_CODEC_BUTTONS;
+	else if (of_property_match_string(pdev->dev.of_node, "jack-type", "headphone") >= 0)
+		scodec->jack_type = SND_JACK_HEADPHONE;
+
 	if (scodec->quirks->bus_clock) {
 		scodec->clk_bus = devm_clk_get(&pdev->dev, "bus");
 		if (IS_ERR(scodec->clk_bus)) {
-- 
2.35.3

