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 <krzysztof.kozlowski@xxxxxxxxxx>
---
Changes in v3:
1. New patch
---
sound/soc/codecs/lpass-macro-common.h | 5 +++++
sound/soc/codecs/lpass-rx-macro.c | 30 ++++++++++++------------------
2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/sound/soc/codecs/lpass-macro-common.h b/sound/soc/codecs/lpass-macro-common.h
index 3aa9737f2737..21cb30ab706d 100644
--- a/sound/soc/codecs/lpass-macro-common.h
+++ b/sound/soc/codecs/lpass-macro-common.h
@@ -41,6 +41,11 @@ void lpass_macro_pds_exit(struct lpass_macro *pds);
void lpass_macro_set_codec_version(enum lpass_codec_version version);
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)
{
switch (version) {
diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index d47c49c90de3..77e734ad1885 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -3803,11 +3803,14 @@ static int rx_macro_probe(struct platform_device *pdev)
if (IS_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);
- if (IS_ERR(base)) {
- ret = PTR_ERR(base);
- goto err;
- }
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
rx->codec_version = lpass_macro_get_codec_version();
switch (rx->codec_version) {
case LPASS_CODEC_VERSION_1_0:
@@ -3818,10 +3821,8 @@ static int rx_macro_probe(struct platform_device *pdev)
rx->rxn_reg_stride = 0x80;
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);
- if (!reg_defaults) {
- ret = -ENOMEM;
- goto err;
- }
+ if (!reg_defaults)
+ return -ENOMEM;
memcpy(®_defaults[0], rx_defaults, sizeof(rx_defaults));
memcpy(®_defaults[ARRAY_SIZE(rx_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)
rx->rxn_reg_stride = 0xc0;
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults);
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
- if (!reg_defaults) {
- ret = -ENOMEM;
- goto err;
- }
+ if (!reg_defaults)
+ return -ENOMEM;
memcpy(®_defaults[0], rx_defaults, sizeof(rx_defaults));
memcpy(®_defaults[ARRAY_SIZE(rx_defaults)],
rx_2_5_defaults, sizeof(rx_2_5_defaults));
break;
default:
dev_err(dev, "Unsupported Codec version (%d)\n", rx->codec_version);
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}
rx_regmap_config.reg_defaults = reg_defaults;
@@ -3927,8 +3925,6 @@ static int rx_macro_probe(struct platform_device *pdev)
clk_disable_unprepare(rx->macro);
err_ver:
kfree(reg_defaults);
-err:
- lpass_macro_pds_exit(rx->pds);
return ret;
}
@@ -3942,8 +3938,6 @@ static void rx_macro_remove(struct platform_device *pdev)
clk_disable_unprepare(rx->fsgen);
clk_disable_unprepare(rx->macro);
clk_disable_unprepare(rx->dcodec);
-
- lpass_macro_pds_exit(rx->pds);
}
static const struct of_device_id rx_macro_dt_match[] = {
--
2.43.0
[Index of Archives]
[Pulseaudio]
[Linux Audio Users]
[ALSA Devel]
[Fedora Desktop]
[Fedora SELinux]
[Big List of Linux Books]
[Yosemite News]
[KDE Users]