From: Takashi Iwai <tiwai@suse.de>
To: Mark Brown <broonie@kernel.org>
Cc: linux-sound@vger.kernel.org, Shenghao Ding <shenghao-ding@ti.com>,
Kevin Lu <kevin-lu@ti.com>, Baojun Xu <baojun.xu@ti.com>,
Sen Wang <sen@ti.com>
Subject: [PATCH 19/31] ASoC: tas2781: Use auto-cleanup for firmware loading
Date: Wed, 5 Aug 2026 15:52:20 +0200 [thread overview]
Message-ID: <20260805135247.670693-20-tiwai@suse.de> (raw)
In-Reply-To: <20260805135247.670693-1-tiwai@suse.de>
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Cc: Shenghao Ding <shenghao-ding@ti.com>
Cc: Kevin Lu <kevin-lu@ti.com>
Cc: Baojun Xu <baojun.xu@ti.com>
Cc: Sen Wang <sen@ti.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/soc/codecs/tas2781-fmwlib.c | 45 +++++++++++--------------------
1 file changed, 15 insertions(+), 30 deletions(-)
diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-fmwlib.c
index dcbeb9618195..b1e75fc868b6 100644
--- a/sound/soc/codecs/tas2781-fmwlib.c
+++ b/sound/soc/codecs/tas2781-fmwlib.c
@@ -2243,7 +2243,7 @@ int tas2781_load_calibration(void *context, char *file_name,
{
struct tasdevice_priv *tas_priv = (struct tasdevice_priv *)context;
struct tasdevice *tasdev = &(tas_priv->tasdevice[i]);
- const struct firmware *fw_entry = NULL;
+ const struct firmware *fw_entry __free(firmware) = NULL;
struct tasdevice_fw *tas_fmw;
struct firmware fmw;
int offset = 0;
@@ -2253,60 +2253,50 @@ int tas2781_load_calibration(void *context, char *file_name,
if (ret) {
dev_err(tas_priv->dev, "%s: Request firmware %s failed\n",
__func__, file_name);
- goto out;
+ return ret;
}
if (!fw_entry->size) {
dev_err(tas_priv->dev, "%s: file read error: size = %lu\n",
__func__, (unsigned long)fw_entry->size);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
fmw.size = fw_entry->size;
fmw.data = fw_entry->data;
tas_fmw = tasdev->cali_data_fmw = kzalloc_obj(struct tasdevice_fw);
- if (!tasdev->cali_data_fmw) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!tasdev->cali_data_fmw)
+ return -ENOMEM;
+
tas_fmw->dev = tas_priv->dev;
offset = fw_parse_header(tas_priv, tas_fmw, &fmw, offset);
if (offset == -EINVAL) {
dev_err(tas_priv->dev, "fw_parse_header EXIT!\n");
- ret = offset;
- goto out;
+ return -EINVAL;
}
offset = fw_parse_variable_hdr_cal(tas_priv, tas_fmw, &fmw, offset);
if (offset == -EINVAL) {
dev_err(tas_priv->dev,
"%s: fw_parse_variable_header_cal EXIT!\n", __func__);
- ret = offset;
- goto out;
+ return -EINVAL;
}
offset = fw_parse_program_data(tas_priv, tas_fmw, &fmw, offset);
if (offset < 0) {
dev_err(tas_priv->dev, "fw_parse_program_data EXIT!\n");
- ret = offset;
- goto out;
+ return offset;
}
offset = fw_parse_configuration_data(tas_priv, tas_fmw, &fmw, offset);
if (offset < 0) {
dev_err(tas_priv->dev, "fw_parse_configuration_data EXIT!\n");
- ret = offset;
- goto out;
+ return offset;
}
offset = fw_parse_calibration_data(tas_priv, tas_fmw, &fmw, offset);
if (offset < 0) {
dev_err(tas_priv->dev, "fw_parse_calibration_data EXIT!\n");
- ret = offset;
- goto out;
+ return offset;
}
-out:
- release_firmware(fw_entry);
-
- return ret;
+ return 0;
}
EXPORT_SYMBOL_NS_GPL(tas2781_load_calibration, "SND_SOC_TAS2781_FMWLIB");
@@ -2399,7 +2389,7 @@ static int tasdevice_dspfw_ready(const struct firmware *fmw,
int tasdevice_dsp_parser(void *context)
{
struct tasdevice_priv *tas_priv = (struct tasdevice_priv *)context;
- const struct firmware *fw_entry;
+ const struct firmware *fw_entry __free(firmware) = NULL;
int ret;
ret = request_firmware(&fw_entry, tas_priv->coef_binaryname,
@@ -2407,15 +2397,10 @@ int tasdevice_dsp_parser(void *context)
if (ret) {
dev_err(tas_priv->dev, "%s: load %s error\n", __func__,
tas_priv->coef_binaryname);
- goto out;
+ return ret;
}
- ret = tasdevice_dspfw_ready(fw_entry, tas_priv);
- release_firmware(fw_entry);
- fw_entry = NULL;
-
-out:
- return ret;
+ return tasdevice_dspfw_ready(fw_entry, tas_priv);
}
EXPORT_SYMBOL_NS_GPL(tasdevice_dsp_parser, "SND_SOC_TAS2781_FMWLIB");
--
2.55.0
next prev parent reply other threads:[~2026-08-05 13:53 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 13:52 [PATCH 00/31] ASoC: Use auto-cleanup for firmware loading Takashi Iwai
2026-08-05 13:52 ` [PATCH 01/31] ASoC: aw87390: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 02/31] ASoC: aw88081: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 03/31] ASoC: aw88166: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 04/31] ASoC: aw88261: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 05/31] ASoC: aw88395: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 06/31] ASoC: aw88399: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 07/31] ASoC: fs-amp-lib: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 08/31] ASoC: hdac_hda: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 09/31] ASoC: max98390: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 10/31] ASoC: ntpfw: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 11/31] ASoC: pcm6240: " Takashi Iwai
2026-08-05 16:47 ` Herve Codina
2026-08-06 6:16 ` Takashi Iwai
2026-08-05 13:52 ` [PATCH 12/31] ASoC: peb2466: " Takashi Iwai
2026-08-05 16:50 ` Herve Codina
2026-08-05 13:52 ` [PATCH 13/31] ASoC: rt1320-sdw: " Takashi Iwai
2026-08-05 22:56 ` Mark Brown
2026-08-06 7:37 ` Takashi Iwai
2026-08-06 11:52 ` Mark Brown
2026-08-06 13:48 ` Takashi Iwai
2026-08-05 13:52 ` [PATCH 14/31] ASoC: rt5575: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 15/31] ASoC: rt5677: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 16/31] ASoC: rt722-sdca: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 17/31] ASoC: sigmadsp: se " Takashi Iwai
2026-08-05 16:08 ` Nuno Sá
2026-08-05 13:52 ` [PATCH 18/31] ASoC: sma1307: Use " Takashi Iwai
2026-08-05 13:52 ` Takashi Iwai [this message]
2026-08-05 13:52 ` [PATCH 20/31] ASoC: tas5805m: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 21/31] ASoC: tlv320aic31xx: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 22/31] ASoC: wm0010: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 23/31] ASoC: wm2000: " Takashi Iwai
2026-08-05 23:16 ` Mark Brown
2026-08-06 7:38 ` Takashi Iwai
2026-08-05 13:52 ` [PATCH 24/31] ASoC: zl38060: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 25/31] ASoC: fsl: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 26/31] ASoC: Intel: avs: " Takashi Iwai
2026-08-05 14:48 ` Cezary Rojewski
2026-08-05 13:52 ` [PATCH 27/31] ASoC: Intel: catpt: " Takashi Iwai
2026-08-05 14:48 ` Cezary Rojewski
2026-08-05 13:52 ` [PATCH 28/31] ASoC: qcom: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 29/31] ASoC: renesas: " Takashi Iwai
2026-08-05 13:52 ` [PATCH 30/31] ASoC: SDCA: " Takashi Iwai
2026-08-05 14:34 ` Charles Keepax
2026-08-05 13:52 ` [PATCH 31/31] ASoC: SOF: " Takashi Iwai
2026-08-06 11:56 ` Péter Ujfalusi
2026-08-06 12:06 ` Takashi Iwai
2026-08-06 13:04 ` Péter Ujfalusi
2026-08-06 13:18 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260805135247.670693-20-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=kevin-lu@ti.com \
--cc=linux-sound@vger.kernel.org \
--cc=sen@ti.com \
--cc=shenghao-ding@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox