[PATCH 30/31] ASoC: SDCA: Use auto-cleanup for firmware loading

Takashi Iwai <[email protected]> Wed, 5 Aug 2026 15:52:31 +0200
Newsgroups org.kernel.vger.linux-sound
Message-ID <[email protected]>
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup.

Only the code refactoring, no functional changes.

Cc: Charles Keepax <[email protected]>
Cc: Maciej Strozek <[email protected]>
Cc: Bard Liao <[email protected]>
Cc: Pierre-Louis Bossart <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
---
 sound/soc/sdca/sdca_fdl.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sound/soc/sdca/sdca_fdl.c b/sound/soc/sdca/sdca_fdl.c
index dbe572336f8c..150e36ed24bc 100644
--- a/sound/soc/sdca/sdca_fdl.c
+++ b/sound/soc/sdca/sdca_fdl.c
@@ -195,7 +195,6 @@ static int fdl_load_file(struct sdca_interrupt *interrupt,
 {
 	struct device *dev = interrupt->dev;
 	struct sdca_fdl_data *fdl_data = &interrupt->function->fdl_data;
-	const struct firmware *firmware = NULL;
 	struct acpi_sw_file *swf = NULL, *tmp;
 	struct sdca_fdl_file *fdl_file;
 	char *disk_filename;
@@ -230,6 +229,7 @@ static int fdl_load_file(struct sdca_interrupt *interrupt,
 
 	dev_dbg(dev, "FDL disk filename: %s\n", disk_filename);
 
+	const struct firmware *firmware __free(firmware) = NULL;
 	ret = firmware_request_nowarn(&firmware, disk_filename, dev);
 	kfree(disk_filename);
 	if (ret) {
@@ -258,8 +258,7 @@ static int fdl_load_file(struct sdca_interrupt *interrupt,
 
 	if (!swf) {
 		dev_err(dev, "failed to locate SWF\n");
-		ret = -ENOENT;
-		goto error;
+		return -ENOENT;
 	}
 
 	dev_info(dev, "loading SWF: %x-%x-%x\n",
@@ -271,9 +270,6 @@ static int fdl_load_file(struct sdca_interrupt *interrupt,
 				     SDCA_CTL_XU_FDL_MESSAGEOFFSET, fdl_file->fdl_offset,
 				     SDCA_CTL_XU_FDL_MESSAGELENGTH, swf->data,
 				     swf->file_length - offsetof(struct acpi_sw_file, data));
-
-error:
-	release_firmware(firmware);
 	return ret;
 }
 
-- 
2.55.0