Skip to content

Commit 891168d

Browse files
krzkbroonie
authored andcommitted
ASoC: codecs: lpass-rx-macro: Simplify PDS cleanup with devm
Eliminate PDS cleanup by using devm_add_action_or_reset() which results in one less error path and smaller cleanup in remove(). Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://patch.msgid.link/20240701-b4-qcom-audio-lpass-codec-cleanups-v3-1-6d98d4dd1ef5@linaro.org Signed-off-by: Mark Brown <[email protected]>
1 parent e15cc90 commit 891168d

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

sound/soc/codecs/lpass-macro-common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ void lpass_macro_pds_exit(struct lpass_macro *pds);
4141
void lpass_macro_set_codec_version(enum lpass_codec_version version);
4242
enum lpass_codec_version lpass_macro_get_codec_version(void);
4343

44+
static inline void lpass_macro_pds_exit_action(void *pds)
45+
{
46+
lpass_macro_pds_exit(pds);
47+
}
48+
4449
static inline const char *lpass_macro_get_codec_version_string(int version)
4550
{
4651
switch (version) {

sound/soc/codecs/lpass-rx-macro.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,11 +3803,14 @@ static int rx_macro_probe(struct platform_device *pdev)
38033803
if (IS_ERR(rx->pds))
38043804
return PTR_ERR(rx->pds);
38053805

3806+
ret = devm_add_action_or_reset(dev, lpass_macro_pds_exit_action, rx->pds);
3807+
if (ret)
3808+
return ret;
3809+
38063810
base = devm_platform_ioremap_resource(pdev, 0);
3807-
if (IS_ERR(base)) {
3808-
ret = PTR_ERR(base);
3809-
goto err;
3810-
}
3811+
if (IS_ERR(base))
3812+
return PTR_ERR(base);
3813+
38113814
rx->codec_version = lpass_macro_get_codec_version();
38123815
switch (rx->codec_version) {
38133816
case LPASS_CODEC_VERSION_1_0:
@@ -3818,10 +3821,8 @@ static int rx_macro_probe(struct platform_device *pdev)
38183821
rx->rxn_reg_stride = 0x80;
38193822
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_pre_2_5_defaults);
38203823
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
3821-
if (!reg_defaults) {
3822-
ret = -ENOMEM;
3823-
goto err;
3824-
}
3824+
if (!reg_defaults)
3825+
return -ENOMEM;
38253826
memcpy(&reg_defaults[0], rx_defaults, sizeof(rx_defaults));
38263827
memcpy(&reg_defaults[ARRAY_SIZE(rx_defaults)],
38273828
rx_pre_2_5_defaults, sizeof(rx_pre_2_5_defaults));
@@ -3833,18 +3834,15 @@ static int rx_macro_probe(struct platform_device *pdev)
38333834
rx->rxn_reg_stride = 0xc0;
38343835
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults);
38353836
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
3836-
if (!reg_defaults) {
3837-
ret = -ENOMEM;
3838-
goto err;
3839-
}
3837+
if (!reg_defaults)
3838+
return -ENOMEM;
38403839
memcpy(&reg_defaults[0], rx_defaults, sizeof(rx_defaults));
38413840
memcpy(&reg_defaults[ARRAY_SIZE(rx_defaults)],
38423841
rx_2_5_defaults, sizeof(rx_2_5_defaults));
38433842
break;
38443843
default:
38453844
dev_err(dev, "Unsupported Codec version (%d)\n", rx->codec_version);
3846-
ret = -EINVAL;
3847-
goto err;
3845+
return -EINVAL;
38483846
}
38493847

38503848
rx_regmap_config.reg_defaults = reg_defaults;
@@ -3927,8 +3925,6 @@ static int rx_macro_probe(struct platform_device *pdev)
39273925
clk_disable_unprepare(rx->macro);
39283926
err_ver:
39293927
kfree(reg_defaults);
3930-
err:
3931-
lpass_macro_pds_exit(rx->pds);
39323928

39333929
return ret;
39343930
}
@@ -3942,8 +3938,6 @@ static void rx_macro_remove(struct platform_device *pdev)
39423938
clk_disable_unprepare(rx->fsgen);
39433939
clk_disable_unprepare(rx->macro);
39443940
clk_disable_unprepare(rx->dcodec);
3945-
3946-
lpass_macro_pds_exit(rx->pds);
39473941
}
39483942

39493943
static const struct of_device_id rx_macro_dt_match[] = {

0 commit comments

Comments
 (0)