Mt6359 platform device is instantiated by mfd_add_devices(). In the case, dev->of_node is NULL so that mt6359_parse_dt() always fails to parse the desired DT properties. Gets the DT properties via dev->parent->of_node. Fixes: 8061734ab654 ("ASoC: mediatek: mt6359: add codec driver") Signed-off-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx> --- Previous discussion: https://mailman.alsa-project.org/pipermail/alsa-devel/2020-September/173773.html sound/soc/codecs/mt6359.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/mt6359.c b/sound/soc/codecs/mt6359.c index 72f05335b420..81aafb553bdd 100644 --- a/sound/soc/codecs/mt6359.c +++ b/sound/soc/codecs/mt6359.c @@ -2636,8 +2636,13 @@ static int mt6359_parse_dt(struct mt6359_priv *priv) { int ret; struct device *dev = priv->dev; + struct device_node *np; - ret = of_property_read_u32(dev->of_node, "mediatek,dmic-mode", + np = of_get_child_by_name(dev->parent->of_node, "mt6359codec"); + if (!np) + return -EINVAL; + + ret = of_property_read_u32(np, "mediatek,dmic-mode", &priv->dmic_one_wire_mode); if (ret) { dev_warn(priv->dev, "%s() failed to read dmic-mode\n", @@ -2645,7 +2650,7 @@ static int mt6359_parse_dt(struct mt6359_priv *priv) priv->dmic_one_wire_mode = 0; } - ret = of_property_read_u32(dev->of_node, "mediatek,mic-type-0", + ret = of_property_read_u32(np, "mediatek,mic-type-0", &priv->mux_select[MUX_MIC_TYPE_0]); if (ret) { dev_warn(priv->dev, "%s() failed to read mic-type-0\n", @@ -2653,7 +2658,7 @@ static int mt6359_parse_dt(struct mt6359_priv *priv) priv->mux_select[MUX_MIC_TYPE_0] = MIC_TYPE_MUX_IDLE; } - ret = of_property_read_u32(dev->of_node, "mediatek,mic-type-1", + ret = of_property_read_u32(np, "mediatek,mic-type-1", &priv->mux_select[MUX_MIC_TYPE_1]); if (ret) { dev_warn(priv->dev, "%s() failed to read mic-type-1\n", @@ -2661,7 +2666,7 @@ static int mt6359_parse_dt(struct mt6359_priv *priv) priv->mux_select[MUX_MIC_TYPE_1] = MIC_TYPE_MUX_IDLE; } - ret = of_property_read_u32(dev->of_node, "mediatek,mic-type-2", + ret = of_property_read_u32(np, "mediatek,mic-type-2", &priv->mux_select[MUX_MIC_TYPE_2]); if (ret) { dev_warn(priv->dev, "%s() failed to read mic-type-2\n", -- 2.28.0.526.ge36021eeef-goog