[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240627-b4-qcom-audio-lpass-codec-cleanups-v1-1-ede31891d238@linaro.org>
Date: Thu, 27 Jun 2024 17:23:43 +0200
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Banajit Goswami <bgoswami@...cinc.com>, Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>
Cc: alsa-devel@...a-project.org, linux-arm-msm@...r.kernel.org,
linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: [PATCH 1/4] ASoC: codecs: lpass-rx-macro: Simplify with devm
allocations
Allocate the default register values array with devm interface to reduce
number of error paths. The array is not used after initializing regmap,
so move the freeing to place right after devm_regmap_init_mmio() to make
it obvious.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
---
sound/soc/codecs/lpass-rx-macro.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 9c4f0763675d..59fe76b13cdb 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -3817,7 +3817,9 @@ static int rx_macro_probe(struct platform_device *pdev)
case LPASS_CODEC_VERSION_2_1:
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);
+ reg_defaults = devm_kmalloc_array(dev, def_count,
+ sizeof(struct reg_default),
+ GFP_KERNEL);
if (!reg_defaults) {
ret = -ENOMEM;
goto err;
@@ -3832,7 +3834,9 @@ static int rx_macro_probe(struct platform_device *pdev)
case LPASS_CODEC_VERSION_2_8:
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);
+ reg_defaults = devm_kmalloc_array(dev, def_count,
+ sizeof(struct reg_default),
+ GFP_KERNEL);
if (!reg_defaults) {
ret = -ENOMEM;
goto err;
@@ -3853,8 +3857,9 @@ static int rx_macro_probe(struct platform_device *pdev)
rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config);
if (IS_ERR(rx->regmap)) {
ret = PTR_ERR(rx->regmap);
- goto err_ver;
+ goto err;
}
+ devm_kfree(dev, reg_defaults);
dev_set_drvdata(dev, rx);
@@ -3866,7 +3871,7 @@ static int rx_macro_probe(struct platform_device *pdev)
ret = clk_prepare_enable(rx->macro);
if (ret)
- goto err_ver;
+ goto err;
ret = clk_prepare_enable(rx->dcodec);
if (ret)
@@ -3912,7 +3917,6 @@ static int rx_macro_probe(struct platform_device *pdev)
if (ret)
goto err_clkout;
- kfree(reg_defaults);
return 0;
err_clkout:
@@ -3925,8 +3929,6 @@ static int rx_macro_probe(struct platform_device *pdev)
clk_disable_unprepare(rx->dcodec);
err_dcodec:
clk_disable_unprepare(rx->macro);
-err_ver:
- kfree(reg_defaults);
err:
lpass_macro_pds_exit(rx->pds);
--
2.43.0
Powered by blists - more mailing lists