Skip to content

Commit

Permalink
ASoC: qcom: topology: Simplify with cleanup.h
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
krzk authored and broonie committed Jul 9, 2024
1 parent d0f4ce8 commit a8915e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sound/soc/qcom/qdsp6/topology.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2020, Linaro Limited

#include <linux/cleanup.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/pcm.h>
Expand Down Expand Up @@ -1288,18 +1289,19 @@ int audioreach_tplg_init(struct snd_soc_component *component)
struct snd_soc_card *card = component->card;
struct device *dev = component->dev;
const struct firmware *fw;
char *tplg_fw_name;
int ret;

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

ret = request_firmware(&fw, tplg_fw_name, dev);
if (ret < 0) {
dev_err(dev, "tplg firmware loading %s failed %d\n", tplg_fw_name, ret);
goto err;
return ret;
}

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

release_firmware(fw);
err:
kfree(tplg_fw_name);

return ret;
}
Expand Down

0 comments on commit a8915e2

Please sign in to comment.