Commit ee5e13b2 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240701-b4-qcom-audio-lpass-codec-cleanups-v3-2-6d98d4dd1ef5@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 891168dc
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
#include <linux/cleanup.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
...@@ -3764,7 +3765,6 @@ static const struct snd_soc_component_driver rx_macro_component_drv = { ...@@ -3764,7 +3765,6 @@ static const struct snd_soc_component_driver rx_macro_component_drv = {
static int rx_macro_probe(struct platform_device *pdev) static int rx_macro_probe(struct platform_device *pdev)
{ {
struct reg_default *reg_defaults;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
kernel_ulong_t flags; kernel_ulong_t flags;
struct rx_macro *rx; struct rx_macro *rx;
...@@ -3812,6 +3812,8 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3812,6 +3812,8 @@ static int rx_macro_probe(struct platform_device *pdev)
return PTR_ERR(base); return PTR_ERR(base);
rx->codec_version = lpass_macro_get_codec_version(); rx->codec_version = lpass_macro_get_codec_version();
struct reg_default *reg_defaults __free(kfree) = NULL;
switch (rx->codec_version) { switch (rx->codec_version) {
case LPASS_CODEC_VERSION_1_0: case LPASS_CODEC_VERSION_1_0:
case LPASS_CODEC_VERSION_1_1: case LPASS_CODEC_VERSION_1_1:
...@@ -3849,10 +3851,8 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3849,10 +3851,8 @@ static int rx_macro_probe(struct platform_device *pdev)
rx_regmap_config.num_reg_defaults = def_count; rx_regmap_config.num_reg_defaults = def_count;
rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config); rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config);
if (IS_ERR(rx->regmap)) { if (IS_ERR(rx->regmap))
ret = PTR_ERR(rx->regmap); return PTR_ERR(rx->regmap);
goto err_ver;
}
dev_set_drvdata(dev, rx); dev_set_drvdata(dev, rx);
...@@ -3864,7 +3864,7 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3864,7 +3864,7 @@ static int rx_macro_probe(struct platform_device *pdev)
ret = clk_prepare_enable(rx->macro); ret = clk_prepare_enable(rx->macro);
if (ret) if (ret)
goto err_ver; return ret;
ret = clk_prepare_enable(rx->dcodec); ret = clk_prepare_enable(rx->dcodec);
if (ret) if (ret)
...@@ -3910,7 +3910,6 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3910,7 +3910,6 @@ static int rx_macro_probe(struct platform_device *pdev)
if (ret) if (ret)
goto err_clkout; goto err_clkout;
kfree(reg_defaults);
return 0; return 0;
err_clkout: err_clkout:
...@@ -3923,8 +3922,6 @@ static int rx_macro_probe(struct platform_device *pdev) ...@@ -3923,8 +3922,6 @@ static int rx_macro_probe(struct platform_device *pdev)
clk_disable_unprepare(rx->dcodec); clk_disable_unprepare(rx->dcodec);
err_dcodec: err_dcodec:
clk_disable_unprepare(rx->macro); clk_disable_unprepare(rx->macro);
err_ver:
kfree(reg_defaults);
return ret; return ret;
} }
......
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