@@ -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);
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@linaro.org> --- sound/soc/codecs/lpass-rx-macro.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)