From: Takashi Iwai <tiwai@suse.de>
To: Mark Brown <broonie@kernel.org>
Cc: Takashi Iwai <tiwai@suse.de>,
linux-sound@vger.kernel.org, Oder Chiou <oder_chiou@realtek.com>
Subject: Re: [PATCH 13/31] ASoC: rt1320-sdw: Use auto-cleanup for firmware loading
Date: Thu, 06 Aug 2026 09:37:14 +0200 [thread overview]
Message-ID: <87wlu3em39.wl-tiwai@suse.de> (raw)
In-Reply-To: <bed1131f-59a4-4da7-994a-d1d5a6728603@sirena.org.uk>
On Thu, 06 Aug 2026 00:56:23 +0200,
Mark Brown wrote:
>
> On Wed, Aug 05, 2026 at 03:52:14PM +0200, Takashi Iwai wrote:
> > Simplify the code to manage the firmware loading with __free(firmware)
> > auto-cleanup.
> >
> > Only the code refactoring, no functional changes.
>
> > @@ -2170,6 +2164,7 @@ struct rt1320_dspfwheader {
> > goto _exit_;
> > }
> >
> > + const struct firmware *fw __free(firmware) = NULL;
> > request_firmware(&fw, filename, dev);
> > if (fw) {
> > fwheader = (struct rt1320_dspfwheader *)fw->data;
>
> There's a goto further up that jumps over this which clang warns about,
> this will break the build. Landmines like that are why cleanup.h warns
> about mixing it with goto.
That's an issue because I moved the declaration of the variable fw;
if it's left at the beginning of the function as it was, it should
work fine, like the patch below. The same applied to the error for
wm2000.
If this is OK, I'll submit v2 series with the fixes for rt1320-sdw and
wm2000.
thanks,
Takashi
-- 8< --
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH v2 13/31] ASoC: rt1320-sdw: Use auto-cleanup for firmware
loading
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
v1->v2: keep the firmware declaration at the beginning of the function
to co-live with gotos
sound/soc/codecs/rt1320-sdw.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/sound/soc/codecs/rt1320-sdw.c b/sound/soc/codecs/rt1320-sdw.c
index 3a5eebcfefdd..8d2d6697a502 100644
--- a/sound/soc/codecs/rt1320-sdw.c
+++ b/sound/soc/codecs/rt1320-sdw.c
@@ -1786,7 +1786,7 @@ static int rt1320_r0_cali_put(struct snd_kcontrol *kcontrol,
static void rt1320_load_mcu_patch(struct rt1320_sdw_priv *rt1320)
{
struct sdw_slave *slave = rt1320->sdw_slave;
- const struct firmware *patch;
+ const struct firmware *patch __free(firmware) = NULL;
const char *filename;
unsigned int addr, val, min_addr, max_addr;
const unsigned char *ptr;
@@ -1840,17 +1840,15 @@ static void rt1320_load_mcu_patch(struct rt1320_sdw_priv *rt1320)
if (addr > max_addr || addr < min_addr) {
dev_err(&slave->dev, "%s: the address 0x%x is wrong", __func__, addr);
- goto _exit_;
+ return;
}
if (val > 0xff) {
dev_err(&slave->dev, "%s: the value 0x%x is wrong", __func__, val);
- goto _exit_;
+ return;
}
regmap_write(rt1320->regmap, addr, val);
}
}
-_exit_:
- release_firmware(patch);
}
}
@@ -1924,7 +1922,7 @@ static int rt1320_rae_load(struct rt1320_sdw_priv *rt1320)
struct device *dev = &rt1320->sdw_slave->dev;
static const char func_tag[] = "FUNC";
static const char xu_tag[] = "XU";
- const struct firmware *rae_fw = NULL;
+ const struct firmware *rae_fw __free(firmware) = NULL;
unsigned int fw_offset;
unsigned char *fw_data;
unsigned char *param_data;
@@ -1977,7 +1975,6 @@ static int rt1320_rae_load(struct rt1320_sdw_priv *rt1320)
}
if (!retry && !(value & 0x40)) {
dev_err(dev, "%s: RAE is not ready to load\n", __func__);
- release_firmware(rae_fw);
return -ETIMEDOUT;
}
break;
@@ -1998,7 +1995,6 @@ static int rt1320_rae_load(struct rt1320_sdw_priv *rt1320)
}
if (!retry && !(value & 0x40)) {
dev_err(dev, "%s: RAE is not ready to load\n", __func__);
- release_firmware(rae_fw);
return -ETIMEDOUT;
}
break;
@@ -2057,7 +2053,6 @@ static int rt1320_rae_load(struct rt1320_sdw_priv *rt1320)
}
regcache_cache_bypass(rt1320->regmap, false);
- release_firmware(rae_fw);
} else {
dev_err(dev, "%s: Failed to load %s firmware\n", __func__, rae_filename);
@@ -2124,7 +2119,7 @@ struct rt1320_dspfwheader {
struct rt1320_dspfwheader *fwheader;
struct rt1320_imageinfo *ptr_img;
struct sdw_bpt_section sec[10];
- const struct firmware *fw = NULL;
+ const struct firmware *fw __free(firmware) = NULL;
unsigned char *fw_data;
bool dev_fw_match = false;
static const char hdr_sig[] = "AFX";
@@ -2178,7 +2173,6 @@ struct rt1320_dspfwheader {
if (fwheader->sync != 0x0a1c5679) {
dev_err(dev, "%s: FW sync error\n", __func__);
- release_firmware(fw);
goto _exit_;
}
@@ -2256,7 +2250,6 @@ struct rt1320_dspfwheader {
}
regcache_cache_bypass(rt1320->regmap, false);
- release_firmware(fw);
if (!dev_fw_match) {
dev_err(dev, "%s: FW file doesn't match to device\n", __func__);
--
2.55.0
next prev parent reply other threads:[~2026-08-06 7:37 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 [this message]
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 ` [PATCH 19/31] ASoC: tas2781: " Takashi Iwai
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=87wlu3em39.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=broonie@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=oder_chiou@realtek.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