Skip to content

Commit a8915e2

Browse files
krzkbroonie
authored andcommitted
ASoC: qcom: topology: Simplify with cleanup.h
Allocate memory, which is being freed at end of the scope, 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/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d0f4ce8 commit a8915e2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sound/soc/qcom/qdsp6/topology.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
// Copyright (c) 2020, Linaro Limited
33

4+
#include <linux/cleanup.h>
45
#include <sound/soc.h>
56
#include <sound/soc-dapm.h>
67
#include <sound/pcm.h>
@@ -1288,18 +1289,19 @@ int audioreach_tplg_init(struct snd_soc_component *component)
12881289
struct snd_soc_card *card = component->card;
12891290
struct device *dev = component->dev;
12901291
const struct firmware *fw;
1291-
char *tplg_fw_name;
12921292
int ret;
12931293

12941294
/* Inline with Qualcomm UCM configs and linux-firmware path */
1295-
tplg_fw_name = kasprintf(GFP_KERNEL, "qcom/%s/%s-tplg.bin", card->driver_name, card->name);
1295+
char *tplg_fw_name __free(kfree) = kasprintf(GFP_KERNEL, "qcom/%s/%s-tplg.bin",
1296+
card->driver_name,
1297+
card->name);
12961298
if (!tplg_fw_name)
12971299
return -ENOMEM;
12981300

12991301
ret = request_firmware(&fw, tplg_fw_name, dev);
13001302
if (ret < 0) {
13011303
dev_err(dev, "tplg firmware loading %s failed %d\n", tplg_fw_name, ret);
1302-
goto err;
1304+
return ret;
13031305
}
13041306

13051307
ret = snd_soc_tplg_component_load(component, &audioreach_tplg_ops, fw);
@@ -1309,8 +1311,6 @@ int audioreach_tplg_init(struct snd_soc_component *component)
13091311
}
13101312

13111313
release_firmware(fw);
1312-
err:
1313-
kfree(tplg_fw_name);
13141314

13151315
return ret;
13161316
}

0 commit comments

Comments
 (0)