Skip to content

Commit ee5e13b

Browse files
krzkbroonie
authored andcommitted
ASoC: codecs: lpass-rx-macro: Simplify with cleanup.h
Allocate the default register values array with scoped/cleanup.h to reduce number of error paths and make code a bit simpler. Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://patch.msgid.link/20240701-b4-qcom-audio-lpass-codec-cleanups-v3-2-6d98d4dd1ef5@linaro.org Signed-off-by: Mark Brown <[email protected]>
1 parent 891168d commit ee5e13b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
// Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
33

4+
#include <linux/cleanup.h>
45
#include <linux/module.h>
56
#include <linux/init.h>
67
#include <linux/io.h>
@@ -3764,7 +3765,6 @@ static const struct snd_soc_component_driver rx_macro_component_drv = {
37643765

37653766
static int rx_macro_probe(struct platform_device *pdev)
37663767
{
3767-
struct reg_default *reg_defaults;
37683768
struct device *dev = &pdev->dev;
37693769
kernel_ulong_t flags;
37703770
struct rx_macro *rx;
@@ -3812,6 +3812,8 @@ static int rx_macro_probe(struct platform_device *pdev)
38123812
return PTR_ERR(base);
38133813

38143814
rx->codec_version = lpass_macro_get_codec_version();
3815+
struct reg_default *reg_defaults __free(kfree) = NULL;
3816+
38153817
switch (rx->codec_version) {
38163818
case LPASS_CODEC_VERSION_1_0:
38173819
case LPASS_CODEC_VERSION_1_1:
@@ -3849,10 +3851,8 @@ static int rx_macro_probe(struct platform_device *pdev)
38493851
rx_regmap_config.num_reg_defaults = def_count;
38503852

38513853
rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config);
3852-
if (IS_ERR(rx->regmap)) {
3853-
ret = PTR_ERR(rx->regmap);
3854-
goto err_ver;
3855-
}
3854+
if (IS_ERR(rx->regmap))
3855+
return PTR_ERR(rx->regmap);
38563856

38573857
dev_set_drvdata(dev, rx);
38583858

@@ -3864,7 +3864,7 @@ static int rx_macro_probe(struct platform_device *pdev)
38643864

38653865
ret = clk_prepare_enable(rx->macro);
38663866
if (ret)
3867-
goto err_ver;
3867+
return ret;
38683868

38693869
ret = clk_prepare_enable(rx->dcodec);
38703870
if (ret)
@@ -3910,7 +3910,6 @@ static int rx_macro_probe(struct platform_device *pdev)
39103910
if (ret)
39113911
goto err_clkout;
39123912

3913-
kfree(reg_defaults);
39143913
return 0;
39153914

39163915
err_clkout:
@@ -3923,8 +3922,6 @@ static int rx_macro_probe(struct platform_device *pdev)
39233922
clk_disable_unprepare(rx->dcodec);
39243923
err_dcodec:
39253924
clk_disable_unprepare(rx->macro);
3926-
err_ver:
3927-
kfree(reg_defaults);
39283925

39293926
return ret;
39303927
}

0 commit comments

Comments
 (0)