Commit 891168dc authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240701-b4-qcom-audio-lpass-codec-cleanups-v3-1-6d98d4dd1ef5@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e15cc906
...@@ -41,6 +41,11 @@ void lpass_macro_pds_exit(struct lpass_macro *pds); ...@@ -41,6 +41,11 @@ void lpass_macro_pds_exit(struct lpass_macro *pds);
void lpass_macro_set_codec_version(enum lpass_codec_version version); void lpass_macro_set_codec_version(enum lpass_codec_version version);
enum lpass_codec_version lpass_macro_get_codec_version(void); enum lpass_codec_version lpass_macro_get_codec_version(void);
static inline void lpass_macro_pds_exit_action(void *pds)
{
lpass_macro_pds_exit(pds);
}
static inline const char *lpass_macro_get_codec_version_string(int version) static inline const char *lpass_macro_get_codec_version_string(int version)
{ {
switch (version) { switch (version) {
......
...@@ -3803,11 +3803,14 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3803,11 +3803,14 @@ static int rx_macro_probe(struct platform_device *pdev)
if (IS_ERR(rx->pds)) if (IS_ERR(rx->pds))
return PTR_ERR(rx->pds); return PTR_ERR(rx->pds);
ret = devm_add_action_or_reset(dev, lpass_macro_pds_exit_action, rx->pds);
if (ret)
return ret;
base = devm_platform_ioremap_resource(pdev, 0); base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base)) { if (IS_ERR(base))
ret = PTR_ERR(base); return PTR_ERR(base);
goto err;
}
rx->codec_version = lpass_macro_get_codec_version(); rx->codec_version = lpass_macro_get_codec_version();
switch (rx->codec_version) { switch (rx->codec_version) {
case LPASS_CODEC_VERSION_1_0: case LPASS_CODEC_VERSION_1_0:
...@@ -3818,10 +3821,8 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3818,10 +3821,8 @@ static int rx_macro_probe(struct platform_device *pdev)
rx->rxn_reg_stride = 0x80; rx->rxn_reg_stride = 0x80;
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_pre_2_5_defaults); def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_pre_2_5_defaults);
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL); reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
if (!reg_defaults) { if (!reg_defaults)
ret = -ENOMEM; return -ENOMEM;
goto err;
}
memcpy(&reg_defaults[0], rx_defaults, sizeof(rx_defaults)); memcpy(&reg_defaults[0], rx_defaults, sizeof(rx_defaults));
memcpy(&reg_defaults[ARRAY_SIZE(rx_defaults)], memcpy(&reg_defaults[ARRAY_SIZE(rx_defaults)],
rx_pre_2_5_defaults, sizeof(rx_pre_2_5_defaults)); rx_pre_2_5_defaults, sizeof(rx_pre_2_5_defaults));
...@@ -3833,18 +3834,15 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3833,18 +3834,15 @@ static int rx_macro_probe(struct platform_device *pdev)
rx->rxn_reg_stride = 0xc0; rx->rxn_reg_stride = 0xc0;
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults); def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults);
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL); reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
if (!reg_defaults) { if (!reg_defaults)
ret = -ENOMEM; return -ENOMEM;
goto err;
}
memcpy(&reg_defaults[0], rx_defaults, sizeof(rx_defaults)); memcpy(&reg_defaults[0], rx_defaults, sizeof(rx_defaults));
memcpy(&reg_defaults[ARRAY_SIZE(rx_defaults)], memcpy(&reg_defaults[ARRAY_SIZE(rx_defaults)],
rx_2_5_defaults, sizeof(rx_2_5_defaults)); rx_2_5_defaults, sizeof(rx_2_5_defaults));
break; break;
default: default:
dev_err(dev, "Unsupported Codec version (%d)\n", rx->codec_version); dev_err(dev, "Unsupported Codec version (%d)\n", rx->codec_version);
ret = -EINVAL; return -EINVAL;
goto err;
} }
rx_regmap_config.reg_defaults = reg_defaults; rx_regmap_config.reg_defaults = reg_defaults;
...@@ -3927,8 +3925,6 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3927,8 +3925,6 @@ static int rx_macro_probe(struct platform_device *pdev)
clk_disable_unprepare(rx->macro); clk_disable_unprepare(rx->macro);
err_ver: err_ver:
kfree(reg_defaults); kfree(reg_defaults);
err:
lpass_macro_pds_exit(rx->pds);
return ret; return ret;
} }
...@@ -3942,8 +3938,6 @@ static void rx_macro_remove(struct platform_device *pdev) ...@@ -3942,8 +3938,6 @@ static void rx_macro_remove(struct platform_device *pdev)
clk_disable_unprepare(rx->fsgen); clk_disable_unprepare(rx->fsgen);
clk_disable_unprepare(rx->macro); clk_disable_unprepare(rx->macro);
clk_disable_unprepare(rx->dcodec); clk_disable_unprepare(rx->dcodec);
lpass_macro_pds_exit(rx->pds);
} }
static const struct of_device_id rx_macro_dt_match[] = { static const struct of_device_id rx_macro_dt_match[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment