* [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading
@ 2026-07-29 8:37 Takashi Iwai
2026-07-29 8:37 ` [PATCH 01/14] ALSA: 6fire: " Takashi Iwai
` (13 more replies)
0 siblings, 14 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
This is a series of trivial patches that replace the manual
release_firmware() calls with the auto-cleanup via __free(firmware).
It doesn't cover all drivers but just a few as a start.
Takashi
===
Takashi Iwai (14):
ALSA: 6fire: Use auto-cleanup for firmware loading
ALSA: hda: ca0132: Use auto-cleanup for firmware loading
ALSA: hda: intel: Use auto-cleanup for firmware loading
ALSA: msnd: Use auto-cleanup for firmware loading
ALSA: hda: cs35l41: Use auto-cleanup for firmware loading
ALSA: hda: cs35l56: Use auto-cleanup for firmware loading
ALSA: sscape: Use auto-cleanup for firmware loading
ALSA: wavefront: Use auto-cleanup for firmware loading
ALSA: asihpi: Use auto-cleanup for firmware loading
ALSA: cs46xx: Use auto-cleanup for firmware loading
ALSA: korg1212: Use auto-cleanup for firmware loading
ALSA: mixart: Use auto-cleanup for firmware loading
ALSA: pcxhr: Use auto-cleanup for firmware loading
ALSA: sh: Use auto-cleanup for firmware loading
sound/hda/codecs/ca0132.c | 12 ++------
sound/hda/codecs/side-codecs/cs35l41_hda.c | 33 ++++++++------------
sound/hda/codecs/side-codecs/cs35l56_hda.c | 35 ++++++----------------
sound/hda/controllers/intel.c | 3 +-
sound/isa/msnd/msnd_pinnacle.c | 18 ++++-------
sound/isa/sscape.c | 8 ++---
sound/isa/wavefront/wavefront_fx.c | 23 +++++---------
sound/isa/wavefront/wavefront_synth.c | 4 +--
sound/pci/asihpi/hpidspcd.c | 18 +++++------
sound/pci/cs46xx/cs46xx_lib.c | 30 +++++++------------
sound/pci/korg1212/korg1212.c | 8 ++---
sound/pci/mixart/mixart_hwdep.c | 4 +--
sound/pci/pcxhr/pcxhr_hwdep.c | 3 +-
sound/sh/aica.c | 4 +--
sound/usb/6fire/firmware.c | 24 +++------------
15 files changed, 69 insertions(+), 158 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 01/14] ALSA: 6fire: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 02/14] ALSA: hda: ca0132: " Takashi Iwai
` (12 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Clean up the code for managing the firmware loading in the 6fire
driver with __free(firmware) and __free(kfree), so that the loaded
firmware and the name string are cleaned up automatically.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/usb/6fire/firmware.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c
index 123c1c6539b8..d9dd8f44b047 100644
--- a/sound/usb/6fire/firmware.c
+++ b/sound/usb/6fire/firmware.c
@@ -194,23 +194,20 @@ static int usb6fire_fw_ezusb_upload(
int ret;
u8 data;
struct usb_device *device = interface_to_usbdev(intf);
- const struct firmware *fw = NULL;
- struct ihex_record *rec = kmalloc_obj(struct ihex_record);
+ struct ihex_record *rec __free(kfree) = kmalloc_obj(struct ihex_record);
if (!rec)
return -ENOMEM;
+ const struct firmware *fw __free(firmware) = NULL;
ret = request_firmware(&fw, fwname, &device->dev);
if (ret < 0) {
- kfree(rec);
dev_err(&intf->dev,
"error requesting ezusb firmware %s.\n", fwname);
return ret;
}
ret = usb6fire_fw_ihex_init(fw, rec);
if (ret < 0) {
- kfree(rec);
- release_firmware(fw);
dev_err(&intf->dev,
"error validating ezusb firmware %s.\n", fwname);
return ret;
@@ -219,8 +216,6 @@ static int usb6fire_fw_ezusb_upload(
data = 0x01; /* stop ezusb cpu */
ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1);
if (ret) {
- kfree(rec);
- release_firmware(fw);
dev_err(&intf->dev,
"unable to upload ezusb firmware %s: begin message.\n",
fwname);
@@ -231,8 +226,6 @@ static int usb6fire_fw_ezusb_upload(
ret = usb6fire_fw_ezusb_write(device, 0xa0, rec->address,
rec->data, rec->len);
if (ret) {
- kfree(rec);
- release_firmware(fw);
dev_err(&intf->dev,
"unable to upload ezusb firmware %s: data urb.\n",
fwname);
@@ -240,8 +233,6 @@ static int usb6fire_fw_ezusb_upload(
}
}
- release_firmware(fw);
- kfree(rec);
if (postdata) { /* write data after firmware has been uploaded */
ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr,
postdata, postlen);
@@ -270,19 +261,18 @@ static int usb6fire_fw_fpga_upload(
int ret;
int i;
struct usb_device *device = interface_to_usbdev(intf);
- u8 *buffer = kmalloc(FPGA_BUFSIZE, GFP_KERNEL);
+ u8 *buffer __free(kfree) = kmalloc(FPGA_BUFSIZE, GFP_KERNEL);
const char *c;
const char *end;
- const struct firmware *fw;
if (!buffer)
return -ENOMEM;
+ const struct firmware *fw __free(firmware) = NULL;
ret = request_firmware(&fw, fwname, &device->dev);
if (ret < 0) {
dev_err(&intf->dev, "unable to get fpga firmware %s.\n",
fwname);
- kfree(buffer);
return -EIO;
}
@@ -291,8 +281,6 @@ static int usb6fire_fw_fpga_upload(
ret = usb6fire_fw_ezusb_write(device, 8, 0, NULL, 0);
if (ret) {
- kfree(buffer);
- release_firmware(fw);
dev_err(&intf->dev,
"unable to upload fpga firmware: begin urb.\n");
return ret;
@@ -304,15 +292,11 @@ static int usb6fire_fw_fpga_upload(
ret = usb6fire_fw_fpga_write(device, buffer, i);
if (ret < 0) {
- release_firmware(fw);
- kfree(buffer);
dev_err(&intf->dev,
"unable to upload fpga firmware: fw urb.\n");
return ret;
}
}
- release_firmware(fw);
- kfree(buffer);
ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0);
if (ret) {
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 02/14] ALSA: hda: ca0132: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
2026-07-29 8:37 ` [PATCH 01/14] ALSA: 6fire: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 03/14] ALSA: hda: intel: " Takashi Iwai
` (11 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/hda/codecs/ca0132.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/sound/hda/codecs/ca0132.c b/sound/hda/codecs/ca0132.c
index 3fe11983d6ca..61c9fb42b1de 100644
--- a/sound/hda/codecs/ca0132.c
+++ b/sound/hda/codecs/ca0132.c
@@ -8530,10 +8530,9 @@ static void ca0132_set_dsp_msr(struct hda_codec *codec, bool is96k)
static bool ca0132_download_dsp_images(struct hda_codec *codec)
{
- bool dsp_loaded = false;
struct ca0132_spec *spec = codec->spec;
const struct dsp_image_seg *dsp_os_image;
- const struct firmware *fw_entry = NULL;
+ const struct firmware *fw_entry __free(firmware) = NULL;
/*
* Alternate firmwares for different variants. The Recon3Di apparently
* can use the default firmware, but I'll leave the option in case
@@ -8573,15 +8572,10 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec)
dsp_os_image = (struct dsp_image_seg *)(fw_entry->data);
if (dspload_image(codec, dsp_os_image, 0, 0, true, 0)) {
codec_err(codec, "ca0132 DSP load image failed\n");
- goto exit_download;
+ return false;
}
- dsp_loaded = dspload_wait_loaded(codec);
-
-exit_download:
- release_firmware(fw_entry);
-
- return dsp_loaded;
+ return dspload_wait_loaded(codec);
}
static void ca0132_download_dsp(struct hda_codec *codec)
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 03/14] ALSA: hda: intel: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
2026-07-29 8:37 ` [PATCH 01/14] ALSA: 6fire: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 02/14] ALSA: hda: ca0132: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 04/14] ALSA: msnd: " Takashi Iwai
` (10 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/hda/controllers/intel.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/hda/controllers/intel.c b/sound/hda/controllers/intel.c
index 192f5c044b7a..dbcdaf12a4bf 100644
--- a/sound/hda/controllers/intel.c
+++ b/sound/hda/controllers/intel.c
@@ -2387,7 +2387,7 @@ static int azx_probe_continue(struct azx *chip)
#ifdef CONFIG_SND_HDA_PATCH_LOADER
if (patch[dev] && *patch[dev]) {
- const struct firmware *fw = NULL;
+ const struct firmware *fw __free(firmware) = NULL;
dev_info(&pci->dev, "Applying patch firmware '%s'\n",
patch[dev]);
@@ -2396,7 +2396,6 @@ static int azx_probe_continue(struct azx *chip)
"Cannot load firmware, continue without patching\n");
} else {
err = snd_hda_load_patch(&chip->bus, fw->size, fw->data);
- release_firmware(fw);
if (err < 0)
goto out_free;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/14] ALSA: msnd: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (2 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 03/14] ALSA: hda: intel: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 05/14] ALSA: hda: cs35l41: " Takashi Iwai
` (9 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/isa/msnd/msnd_pinnacle.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
index 0d5f4461a7bc..eac6e22362cc 100644
--- a/sound/isa/msnd/msnd_pinnacle.c
+++ b/sound/isa/msnd/msnd_pinnacle.c
@@ -367,7 +367,8 @@ static int snd_msnd_init_sma(struct snd_msnd *chip)
static int upload_dsp_code(struct snd_card *card)
{
struct snd_msnd *chip = card->private_data;
- const struct firmware *init_fw = NULL, *perm_fw = NULL;
+ const struct firmware *init_fw __free(firmware) = NULL;
+ const struct firmware *perm_fw __free(firmware) = NULL;
int err;
outb(HPBLKSEL_0, chip->io + HP_BLKS);
@@ -375,28 +376,21 @@ static int upload_dsp_code(struct snd_card *card)
err = request_firmware(&init_fw, INITCODEFILE, card->dev);
if (err < 0) {
dev_err(card->dev, LOGNAME ": Error loading " INITCODEFILE);
- goto cleanup1;
+ return err;
}
err = request_firmware(&perm_fw, PERMCODEFILE, card->dev);
if (err < 0) {
dev_err(card->dev, LOGNAME ": Error loading " PERMCODEFILE);
- goto cleanup;
+ return err;
}
memcpy_toio(chip->mappedbase, perm_fw->data, perm_fw->size);
if (snd_msnd_upload_host(chip, init_fw->data, init_fw->size) < 0) {
dev_warn(card->dev, LOGNAME ": Error uploading to DSP\n");
- err = -ENODEV;
- goto cleanup;
+ return -ENODEV;
}
dev_info(card->dev, LOGNAME ": DSP firmware uploaded\n");
- err = 0;
-
-cleanup:
- release_firmware(perm_fw);
-cleanup1:
- release_firmware(init_fw);
- return err;
+ return 0;
}
#ifdef MSND_CLASSIC
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 05/14] ALSA: hda: cs35l41: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (3 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 04/14] ALSA: msnd: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 06/14] ALSA: hda: cs35l56: " Takashi Iwai
` (8 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound; +Cc: patches
Simplify the code to manage the firmware loading with auto-cleanup
with __free(firmware). A NULL clear is added at
cs35l41_request_firmware_file() for avoiding the double-free.
Note that the driver still keeps a few manual firmware releases
because it retries with different firmware files when one of firmware
pairs fails.
Only the code refactoring, no functional changes.
Cc: patches@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/hda/codecs/side-codecs/cs35l41_hda.c | 33 ++++++++--------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/sound/hda/codecs/side-codecs/cs35l41_hda.c b/sound/hda/codecs/side-codecs/cs35l41_hda.c
index 64a5bd895fd1..41a13456775d 100644
--- a/sound/hda/codecs/side-codecs/cs35l41_hda.c
+++ b/sound/hda/codecs/side-codecs/cs35l41_hda.c
@@ -170,6 +170,7 @@ static int cs35l41_request_firmware_file(struct cs35l41_hda *cs35l41,
char *s, c;
int ret = 0;
+ *firmware = NULL;
if (spkid > -1 && ssid && amp_name)
*filename = kasprintf(GFP_KERNEL, "cirrus/%s-%s-%s-%s-spkid%d-%s.%s", CS35L41_PART,
dsp_name, cs35l41_hda_fw_ids[cs35l41->firmware_type],
@@ -528,8 +529,8 @@ static int cs35l41_read_tuning_params(struct cs35l41_hda *cs35l41, const struct
static int cs35l41_load_tuning_params(struct cs35l41_hda *cs35l41, char *tuning_filename)
{
- const struct firmware *tuning_param_file = NULL;
- char *tuning_param_filename = NULL;
+ const struct firmware *tuning_param_file __free(firmware) = NULL;
+ char *tuning_param_filename __free(kfree) = NULL;
int ret;
ret = cs35l41_request_tuning_param_file(cs35l41, tuning_filename, &tuning_param_file,
@@ -548,19 +549,16 @@ static int cs35l41_load_tuning_params(struct cs35l41_hda *cs35l41, char *tuning_
cs35l41_set_default_tuning_params(cs35l41);
}
- release_firmware(tuning_param_file);
- kfree(tuning_param_filename);
-
return ret;
}
static int cs35l41_init_dsp(struct cs35l41_hda *cs35l41)
{
- const struct firmware *coeff_firmware = NULL;
- const struct firmware *wmfw_firmware = NULL;
+ const struct firmware *coeff_firmware __free(firmware) = NULL;
+ const struct firmware *wmfw_firmware __free(firmware) = NULL;
struct cs_dsp *dsp = &cs35l41->cs_dsp;
- char *coeff_filename = NULL;
- char *wmfw_filename = NULL;
+ char *coeff_filename __free(kfree) = NULL;
+ char *wmfw_filename __free(kfree) = NULL;
int ret;
if (!cs35l41->halo_initialized) {
@@ -592,20 +590,13 @@ static int cs35l41_init_dsp(struct cs35l41_hda *cs35l41)
ret = cs_dsp_power_up(dsp, wmfw_firmware, wmfw_filename, coeff_firmware, coeff_filename,
cs35l41_hda_fw_ids[cs35l41->firmware_type]);
- if (ret)
- goto err;
+ if (ret) {
+ cs35l41_set_default_tuning_params(cs35l41);
+ return ret;
+ }
cs35l41_hda_apply_calibration(cs35l41);
-
-err:
- if (ret)
- cs35l41_set_default_tuning_params(cs35l41);
- release_firmware(wmfw_firmware);
- release_firmware(coeff_firmware);
- kfree(wmfw_filename);
- kfree(coeff_filename);
-
- return ret;
+ return 0;
}
static void cs35l41_shutdown_dsp(struct cs35l41_hda *cs35l41)
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 06/14] ALSA: hda: cs35l56: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (4 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 05/14] ALSA: hda: cs35l41: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-30 9:35 ` Charles Keepax
2026-07-30 14:51 ` Richard Fitzgerald
2026-07-29 8:37 ` [PATCH 07/14] ALSA: sscape: " Takashi Iwai
` (7 subsequent siblings)
13 siblings, 2 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound; +Cc: patches
Simplify the code to manage the firmware loading with auto-cleanup.
By the use of __free(firmware), we can replace the manual mutex locks
with guard() gracefully, too.
Only the code refactoring, no functional changes.
Cc: patches@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/hda/codecs/side-codecs/cs35l56_hda.c | 35 ++++++----------------
1 file changed, 9 insertions(+), 26 deletions(-)
diff --git a/sound/hda/codecs/side-codecs/cs35l56_hda.c b/sound/hda/codecs/side-codecs/cs35l56_hda.c
index 78c2cf387a00..bc207ab5b020 100644
--- a/sound/hda/codecs/side-codecs/cs35l56_hda.c
+++ b/sound/hda/codecs/side-codecs/cs35l56_hda.c
@@ -527,18 +527,6 @@ static void cs35l56_hda_request_firmware_files(struct cs35l56_hda *cs35l56,
base_name, NULL, NULL, "bin");
}
-static void cs35l56_hda_release_firmware_files(const struct firmware *wmfw_firmware,
- char *wmfw_filename,
- const struct firmware *coeff_firmware,
- char *coeff_filename)
-{
- release_firmware(wmfw_firmware);
- kfree(wmfw_filename);
-
- release_firmware(coeff_firmware);
- kfree(coeff_filename);
-}
-
static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56)
{
int ret;
@@ -561,10 +549,10 @@ static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56)
static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
{
- const struct firmware *coeff_firmware = NULL;
- const struct firmware *wmfw_firmware = NULL;
- char *coeff_filename = NULL;
- char *wmfw_filename = NULL;
+ const struct firmware *coeff_firmware __free(firmware) = NULL;
+ const struct firmware *wmfw_firmware __free(firmware) = NULL;
+ char *coeff_filename __free(kfree) = NULL;
+ char *wmfw_filename __free(kfree) = NULL;
unsigned int preloaded_fw_ver;
bool firmware_missing;
int ret;
@@ -606,14 +594,14 @@ static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
if (firmware_missing) {
if (!wmfw_firmware) {
dev_err(cs35l56->base.dev, ".%s file required but not found\n", "wmfw");
- goto err_fw_release;
+ return;
} else if (!coeff_firmware) {
dev_err(cs35l56->base.dev, ".%s file required but not found\n", "bin");
- goto err_fw_release;
+ return;
}
}
- mutex_lock(&cs35l56->base.irq_lock);
+ guard(mutex)(&cs35l56->base.irq_lock);
/*
* If the firmware hasn't been patched it must be shutdown before
@@ -624,14 +612,14 @@ static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
if (firmware_missing && (wmfw_firmware || coeff_firmware)) {
ret = cs35l56_firmware_shutdown(&cs35l56->base);
if (ret)
- goto err;
+ return;
}
ret = cs_dsp_power_up(&cs35l56->cs_dsp, wmfw_firmware, wmfw_filename,
coeff_firmware, coeff_filename, "misc");
if (ret) {
dev_dbg(cs35l56->base.dev, "%s: cs_dsp_power_up ret %d\n", __func__, ret);
- goto err;
+ return;
}
if (wmfw_filename)
@@ -679,11 +667,6 @@ static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
err_powered_up:
if (!cs35l56->base.fw_patched)
cs_dsp_power_down(&cs35l56->cs_dsp);
-err:
- mutex_unlock(&cs35l56->base.irq_lock);
-err_fw_release:
- cs35l56_hda_release_firmware_files(wmfw_firmware, wmfw_filename,
- coeff_firmware, coeff_filename);
}
static void cs35l56_hda_dsp_work(struct work_struct *work)
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 07/14] ALSA: sscape: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (5 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 06/14] ALSA: hda: cs35l56: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 08/14] ALSA: wavefront: " Takashi Iwai
` (6 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/isa/sscape.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index ce8a59650e38..9b615b588cdf 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -526,7 +526,7 @@ static int upload_dma_data(struct soundscape *s, const unsigned char *data,
static int sscape_upload_bootblock(struct snd_card *card)
{
struct soundscape *sscape = get_card_soundscape(card);
- const struct firmware *init_fw = NULL;
+ const struct firmware *init_fw __free(firmware) = NULL;
int data = 0;
int ret;
@@ -537,8 +537,6 @@ static int sscape_upload_bootblock(struct snd_card *card)
}
ret = upload_dma_data(sscape, init_fw->data, init_fw->size);
- release_firmware(init_fw);
-
guard(spinlock_irqsave)(&sscape->lock);
if (ret == 0)
data = host_read_ctrl_unsafe(sscape->io_base, 100);
@@ -562,7 +560,7 @@ static int sscape_upload_bootblock(struct snd_card *card)
static int sscape_upload_microcode(struct snd_card *card, int version)
{
struct soundscape *sscape = get_card_soundscape(card);
- const struct firmware *init_fw = NULL;
+ const struct firmware *init_fw __free(firmware) = NULL;
char name[14];
int err;
@@ -579,8 +577,6 @@ static int sscape_upload_microcode(struct snd_card *card, int version)
dev_info(card->dev, "sscape: MIDI firmware loaded %zu KBs\n",
init_fw->size >> 10);
- release_firmware(init_fw);
-
return err;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 08/14] ALSA: wavefront: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (6 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 07/14] ALSA: sscape: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 09/14] ALSA: asihpi: " Takashi Iwai
` (5 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/isa/wavefront/wavefront_fx.c | 23 +++++++----------------
sound/isa/wavefront/wavefront_synth.c | 4 +---
2 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c
index beca35ce04f3..6d95ea338ea9 100644
--- a/sound/isa/wavefront/wavefront_fx.c
+++ b/sound/isa/wavefront/wavefront_fx.c
@@ -232,41 +232,32 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
{
unsigned int i;
int err;
- const struct firmware *firmware = NULL;
+ const struct firmware *firmware __free(firmware) = NULL;
if (dev->fx_initialized)
return 0;
err = request_firmware(&firmware, "yamaha/yss225_registers.bin",
dev->card->dev);
- if (err < 0) {
- err = -1;
- goto out;
- }
+ if (err < 0)
+ return -1;
for (i = 0; i + 1 < firmware->size; i += 2) {
if (firmware->data[i] >= 8 && firmware->data[i] < 16) {
outb(firmware->data[i + 1],
dev->base + firmware->data[i]);
} else if (firmware->data[i] == WAIT_IDLE) {
- if (!wavefront_fx_idle(dev)) {
- err = -1;
- goto out;
- }
+ if (!wavefront_fx_idle(dev))
+ return -1;
} else {
dev_err(dev->card->dev,
"invalid address in register data\n");
- err = -1;
- goto out;
+ return -1;
}
}
dev->fx_initialized = 1;
- err = 0;
-
-out:
- release_firmware(firmware);
- return err;
+ return 0;
}
MODULE_FIRMWARE("yamaha/yss225_registers.bin");
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index 2f57a6795d22..0c8f5cf26455 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -2053,7 +2053,7 @@ wavefront_download_firmware (snd_wavefront_t *dev, char *path)
const unsigned char *buf;
int len, err;
int section_cnt_downloaded = 0;
- const struct firmware *firmware;
+ const struct firmware *firmware __free(firmware) = NULL;
err = request_firmware(&firmware, path, dev->card->dev);
if (err < 0) {
@@ -2108,11 +2108,9 @@ wavefront_download_firmware (snd_wavefront_t *dev, char *path)
section_cnt_downloaded++;
}
- release_firmware(firmware);
return 0;
failure:
- release_firmware(firmware);
dev_err(dev->card->dev, "firmware download failed!!!\n");
return 1;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 09/14] ALSA: asihpi: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (7 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 08/14] ALSA: wavefront: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 10/14] ALSA: cs46xx: " Takashi Iwai
` (4 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/pci/asihpi/hpidspcd.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/sound/pci/asihpi/hpidspcd.c b/sound/pci/asihpi/hpidspcd.c
index b1b5a131f626..6d2c27e47d07 100644
--- a/sound/pci/asihpi/hpidspcd.c
+++ b/sound/pci/asihpi/hpidspcd.c
@@ -23,7 +23,7 @@ struct dsp_code_private {
short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
u32 *os_error_code)
{
- const struct firmware *firmware;
+ const struct firmware *firmware __free(firmware) = NULL;
struct pci_dev *dev = os_data;
struct code_header header;
char fw_name[20];
@@ -37,11 +37,11 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
if (err || !firmware) {
dev_err(&dev->dev, "%d, request_firmware failed for %s\n",
err, fw_name);
- goto error1;
+ goto error;
}
if (firmware->size < sizeof(header)) {
dev_err(&dev->dev, "Header size too small %s\n", fw_name);
- goto error2;
+ goto error;
}
memcpy(&header, firmware->data, sizeof(header));
@@ -51,7 +51,7 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
dev_err(&dev->dev,
"Invalid firmware header size %d != file %zd\n",
header.size, firmware->size);
- goto error2;
+ goto error;
}
if (HPI_VER_MAJOR(header.version) != HPI_VER_MAJOR(HPI_VER)) {
@@ -59,7 +59,7 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
dev_err(&dev->dev,
"Incompatible firmware version DSP image %X != Driver %X\n",
header.version, HPI_VER);
- goto error2;
+ goto error;
}
if (header.version != HPI_VER) {
@@ -72,19 +72,17 @@ short hpi_dsp_code_open(u32 adapter, void *os_data, struct dsp_code *dsp_code,
dsp_code->pvt = kmalloc_obj(*dsp_code->pvt);
if (!dsp_code->pvt) {
err_ret = HPI_ERROR_MEMORY_ALLOC;
- goto error2;
+ goto error;
}
dsp_code->pvt->dev = dev;
- dsp_code->pvt->firmware = firmware;
+ dsp_code->pvt->firmware = no_free_ptr(firmware);
dsp_code->header = header;
dsp_code->block_length = header.size / sizeof(u32);
dsp_code->word_count = sizeof(header) / sizeof(u32);
return 0;
-error2:
- release_firmware(firmware);
-error1:
+error:
dsp_code->block_length = 0;
return err_ret;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 10/14] ALSA: cs46xx: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (8 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 09/14] ALSA: asihpi: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 11/14] ALSA: korg1212: " Takashi Iwai
` (3 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/pci/cs46xx/cs46xx_lib.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 1c11023184ac..19a6927c079d 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -387,7 +387,7 @@ static int load_firmware(struct snd_cs46xx *chip,
unsigned int nums, fwlen, fwsize;
const __le32 *fwdat;
struct dsp_module_desc *module = NULL;
- const struct firmware *fw;
+ const struct firmware *fw __free(firmware) = NULL;
char fw_path[32];
sprintf(fw_path, "cs46xx/%s", fw_name);
@@ -395,10 +395,8 @@ static int load_firmware(struct snd_cs46xx *chip,
if (err < 0)
return err;
fwsize = fw->size / 4;
- if (fwsize < 2) {
- err = -EINVAL;
- goto error;
- }
+ if (fwsize < 2)
+ return -EINVAL;
err = -ENOMEM;
module = kzalloc_obj(*module);
@@ -454,14 +452,12 @@ static int load_firmware(struct snd_cs46xx *chip,
}
*module_ret = module;
- release_firmware(fw);
return 0;
error_inval:
err = -EINVAL;
error:
free_module_desc(module);
- release_firmware(fw);
return err;
}
@@ -500,22 +496,18 @@ MODULE_FIRMWARE("cs46xx/ba1");
static int load_firmware(struct snd_cs46xx *chip)
{
- const struct firmware *fw;
+ const struct firmware *fw __free(firmware) = NULL;
int i, size, err;
err = request_firmware(&fw, "cs46xx/ba1", &chip->pci->dev);
if (err < 0)
return err;
- if (fw->size != sizeof(*chip->ba1)) {
- err = -EINVAL;
- goto error;
- }
+ if (fw->size != sizeof(*chip->ba1))
+ return -EINVAL;
chip->ba1 = vmalloc(sizeof(*chip->ba1));
- if (!chip->ba1) {
- err = -ENOMEM;
- goto error;
- }
+ if (!chip->ba1)
+ return -ENOMEM;
memcpy_le32(chip->ba1, fw->data, sizeof(*chip->ba1));
@@ -524,11 +516,9 @@ static int load_firmware(struct snd_cs46xx *chip)
for (i = 0; i < BA1_MEMORY_COUNT; i++)
size += chip->ba1->memory[i].size;
if (size > BA1_DWORD_SIZE * 4)
- err = -EINVAL;
+ return -EINVAL;
- error:
- release_firmware(fw);
- return err;
+ return 0;
}
static __maybe_unused int snd_cs46xx_download_image(struct snd_cs46xx *chip)
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 11/14] ALSA: korg1212: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (9 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 10/14] ALSA: cs46xx: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 12/14] ALSA: mixart: " Takashi Iwai
` (2 subsequent siblings)
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/pci/korg1212/korg1212.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index d16acf83668a..f4d8402f835f 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -1980,7 +1980,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci)
__maybe_unused unsigned ioport_size;
__maybe_unused unsigned iomem2_size;
struct snd_korg1212 *korg1212 = card->private_data;
- const struct firmware *dsp_code;
+ const struct firmware *dsp_code __free(firmware) = NULL;
err = pcim_enable_device(pci);
if (err < 0)
@@ -2147,10 +2147,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci)
korg1212->dma_dsp = snd_devm_alloc_pages(&pci->dev, SNDRV_DMA_TYPE_DEV,
dsp_code->size);
- if (!korg1212->dma_dsp) {
- release_firmware(dsp_code);
+ if (!korg1212->dma_dsp)
return -ENOMEM;
- }
K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
korg1212->dma_dsp->area, korg1212->dma_dsp->addr, dsp_code->size,
@@ -2158,8 +2156,6 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci)
memcpy(korg1212->dma_dsp->area, dsp_code->data, dsp_code->size);
- release_firmware(dsp_code);
-
rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
if (rc)
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 12/14] ALSA: mixart: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (10 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 11/14] ALSA: korg1212: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 13/14] ALSA: pcxhr: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 14/14] ALSA: sh: " Takashi Iwai
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/pci/mixart/mixart_hwdep.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index 439e3ff05fe1..aa8d5bae30d0 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -560,12 +560,11 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
"miXart8.xlx", "miXart8.elf", "miXart8AES.xlx"
};
char path[32];
-
- const struct firmware *fw_entry;
int i, err;
for (i = 0; i < 3; i++) {
sprintf(path, "mixart/%s", fw_files[i]);
+ const struct firmware *fw_entry __free(firmware) = NULL;
if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
dev_err(&mgr->pci->dev,
"miXart: can't load firmware %s\n", path);
@@ -573,7 +572,6 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
}
/* fake hwdep dsp record */
err = mixart_dsp_load(mgr, i, fw_entry);
- release_firmware(fw_entry);
if (err < 0)
return err;
mgr->dsp_loaded |= 1 << i;
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 13/14] ALSA: pcxhr: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (11 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 12/14] ALSA: mixart: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
2026-07-29 8:37 ` [PATCH 14/14] ALSA: sh: " Takashi Iwai
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/pci/pcxhr/pcxhr_hwdep.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c
index 249805065f61..54f3950579aa 100644
--- a/sound/pci/pcxhr/pcxhr_hwdep.c
+++ b/sound/pci/pcxhr/pcxhr_hwdep.c
@@ -367,7 +367,6 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
};
char path[32];
- const struct firmware *fw_entry;
int i, err;
int fw_set = mgr->fw_file_set;
@@ -375,6 +374,7 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
if (!fw_files[fw_set][i])
continue;
sprintf(path, "pcxhr/%s", fw_files[fw_set][i]);
+ const struct firmware *fw_entry __free(firmware) = NULL;
if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
dev_err(&mgr->pci->dev,
"pcxhr: can't load firmware %s\n",
@@ -383,7 +383,6 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
}
/* fake hwdep dsp record */
err = pcxhr_dsp_load(mgr, i, fw_entry);
- release_firmware(fw_entry);
if (err < 0)
return err;
mgr->dsp_loaded |= 1 << i;
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 14/14] ALSA: sh: Use auto-cleanup for firmware loading
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
` (12 preceding siblings ...)
2026-07-29 8:37 ` [PATCH 13/14] ALSA: pcxhr: " Takashi Iwai
@ 2026-07-29 8:37 ` Takashi Iwai
13 siblings, 0 replies; 19+ messages in thread
From: Takashi Iwai @ 2026-07-29 8:37 UTC (permalink / raw)
To: linux-sound
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.
Only the code refactoring, no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/sh/aica.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 8196e1bf0416..078fc7fc08f9 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -518,8 +518,9 @@ static const struct snd_kcontrol_new snd_aica_pcmvolume_control = {
static int load_aica_firmware(void)
{
int err;
- const struct firmware *fw_entry;
spu_reset();
+
+ const struct firmware *fw_entry __free(firmware) = NULL;
err = request_firmware(&fw_entry, "aica_firmware.bin", &pd->dev);
if (unlikely(err))
return err;
@@ -527,7 +528,6 @@ static int load_aica_firmware(void)
spu_disable();
spu_memload(0, fw_entry->data, fw_entry->size);
spu_enable();
- release_firmware(fw_entry);
return err;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 06/14] ALSA: hda: cs35l56: Use auto-cleanup for firmware loading
2026-07-29 8:37 ` [PATCH 06/14] ALSA: hda: cs35l56: " Takashi Iwai
@ 2026-07-30 9:35 ` Charles Keepax
2026-07-30 9:45 ` Takashi Iwai
2026-07-30 14:51 ` Richard Fitzgerald
1 sibling, 1 reply; 19+ messages in thread
From: Charles Keepax @ 2026-07-30 9:35 UTC (permalink / raw)
To: Takashi Iwai; +Cc: linux-sound, patches
On Wed, Jul 29, 2026 at 10:37:24AM +0200, Takashi Iwai wrote:
> Simplify the code to manage the firmware loading with auto-cleanup.
> By the use of __free(firmware), we can replace the manual mutex locks
> with guard() gracefully, too.
>
> Only the code refactoring, no functional changes.
>
> Cc: patches@opensource.cirrus.com
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> sound/hda/codecs/side-codecs/cs35l56_hda.c | 35 ++++++----------------
> 1 file changed, 9 insertions(+), 26 deletions(-)
>
> diff --git a/sound/hda/codecs/side-codecs/cs35l56_hda.c b/sound/hda/codecs/side-codecs/cs35l56_hda.c
> index 78c2cf387a00..bc207ab5b020 100644
> --- a/sound/hda/codecs/side-codecs/cs35l56_hda.c
> +++ b/sound/hda/codecs/side-codecs/cs35l56_hda.c
> @@ -527,18 +527,6 @@ static void cs35l56_hda_request_firmware_files(struct cs35l56_hda *cs35l56,
> base_name, NULL, NULL, "bin");
> }
>
> -static void cs35l56_hda_release_firmware_files(const struct firmware *wmfw_firmware,
> - char *wmfw_filename,
> - const struct firmware *coeff_firmware,
> - char *coeff_filename)
> -{
> - release_firmware(wmfw_firmware);
> - kfree(wmfw_filename);
> -
> - release_firmware(coeff_firmware);
> - kfree(coeff_filename);
> -}
> -
> static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56)
> {
> int ret;
> @@ -561,10 +549,10 @@ static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56)
>
> static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
> {
> - const struct firmware *coeff_firmware = NULL;
> - const struct firmware *wmfw_firmware = NULL;
> - char *coeff_filename = NULL;
> - char *wmfw_filename = NULL;
> + const struct firmware *coeff_firmware __free(firmware) = NULL;
> + const struct firmware *wmfw_firmware __free(firmware) = NULL;
Is it definitely safe to replace release_firmware with kfree? In
most cases that is all release_firmware does, but it looks like
it does different stuff if someone built the firmware into the
kernel?
Thanks,
Charles
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 06/14] ALSA: hda: cs35l56: Use auto-cleanup for firmware loading
2026-07-30 9:35 ` Charles Keepax
@ 2026-07-30 9:45 ` Takashi Iwai
2026-07-30 10:21 ` Charles Keepax
0 siblings, 1 reply; 19+ messages in thread
From: Takashi Iwai @ 2026-07-30 9:45 UTC (permalink / raw)
To: Charles Keepax; +Cc: Takashi Iwai, linux-sound, patches
On Thu, 30 Jul 2026 11:35:56 +0200,
Charles Keepax wrote:
>
> On Wed, Jul 29, 2026 at 10:37:24AM +0200, Takashi Iwai wrote:
> > Simplify the code to manage the firmware loading with auto-cleanup.
> > By the use of __free(firmware), we can replace the manual mutex locks
> > with guard() gracefully, too.
> >
> > Only the code refactoring, no functional changes.
> >
> > Cc: patches@opensource.cirrus.com
> > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> > ---
> > sound/hda/codecs/side-codecs/cs35l56_hda.c | 35 ++++++----------------
> > 1 file changed, 9 insertions(+), 26 deletions(-)
> >
> > diff --git a/sound/hda/codecs/side-codecs/cs35l56_hda.c b/sound/hda/codecs/side-codecs/cs35l56_hda.c
> > index 78c2cf387a00..bc207ab5b020 100644
> > --- a/sound/hda/codecs/side-codecs/cs35l56_hda.c
> > +++ b/sound/hda/codecs/side-codecs/cs35l56_hda.c
> > @@ -527,18 +527,6 @@ static void cs35l56_hda_request_firmware_files(struct cs35l56_hda *cs35l56,
> > base_name, NULL, NULL, "bin");
> > }
> >
> > -static void cs35l56_hda_release_firmware_files(const struct firmware *wmfw_firmware,
> > - char *wmfw_filename,
> > - const struct firmware *coeff_firmware,
> > - char *coeff_filename)
> > -{
> > - release_firmware(wmfw_firmware);
> > - kfree(wmfw_filename);
> > -
> > - release_firmware(coeff_firmware);
> > - kfree(coeff_filename);
> > -}
> > -
> > static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56)
> > {
> > int ret;
> > @@ -561,10 +549,10 @@ static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56)
> >
> > static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
> > {
> > - const struct firmware *coeff_firmware = NULL;
> > - const struct firmware *wmfw_firmware = NULL;
> > - char *coeff_filename = NULL;
> > - char *wmfw_filename = NULL;
> > + const struct firmware *coeff_firmware __free(firmware) = NULL;
> > + const struct firmware *wmfw_firmware __free(firmware) = NULL;
>
> Is it definitely safe to replace release_firmware with kfree? In
> most cases that is all release_firmware does, but it looks like
> it does different stuff if someone built the firmware into the
> kernel?
It's __free(firmware), not __free(kfree) :)
Takashi
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 06/14] ALSA: hda: cs35l56: Use auto-cleanup for firmware loading
2026-07-30 9:45 ` Takashi Iwai
@ 2026-07-30 10:21 ` Charles Keepax
0 siblings, 0 replies; 19+ messages in thread
From: Charles Keepax @ 2026-07-30 10:21 UTC (permalink / raw)
To: Takashi Iwai; +Cc: linux-sound, patches
On Thu, Jul 30, 2026 at 11:45:49AM +0200, Takashi Iwai wrote:
> On Thu, 30 Jul 2026 11:35:56 +0200,
> Charles Keepax wrote:
> >
> > On Wed, Jul 29, 2026 at 10:37:24AM +0200, Takashi Iwai wrote:
> > > Simplify the code to manage the firmware loading with auto-cleanup.
> > > By the use of __free(firmware), we can replace the manual mutex locks
> > > with guard() gracefully, too.
> > >
> > > Only the code refactoring, no functional changes.
> > >
> > > Cc: patches@opensource.cirrus.com
> > > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> > > ---
> > > sound/hda/codecs/side-codecs/cs35l56_hda.c | 35 ++++++----------------
> > > 1 file changed, 9 insertions(+), 26 deletions(-)
> > >
> > > diff --git a/sound/hda/codecs/side-codecs/cs35l56_hda.c b/sound/hda/codecs/side-codecs/cs35l56_hda.c
> > > index 78c2cf387a00..bc207ab5b020 100644
> > > --- a/sound/hda/codecs/side-codecs/cs35l56_hda.c
> > > +++ b/sound/hda/codecs/side-codecs/cs35l56_hda.c
> > > @@ -527,18 +527,6 @@ static void cs35l56_hda_request_firmware_files(struct cs35l56_hda *cs35l56,
> > > base_name, NULL, NULL, "bin");
> > > }
> > >
> > > -static void cs35l56_hda_release_firmware_files(const struct firmware *wmfw_firmware,
> > > - char *wmfw_filename,
> > > - const struct firmware *coeff_firmware,
> > > - char *coeff_filename)
> > > -{
> > > - release_firmware(wmfw_firmware);
> > > - kfree(wmfw_filename);
> > > -
> > > - release_firmware(coeff_firmware);
> > > - kfree(coeff_filename);
> > > -}
> > > -
> > > static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56)
> > > {
> > > int ret;
> > > @@ -561,10 +549,10 @@ static int cs35l56_hda_apply_calibration(struct cs35l56_hda *cs35l56)
> > >
> > > static void cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
> > > {
> > > - const struct firmware *coeff_firmware = NULL;
> > > - const struct firmware *wmfw_firmware = NULL;
> > > - char *coeff_filename = NULL;
> > > - char *wmfw_filename = NULL;
> > > + const struct firmware *coeff_firmware __free(firmware) = NULL;
> > > + const struct firmware *wmfw_firmware __free(firmware) = NULL;
> >
> > Is it definitely safe to replace release_firmware with kfree? In
> > most cases that is all release_firmware does, but it looks like
> > it does different stuff if someone built the firmware into the
> > kernel?
>
> It's __free(firmware), not __free(kfree) :)
Oops... sorry my bad, must be too early in the morning for me :-)
Thanks,
Charles
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 06/14] ALSA: hda: cs35l56: Use auto-cleanup for firmware loading
2026-07-29 8:37 ` [PATCH 06/14] ALSA: hda: cs35l56: " Takashi Iwai
2026-07-30 9:35 ` Charles Keepax
@ 2026-07-30 14:51 ` Richard Fitzgerald
1 sibling, 0 replies; 19+ messages in thread
From: Richard Fitzgerald @ 2026-07-30 14:51 UTC (permalink / raw)
To: Takashi Iwai, linux-sound; +Cc: patches
On 29/7/26 09:37, Takashi Iwai wrote:
> Simplify the code to manage the firmware loading with auto-cleanup.
> By the use of __free(firmware), we can replace the manual mutex locks
> with guard() gracefully, too.
>
> Only the code refactoring, no functional changes.
>
> Cc: patches@opensource.cirrus.com
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> sound/hda/codecs/side-codecs/cs35l56_hda.c | 35 ++++++----------------
> 1 file changed, 9 insertions(+), 26 deletions(-)
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-07-30 14:52 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 8:37 [PATCH 00/14] ALSA: Use auto-cleanup for firmware loading Takashi Iwai
2026-07-29 8:37 ` [PATCH 01/14] ALSA: 6fire: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 02/14] ALSA: hda: ca0132: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 03/14] ALSA: hda: intel: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 04/14] ALSA: msnd: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 05/14] ALSA: hda: cs35l41: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 06/14] ALSA: hda: cs35l56: " Takashi Iwai
2026-07-30 9:35 ` Charles Keepax
2026-07-30 9:45 ` Takashi Iwai
2026-07-30 10:21 ` Charles Keepax
2026-07-30 14:51 ` Richard Fitzgerald
2026-07-29 8:37 ` [PATCH 07/14] ALSA: sscape: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 08/14] ALSA: wavefront: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 09/14] ALSA: asihpi: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 10/14] ALSA: cs46xx: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 11/14] ALSA: korg1212: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 12/14] ALSA: mixart: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 13/14] ALSA: pcxhr: " Takashi Iwai
2026-07-29 8:37 ` [PATCH 14/14] ALSA: sh: " Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox