ASoC: mediatek: mt8192: Improve error handling
Subsystems (3)
cover ASoC: mediatek: mt8192: Improve error handling
From: bui duc phuc <[email protected]>
Hi all,
This series addresses part of the error handling in the MT8192 driver.
It propagates errors from clock operations, GPIO requests, and DAPM event handlers, and uses dev_err_probe() for cleaner probe logic.
Compile-tested only.
Best regards,
Phuc
bui duc phuc (15):
ASoC: mediatek: mt8192: fix APLL mux error handling
ASoC: mediatek: mt8192: fix AFE clock error handling
ASoC: mediatek: mt8192: fix error handling in APLL enable functions
ASoC: mediatek: mt8192: fix MCK clock error handling
ASoC: mediatek: mt8192: switch to devm_clk_get_optional()
ASoC: mediatek: mt8192: Use dev_err_probe() in mt8192_init_clock()
ASoC: mediatek: mt8192: Propagate errors in mt8192_afe_gpio_request()
ASoC: mediatek: mt8192: Use dev_err_probe() for devm_pinctrl_get()
ASoC: mediatek: mt8192: check return values in mt8192_afe_gpio_init()
ASoC: mediatek: mt8192: Handle regcache_sync() failure in runtime
resume
ASoC: mediatek: mt8192: Remove redundant error message
ASoC: mediatek: mt8192: Propagate mt8192_afe_gpio_request() errors in
ADDA DAI
ASoC: mediatek: mt8192: Propagate errors in TDM DAI DAPM event
handlers
ASoC: mediatek: mt8192: Propagate errors in I2S DAI DAPM event
handlers
ASoC: mediatek: mt8192-mt6359: Fix error handling in MTKAIF
calibration
sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 163 +++++++++++------- sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 94 +++++----- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 12 +- sound/soc/mediatek/mt8192/mt8192-dai-adda.c | 44 +++-- sound/soc/mediatek/mt8192/mt8192-dai-i2s.c | 20 ++- sound/soc/mediatek/mt8192/mt8192-dai-tdm.c | 18 +- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 37 ++-- 7 files changed, 240 insertions(+), 148 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/15 ASoC: mediatek: mt8192: fix APLL mux error handling
From: bui duc phuc <[email protected]>
Propagate errors from clock operations in the enable path and clean up previously enabled clocks when a later operation fails.
For the disable path, continue disabling all clocks even if a clock operation fails. Log the error without returning it, so the disable path can perform as much cleanup as possible.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 54 +++++++++++++--------- 1 file changed, 32 insertions(+), 22 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +32 -22
@@ -87,7 +87,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], ret); - goto EXIT; +return ret; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], afe_priv->clk[CLK_TOP_APLL1_CK ]);
@@ -95,7 +95,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_TOP_APLL1_CK ], ret); - goto EXIT; + goto err_disable_mux_aud_1; }/* 180.6336 / 4 = 45.1584MHz */
@@ -103,7 +103,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], ret); - goto EXIT; + goto err_set_parent_mux_aud_1; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ], afe_priv->clk[CLK_TOP_APLL1_D4 ]);
@@ -111,31 +111,36 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_TOP_APLL1_D4 ], ret); - goto EXIT; + goto err_disable_mux_aud_eng1; } }else { ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ], afe_priv->clk[CLK_CLK26M ]); -if (ret) { +if (ret)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; - }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]); ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], afe_priv->clk[CLK_CLK26M ]); -if (ret) { +if (ret)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; - }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); } -EXIT: +return 0 ; + +err_disable_mux_aud_eng1: +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]); +err_set_parent_mux_aud_1: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], + afe_priv->clk[CLK_CLK26M ]); +err_disable_mux_aud_1: +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); +return ret; }
@@ -149,7 +154,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], ret); - goto EXIT; +return ret; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], afe_priv->clk[CLK_TOP_APLL2_CK ]);
@@ -157,7 +162,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_TOP_APLL2_CK ], ret); - goto EXIT; + goto err_disable_mux_aud_2; }/* 196.608 / 4 = 49.152MHz */
@@ -165,7 +170,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], ret); - goto EXIT; + goto err_set_parent_mux_aud_2; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ], afe_priv->clk[CLK_TOP_APLL2_D4 ]);
@@ -173,31 +178,36 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_TOP_APLL2_D4 ], ret); - goto EXIT; + goto err_disable_mux_aud_eng2; } }else { ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ], afe_priv->clk[CLK_CLK26M ]); -if (ret) { +if (ret)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; - }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]); ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], afe_priv->clk[CLK_CLK26M ]); -if (ret) { +if (ret)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; - }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); } -EXIT: +return 0 ; + +err_disable_mux_aud_eng2: +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]); +err_set_parent_mux_aud_2: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], + afe_priv->clk[CLK_CLK26M ]); +err_disable_mux_aud_2: +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); +return ret; }
Signature · 1 line
2.43.0
PATCH 2/15 ASoC: mediatek: mt8192: fix AFE clock error handling
In reply to [email protected]From: bui duc phuc <[email protected]>
If a clock operation fails in mt8192_afe_enable_clock(), the function returns immediately via the EXIT label without disabling the clocks that were successfully enabled earlier in the sequence. This leaves unneeded clocks running and causes a resource leak.
Properly unwind clocks enabled before an error by jumping to appropriate cleanup labels on failure.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +19 -9
@@ -220,21 +220,21 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_INFRA_SYS_AUDIO ], ret); - goto EXIT; +return ret; } ret =clk_prepare_enable (afe_priv->clk[CLK_INFRA_AUDIO_26M ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_INFRA_AUDIO_26M ], ret); - goto EXIT; + goto err_disable_infra_sys_audio; } ret =clk_prepare_enable (afe_priv->clk[CLK_MUX_AUDIO ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIO ], ret); - goto EXIT; + goto err_disable_infra_audio_26m; } ret =clk_set_parent (afe_priv->clk[CLK_MUX_AUDIO ], afe_priv->clk[CLK_CLK26M ]);
@@ -242,14 +242,14 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIO ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; + goto err_disable_mux_audio; } ret =clk_prepare_enable (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIOINTBUS ], ret); - goto EXIT; + goto err_disable_mux_audio; } ret =mt8192_set_audio_int_bus_parent (afe,CLK_CLK26M );
@@ -257,7 +257,7 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIOINTBUS ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; + goto err_disable_mux_audiointbus; } ret = clk_set_parent(afe_priv->clk[CLK_TOP_MUX_AUDIO_H],
@@ -266,17 +266,27 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUDIO_H ], aud_clks[CLK_TOP_APLL2_CK ], ret); - goto EXIT; + goto err_disable_mux_audiointbus; } ret =clk_prepare_enable (afe_priv->clk[CLK_AFE ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_AFE ], ret); - goto EXIT; + goto err_disable_mux_audiointbus; } -EXIT: +return 0 ; + +err_disable_mux_audiointbus: +clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]); +err_disable_mux_audio: +clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIO ]); +err_disable_infra_audio_26m: +clk_disable_unprepare (afe_priv->clk[CLK_INFRA_AUDIO_26M ]); +err_disable_infra_sys_audio: +clk_disable_unprepare (afe_priv->clk[CLK_INFRA_SYS_AUDIO ]); +return ret; }
Signature · 1 line
2.43.0
PATCH 3/15 ASoC: mediatek: mt8192: fix error handling in APLL enable functions
In reply to [email protected]From: bui duc phuc <[email protected]>
If a clock operation fails in mt8192_apll1_enable() or apll2_enable(), the functions return without checking the return value of mux settings or unwinding previously enabled clocks and MUX configurations.
Fix this by checking the return value of apll1_mux_setting() and apll2_mux_setting(), and adding proper unwind handling on failure.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +24 -8
@@ -308,20 +308,22 @@ int mt8192_apll1_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll1_mux_setting (afe, true); + ret =apll1_mux_setting (afe, true); +if (ret) +return ret; ret =clk_prepare_enable (afe_priv->clk[CLK_APLL22M ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_APLL22M ], ret); - goto EXIT; + goto err_disable_mux_setting; } ret =clk_prepare_enable (afe_priv->clk[CLK_APLL1_TUNER ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_APLL1_TUNER ], ret); - goto EXIT; + goto err_disable_apll22m; } regmap_update_bits(afe->regmap, AFE_APLL1_TUNER_CFG,
@@ -332,7 +334,13 @@ int mt8192_apll1_enable(struct mtk_base_afe *afe)AFE_22M_ON_MASK_SFT , 0x1 << AFE_22M_ON_SFT); -EXIT: +return 0 ; + +err_disable_apll22m: +clk_disable_unprepare (afe_priv->clk[CLK_APLL22M ]); +err_disable_mux_setting: +apll1_mux_setting (afe, false); +return ret; }
@@ -358,20 +366,22 @@ int mt8192_apll2_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll2_mux_setting (afe, true); + ret =apll2_mux_setting (afe, true); +if (ret) +return ret; ret =clk_prepare_enable (afe_priv->clk[CLK_APLL24M ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_APLL24M ], ret); - goto EXIT; + goto err_disable_mux_setting; } ret =clk_prepare_enable (afe_priv->clk[CLK_APLL2_TUNER ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_APLL2_TUNER ], ret); - goto EXIT; + goto err_disable_apll24m; } regmap_update_bits(afe->regmap, AFE_APLL2_TUNER_CFG,
@@ -382,7 +392,13 @@ int mt8192_apll2_enable(struct mtk_base_afe *afe)AFE_24M_ON_MASK_SFT , 0x1 << AFE_24M_ON_SFT); -EXIT: +return 0 ; + +err_disable_apll24m: +clk_disable_unprepare (afe_priv->clk[CLK_APLL24M ]); +err_disable_mux_setting: +apll2_mux_setting (afe, false); +return ret; }
Signature · 1 line
2.43.0
PATCH 4/15 ASoC: mediatek: mt8192: fix MCK clock error handling
In reply to [email protected]From: bui duc phuc <[email protected]>
If an error occurs after enabling 'm_sel_id' or 'div_clk_id' in mt8192_mck_enable(), the function returns directly without disabling the previously enabled clocks, leading to a resource leak.
Fix this by jumping to proper cleanup labels to unwind enabled clocks on failure paths.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +11 -3
@@ -619,7 +619,7 @@ int mt8192_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)dev_err (afe->dev,"%s(), clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[m_sel_id], aud_clks[apll_clk_id], ret); -return ret; + goto err_disable_m_sel; } }
@@ -628,17 +628,25 @@ int mt8192_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[div_clk_id], ret); -return ret; + goto err_disable_m_sel; } ret =clk_set_rate (afe_priv->clk[div_clk_id], rate);if (ret) {dev_err (afe->dev,"%s(), clk_set_rate %s, rate %d, fail %d\n" , __func__, aud_clks[div_clk_id], rate, ret); -return ret; + goto err_disable_div_clk; }return 0 ; + +err_disable_div_clk: +clk_disable_unprepare (afe_priv->clk[div_clk_id]); +err_disable_m_sel: +if (m_sel_id >=0 ) +clk_disable_unprepare (afe_priv->clk[m_sel_id]); + +return ret; }void mt8192_mck_disable (struct mtk_base_afe *afe,int mck_id)
Signature · 1 line
2.43.0
PATCH 5/15 ASoC: mediatek: mt8192: switch to devm_clk_get_optional()
In reply to [email protected]From: bui duc phuc <[email protected]>
Switch from devm_clk_get() to devm_clk_get_optional() when requesting clocks, as optional clocks automatically return NULL when not present instead of requiring manual check and NULL assignment.
Additionally, handle clock errors properly using dev_err_probe() to propagate error codes (such as -EPROBE_DEFER) on failure instead of just printing a warning and continuing with NULL pointers.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +4 -7
@@ -672,13 +672,10 @@ int mt8192_init_clock(struct mtk_base_afe *afe)return -ENOMEM ;for (i =0 ; i <CLK_NUM ; i++) { - afe_priv->clk[i] =devm_clk_get (afe->dev, aud_clks[i]); -if (IS_ERR (afe_priv->clk[i])) { -dev_warn (afe->dev,"%s devm_clk_get %s fail, ret %ld\n" , - __func__, - aud_clks[i],PTR_ERR (afe_priv->clk[i])); - afe_priv->clk[i] =NULL ; - } + afe_priv->clk[i] =devm_clk_get_optional (afe->dev, aud_clks[i]); +if (IS_ERR (afe_priv->clk[i])) +return dev_err_probe (afe->dev,PTR_ERR (afe_priv->clk[i]), +"failed to get clock %s\n" , aud_clks[i]); } afe_priv->apmixedsys = syscon_regmap_lookup_by_phandle(of_node,
Signature · 1 line
2.43.0
PATCH 6/15 ASoC: mediatek: mt8192: Use dev_err_probe() in mt8192_init_clock()
In reply to [email protected]From: bui duc phuc <[email protected]>
Use dev_err_probe() when obtaining clocks to avoid redundant error messages, particularly for probe deferral.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +9 -15
@@ -680,27 +680,21 @@ int mt8192_init_clock(struct mtk_base_afe *afe) afe_priv->apmixedsys =syscon_regmap_lookup_by_phandle (of_node,"mediatek,apmixedsys" ); -if (IS_ERR (afe_priv->apmixedsys)) { -dev_err (afe->dev,"%s() Cannot find apmixedsys controller: %ld\n" , - __func__,PTR_ERR (afe_priv->apmixedsys)); -return PTR_ERR (afe_priv->apmixedsys); - } +if (IS_ERR (afe_priv->apmixedsys)) +return dev_err_probe (afe->dev,PTR_ERR (afe_priv->apmixedsys), +"Cannot find apmixedsys controller\n" ); afe_priv->topckgen =syscon_regmap_lookup_by_phandle (of_node,"mediatek,topckgen" ); -if (IS_ERR (afe_priv->topckgen)) { -dev_err (afe->dev,"%s() Cannot find topckgen controller: %ld\n" , - __func__,PTR_ERR (afe_priv->topckgen)); -return PTR_ERR (afe_priv->topckgen); - } +if (IS_ERR (afe_priv->topckgen)) +return dev_err_probe (afe->dev,PTR_ERR (afe_priv->topckgen), +"Cannot find topckgen controller\n" ); afe_priv->infracfg =syscon_regmap_lookup_by_phandle (of_node,"mediatek,infracfg" ); -if (IS_ERR (afe_priv->infracfg)) { -dev_err (afe->dev,"%s() Cannot find infracfg: %ld\n" , - __func__,PTR_ERR (afe_priv->infracfg)); -return PTR_ERR (afe_priv->infracfg); - } +if (IS_ERR (afe_priv->infracfg)) +return dev_err_probe (afe->dev,PTR_ERR (afe_priv->infracfg), +"Cannot find infracfg\n" );return 0 ; }
Signature · 1 line
2.43.0
PATCH 7/15 ASoC: mediatek: mt8192: Propagate errors in mt8192_afe_gpio_request()
In reply to [email protected]From: bui duc phuc <[email protected]>
Currently, mt8192_afe_gpio_request() ignores the return values from mt8192_afe_gpio_select() and other helper functions. If configuring a GPIO state fails, the function still returns 0, hiding the failure from callers.
Fix this by capturing and returning the error codes properly.
--- sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 74 +++++++++++---------- 1 file changed, 40 insertions(+), 34 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c +40 -34
@@ -208,98 +208,104 @@ static int mt8192_afe_gpio_adda_ch34_ul(struct device *dev, bool enable)int mt8192_afe_gpio_request (struct device *dev,bool enable,int dai,int uplink) { +int ret; +guard (mutex)(&gpio_request_mutex);switch (dai) {case MT8192_DAI_ADDA :if (uplink) -mt8192_afe_gpio_adda_ul (dev, enable); + ret =mt8192_afe_gpio_adda_ul (dev, enable);else -mt8192_afe_gpio_adda_dl (dev, enable); + ret =mt8192_afe_gpio_adda_dl (dev, enable);break ;case MT8192_DAI_ADDA_CH34 :if (uplink) -mt8192_afe_gpio_adda_ch34_ul (dev, enable); + ret =mt8192_afe_gpio_adda_ch34_ul (dev, enable);else -mt8192_afe_gpio_adda_ch34_dl (dev, enable); + ret =mt8192_afe_gpio_adda_ch34_dl (dev, enable);break ;case MT8192_DAI_I2S_0 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S0_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S0_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S0_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S0_OFF );break ;case MT8192_DAI_I2S_1 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S1_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S1_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S1_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S1_OFF );break ;case MT8192_DAI_I2S_2 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S2_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S2_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S2_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S2_OFF );break ;case MT8192_DAI_I2S_3 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S3_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S3_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S3_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S3_OFF );break ;case MT8192_DAI_I2S_5 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S5_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S5_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S5_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S5_OFF );break ;case MT8192_DAI_I2S_6 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S6_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S6_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S6_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S6_OFF );break ;case MT8192_DAI_I2S_7 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S7_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S7_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S7_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S7_OFF );break ;case MT8192_DAI_I2S_8 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S8_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S8_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S8_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S8_OFF );break ;case MT8192_DAI_I2S_9 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S9_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S9_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S9_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S9_OFF );break ;case MT8192_DAI_TDM :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_TDM_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_TDM_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_TDM_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_TDM_OFF );break ;case MT8192_DAI_VOW :if (enable) { -mt8192_afe_gpio_select (dev, -MT8192_AFE_GPIO_VOW_CLK_ON ); -mt8192_afe_gpio_select (dev, -MT8192_AFE_GPIO_VOW_DAT_ON ); + ret =mt8192_afe_gpio_select (dev, +MT8192_AFE_GPIO_VOW_CLK_ON ); +if (ret) +break ; + ret =mt8192_afe_gpio_select (dev, +MT8192_AFE_GPIO_VOW_DAT_ON ); }else { -mt8192_afe_gpio_select (dev, -MT8192_AFE_GPIO_VOW_CLK_OFF ); -mt8192_afe_gpio_select (dev, -MT8192_AFE_GPIO_VOW_DAT_OFF ); + ret =mt8192_afe_gpio_select (dev, +MT8192_AFE_GPIO_VOW_CLK_OFF ); +if (ret) +break ; + ret =mt8192_afe_gpio_select (dev, +MT8192_AFE_GPIO_VOW_DAT_OFF ); }break ;default :dev_warn (dev,"%s(), invalid dai %d\n" , __func__, dai); -return -EINVAL ; + ret = -EINVAL ; } -return 0 ; +return ret; }EXPORT_SYMBOL (mt8192_afe_gpio_request);
Signature · 1 line
2.43.0
PATCH 8/15 ASoC: mediatek: mt8192: Use dev_err_probe() for devm_pinctrl_get()
In reply to [email protected]From: bui duc phuc <[email protected]>
Use dev_err_probe() when obtaining clocks to avoid redundant error messages, particularly for probe deferral.
--- sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c +2 -6
@@ -132,12 +132,8 @@ int mt8192_afe_gpio_init(struct device *dev)int i, ret; aud_pinctrl =devm_pinctrl_get (dev); -if (IS_ERR (aud_pinctrl)) { - ret =PTR_ERR (aud_pinctrl); -dev_err (dev,"%s(), ret %d, cannot get aud_pinctrl!\n" , - __func__, ret); -return ret; - } +if (IS_ERR (aud_pinctrl)) +return dev_err_probe (dev,PTR_ERR (aud_pinctrl),"cannot get aud_pinctrl!\n" );for (i =0 ; i <ARRAY_SIZE (aud_gpios); i++) { aud_gpios[i].gpioctrl = pinctrl_lookup_state(aud_pinctrl,
Signature · 1 line
2.43.0
PATCH 9/15 ASoC: mediatek: mt8192: check return values in mt8192_afe_gpio_init()
In reply to [email protected]From: bui duc phuc <[email protected]>
Currently, mt8192_afe_gpio_init() ignores the return values of mt8192_afe_gpio_select() and mt8192_afe_gpio_request(). If configuring GPIO states or requesting GPIOs fails during initialization, the function still proceeds and returns 0, masking the initialization failure.
Fix this by checking and propagating the return values properly.
--- sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c +8 -4
@@ -147,13 +147,17 @@ int mt8192_afe_gpio_init(struct device *dev) } } -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_CLK_MOSI_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_CLK_MOSI_ON ); +if (ret) +return ret;/* gpio status init */ -mt8192_afe_gpio_request (dev, false,MT8192_DAI_ADDA ,0 ); -mt8192_afe_gpio_request (dev, false,MT8192_DAI_ADDA ,1 ); + ret =mt8192_afe_gpio_request (dev, false,MT8192_DAI_ADDA ,0 ); +if (ret) +return ret; + ret =mt8192_afe_gpio_request (dev, false,MT8192_DAI_ADDA ,1 ); -return 0 ; +return ret; }EXPORT_SYMBOL (mt8192_afe_gpio_init);
Signature · 1 line
2.43.0
PATCH 10/15 ASoC: mediatek: mt8192: Handle regcache_sync() failure in runtime resume
In reply to [email protected]From: bui duc phuc <[email protected]>
Currently, the return value of regcache_sync() in mt8192_afe_runtime_resume() is ignored. If regcache_sync() fails, the function continues execution with clocks enabled and regcache out of sync.
Fix this by checking the return value of regcache_sync(). On failure, restore regcache to cache-only mode and disable the clocks enabled earlier in the function.
--- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +5 -1
@@ -2104,7 +2104,11 @@ static int mt8192_afe_runtime_resume(struct device *dev) goto skip_regmap;regcache_cache_only (afe->regmap, false); -regcache_sync (afe->regmap); + ret =regcache_sync (afe->regmap); +if (ret) { +regcache_cache_only (afe->regmap, true); +mt8192_afe_disable_clock (afe); + }/* enable audio sys DCM for power saving */ regmap_update_bits(afe_priv->infracfg,
Signature · 1 line
2.43.0
PATCH 11/15 ASoC: mediatek: mt8192: Remove redundant error message
In reply to [email protected]From: bui duc phuc <[email protected]>
The errors handled here are already reported by the called functions, either directly or deeper in the call chain. Therefore, the additional dev_err() and dev_err_probe() call is redundant and can be removed.
--- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +2 -4
@@ -2192,10 +2192,8 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev)/* init audio related clock */ ret =mt8192_init_clock (afe); -if (ret) { -dev_err (dev,"init clock error\n" ); +if (ret)return ret; - }/* reset controller to reset audio regs before regmap cache */ rstc =devm_reset_control_get_exclusive (dev,"audiosys" );
@@ -2271,7 +2269,7 @@ static int mt8192_afe_pcm_dev_probe(struct platform_device *pdev) ret =devm_request_irq (dev, irq_id, mt8192_afe_irq_handler,IRQF_TRIGGER_NONE ,"asys-isr" , (void *)afe);if (ret) -return dev_err_probe (dev, ret,"could not request_irq for Afe_ISR_Handle\n" ); +return ret;/* init sub_dais */ INIT_LIST_HEAD (&afe->sub_dais);
Signature · 1 line
2.43.0
PATCH 12/15 ASoC: mediatek: mt8192: Propagate mt8192_afe_gpio_request() errors in ADDA DAI
In reply to [email protected]From: bui duc phuc <[email protected]>
Currently, DAPM event handlers in mt8192-dai-adda.c ignore the return value of mt8192_afe_gpio_request(). If GPIO configuration fails during PRE_PMU or POST_PMD events, the error is silently ignored.
Fix this by checking and propagating error codes from mt8192_afe_gpio_request() in all ADDA DAPM event handlers.
--- sound/soc/mediatek/mt8192/mt8192-dai-adda.c | 44 +++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-)
sound/soc/mediatek/mt8192/mt8192-dai-adda.c +32 -12
@@ -218,10 +218,13 @@ static int mtk_adda_ul_event(struct snd_soc_dapm_widget *w,struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt);struct mt8192_afe_private *afe_priv = afe->platform_priv;int mtkaif_dmic = afe_priv->mtkaif_dmic; +int ret;switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 ); + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 ); +if (ret) +return ret;/* update setting to dmic */ if (mtkaif_dmic) {
@@ -239,7 +242,9 @@ static int mtk_adda_ul_event(struct snd_soc_dapm_widget *w,case SND_SOC_DAPM_POST_PMD :/* should delayed 1/fs(smallest is 8k) = 125us before afe off */ usleep_range (125 ,135 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,1 ); + ret =mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,1 ); +if (ret) +return ret;break ;default :break ;
@@ -257,11 +262,14 @@ static int mtk_adda_ch34_ul_event(struct snd_soc_dapm_widget *w,struct mt8192_afe_private *afe_priv = afe->platform_priv;int mtkaif_dmic = afe_priv->mtkaif_dmic_ch34;int mtkaif_adda6_only = afe_priv->mtkaif_adda6_only; +int ret;switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 , -1 ); + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 , +1 ); +if (ret) +return ret;/* update setting to dmic */ if (mtkaif_dmic) {
@@ -291,8 +299,10 @@ static int mtk_adda_ch34_ul_event(struct snd_soc_dapm_widget *w,case SND_SOC_DAPM_POST_PMD :/* should delayed 1/fs(smallest is 8k) = 125us before afe off */ usleep_range (125 ,135 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 , -1 ); + ret =mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 , +1 ); +if (ret) +return ret;/* reset dmic */ afe_priv->mtkaif_dmic_ch34 =0 ;
@@ -446,15 +456,20 @@ static int mtk_adda_dl_event(struct snd_soc_dapm_widget *w, {struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt); +int ret;switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 ); + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 ); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD :/* should delayed 1/fs(smallest is 8k) = 125us before afe off */ usleep_range (125 ,135 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,0 ); + ret =mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,0 ); +if (ret) +return ret;break ;default :break ;
@@ -469,17 +484,22 @@ static int mtk_adda_ch34_dl_event(struct snd_soc_dapm_widget *w, {struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt); +int ret;switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 , -0 ); + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 , +0 ); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD :/* should delayed 1/fs(smallest is 8k) = 125us before afe off */ usleep_range (125 ,135 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 , -0 ); + ret =mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 , +0 ); +if (ret) +return ret;break ;default :break ;
Signature · 1 line
2.43.0
PATCH 13/15 ASoC: mediatek: mt8192: Propagate errors in TDM DAI DAPM event handlers
In reply to [email protected]From: bui duc phuc <[email protected]>
Currently, DAPM event handlers in mt8192-dai-tdm.c ignore return values from mt8192_afe_gpio_request() and mt8192_mck_enable().
If GPIO configuration or master clock setup fails during DAPM events, the error is silently ignored.
Fix this by checking and propagating error codes properly in all TDM DAI DAPM event handlers.
--- sound/soc/mediatek/mt8192/mt8192-dai-tdm.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
sound/soc/mediatek/mt8192/mt8192-dai-tdm.c +13 -5
@@ -250,6 +250,7 @@ static int mtk_tdm_en_event(struct snd_soc_dapm_widget *w,struct mt8192_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;if (!tdm_priv) {dev_warn (afe->dev,"%s(), tdm_priv == NULL" , __func__);
@@ -261,16 +262,17 @@ static int mtk_tdm_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true, tdm_priv->id,0 ); + ret =mt8192_afe_gpio_request (afe->dev, true, tdm_priv->id,0 );break ;case SND_SOC_DAPM_POST_PMD : -mt8192_afe_gpio_request (afe->dev, false, tdm_priv->id,0 ); + ret =mt8192_afe_gpio_request (afe->dev, false, tdm_priv->id,0 );break ;default : + ret =0 ;break ; } -return 0 ; +return ret; } static int mtk_tdm_bck_en_event(struct snd_soc_dapm_widget *w,
@@ -282,6 +284,7 @@ static int mtk_tdm_bck_en_event(struct snd_soc_dapm_widget *w,struct mt8192_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;if (!tdm_priv) {dev_warn (afe->dev,"%s(), tdm_priv == NULL" , __func__);
@@ -293,7 +296,9 @@ static int mtk_tdm_bck_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_mck_enable (afe, tdm_priv->bck_id, tdm_priv->bck_rate); + ret =mt8192_mck_enable (afe, tdm_priv->bck_id, tdm_priv->bck_rate); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD :mt8192_mck_disable (afe, tdm_priv->bck_id);
@@ -314,6 +319,7 @@ static int mtk_tdm_mck_en_event(struct snd_soc_dapm_widget *w,struct mt8192_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;if (!tdm_priv) {dev_warn (afe->dev,"%s(), tdm_priv == NULL" , __func__);
@@ -325,7 +331,9 @@ static int mtk_tdm_mck_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_mck_enable (afe, tdm_priv->mclk_id, tdm_priv->mclk_rate); + ret =mt8192_mck_enable (afe, tdm_priv->mclk_id, tdm_priv->mclk_rate); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD : tdm_priv->mclk_rate =0 ;
Signature · 1 line
2.43.0
PATCH 14/15 ASoC: mediatek: mt8192: Propagate errors in I2S DAI DAPM event handlers
In reply to [email protected]From: bui duc phuc <[email protected]>
Currently, DAPM event handlers in mt8192-dai-i2s.c ignore return values from mt8192_afe_gpio_request(), mt8192_apll1_enable(), mt8192_apll2_enable(), and mt8192_mck_enable(). If GPIO configuration or clock setup fails during DAPM events, the error is silently ignored.
Fix this by checking and propagating error codes properly in all I2S DAI DAPM event handlers.
--- sound/soc/mediatek/mt8192/mt8192-dai-i2s.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8192/mt8192-dai-i2s.c +14 -6
@@ -586,6 +586,7 @@ static int mtk_i2s_en_event(struct snd_soc_dapm_widget *w,struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt);struct mtk_afe_i2s_priv *i2s_priv; +int ret; i2s_priv =get_i2s_priv_by_name (afe, w->name);
@@ -599,16 +600,17 @@ static int mtk_i2s_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true, i2s_priv->id,0 ); + ret =mt8192_afe_gpio_request (afe->dev, true, i2s_priv->id,0 );break ;case SND_SOC_DAPM_POST_PMD : -mt8192_afe_gpio_request (afe->dev, false, i2s_priv->id,0 ); + ret =mt8192_afe_gpio_request (afe->dev, false, i2s_priv->id,0 );break ;default : + ret =0 ;break ; } -return 0 ; +return ret; } static int mtk_apll_event(struct snd_soc_dapm_widget *w,
@@ -617,6 +619,7 @@ static int mtk_apll_event(struct snd_soc_dapm_widget *w, {struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt); +int ret;dev_dbg (cmpnt->dev,"%s(), name %s, event 0x%x\n" , __func__, w->name, event);
@@ -624,9 +627,11 @@ static int mtk_apll_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU :if (snd_soc_dapm_widget_name_cmp (w,APLL1_W_NAME ) ==0 ) -mt8192_apll1_enable (afe); + ret =mt8192_apll1_enable (afe);else -mt8192_apll2_enable (afe); + ret =mt8192_apll2_enable (afe); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD :if (snd_soc_dapm_widget_name_cmp (w,APLL1_W_NAME ) ==0 )
@@ -704,6 +709,7 @@ static int mtk_mclk_en_event(struct snd_soc_dapm_widget *w,struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt);struct mtk_afe_i2s_priv *i2s_priv; +int ret;dev_dbg (cmpnt->dev,"%s(), name %s, event 0x%x\n" , __func__, w->name, event);
@@ -716,7 +722,9 @@ static int mtk_mclk_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_mck_enable (afe, i2s_priv->mclk_id, i2s_priv->mclk_rate); + ret =mt8192_mck_enable (afe, i2s_priv->mclk_id, i2s_priv->mclk_rate); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD : i2s_priv->mclk_rate =0 ;
Signature · 1 line
2.43.0
PATCH 15/15 ASoC: mediatek: mt8192-mt6359: Fix error handling in MTKAIF calibration
In reply to [email protected]From: bui duc phuc <[email protected]>
mt8192_mt6359_mtkaif_calibration() ignored the return values of pm_runtime_get_sync() and mt8192_afe_gpio_request(), which could leave PM runtime references or GPIO state unbalanced on failure.
Switch to pm_runtime_resume_and_get(), check each GPIO request, and unwind on error.
--- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-)
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +25 -12
@@ -163,12 +163,23 @@ static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)int chosen_phase_1, chosen_phase_2, chosen_phase_3;int counter;int mtkaif_calib_ok; +int ret =0 ; -pm_runtime_get_sync (afe->dev); -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 ); -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 ); -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 ,1 ); -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 ,0 ); + ret =pm_runtime_resume_and_get (afe->dev); +if (ret <0 ) +return ret; + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 ); +if (ret) + goto err_pm_put; + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 ); +if (ret) + goto err_disable_adda_1; + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 ,1 ); +if (ret) + goto err_disable_adda_0; + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 ,0 ); +if (ret) + goto err_disable_adda_ch34_1;mt6359_mtkaif_calibration_enable (cmpnt_codec);
@@ -289,10 +300,14 @@ static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)mt6359_mtkaif_calibration_disable (cmpnt_codec); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,1 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,0 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 ,1 );mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 ,0 ); +err_disable_adda_ch34_1: +mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 ,1 ); +err_disable_adda_0: +mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,0 ); +err_disable_adda_1: +mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,1 ); +err_pm_put:pm_runtime_put (afe->dev); dev_dbg(afe->dev, "%s(), mtkaif_chosen_phase[0/1/2]:%d/%d/%d\n",
@@ -301,7 +316,7 @@ static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd) afe_priv->mtkaif_chosen_phase[1 ], afe_priv->mtkaif_chosen_phase[2]); -return 0 ; +return ret; }static int mt8192_mt6359_init (struct snd_soc_pcm_runtime *rtd)
@@ -319,9 +334,7 @@ static int mt8192_mt6359_init(struct snd_soc_pcm_runtime *rtd) afe_priv->mtkaif_protocol =MTKAIF_PROTOCOL_2_CLK_P2 ;/* mtkaif calibration */ -mt8192_mt6359_mtkaif_calibration (rtd); - -return 0 ; +return mt8192_mt6359_mtkaif_calibration (rtd); }static int mt8192_rt5682_init (struct snd_soc_pcm_runtime *rtd)
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 9 lines · On Fri, 18 Sep 2026 20:38:56 +0700, [email protected] wrote:
ASoC: mediatek: mt8192: Improve error handling
From: bui duc phuc <[email protected]>
Hi all,
This series addresses part of the error handling in the MT8192 driver.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[01/15] ASoC: mediatek: mt8192: fix APLL mux error handling
https://git.kernel.org/broonie/sound/c/e8c263e0ef95 [02/15] ASoC: mediatek: mt8192: fix AFE clock error handling https://git.kernel.org/broonie/sound/c/7c54781e6e60 [03/15] ASoC: mediatek: mt8192: fix error handling in APLL enable functions https://git.kernel.org/broonie/sound/c/88760524ca99 [04/15] ASoC: mediatek: mt8192: fix MCK clock error handling https://git.kernel.org/broonie/sound/c/4a0ab266cb15 [05/15] ASoC: mediatek: mt8192: switch to devm_clk_get_optional() https://git.kernel.org/broonie/sound/c/6f4edfdce009 [06/15] ASoC: mediatek: mt8192: Use dev_err_probe() in mt8192_init_clock() https://git.kernel.org/broonie/sound/c/bed395cb305b [07/15] ASoC: mediatek: mt8192: Propagate errors in mt8192_afe_gpio_request() https://git.kernel.org/broonie/sound/c/411be3902fa8 [08/15] ASoC: mediatek: mt8192: Use dev_err_probe() for devm_pinctrl_get() https://git.kernel.org/broonie/sound/c/59608878c593 [09/15] ASoC: mediatek: mt8192: check return values in mt8192_afe_gpio_init() https://git.kernel.org/broonie/sound/c/7cca184ad434 [10/15] ASoC: mediatek: mt8192: Handle regcache_sync() failure in runtime resume https://git.kernel.org/broonie/sound/c/d9e264741b04 [11/15] ASoC: mediatek: mt8192: Remove redundant error message https://git.kernel.org/broonie/sound/c/d31c0d3eb414 [12/15] ASoC: mediatek: mt8192: Propagate mt8192_afe_gpio_request() errors in ADDA DAI https://git.kernel.org/broonie/sound/c/eed9414a1b07 [13/15] ASoC: mediatek: mt8192: Propagate errors in TDM DAI DAPM event handlers https://git.kernel.org/broonie/sound/c/d0bc9613bc2d [14/15] ASoC: mediatek: mt8192: Propagate errors in I2S DAI DAPM event handlers https://git.kernel.org/broonie/sound/c/49aeb628d10e [15/15] ASoC: mediatek: mt8192-mt6359: Fix error handling in MTKAIF calibration https://git.kernel.org/broonie/sound/c/d6c8a0b5bf69
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