]> git.hungrycats.org Git - linux/commitdiff
ASoC: tas5805m: Use auto-cleanup for firmware loading
authorTakashi Iwai <tiwai@suse.de>
Thu, 6 Aug 2026 13:59:52 +0000 (15:59 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 10 Aug 2026 14:34:02 +0000 (15:34 +0100)
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>
Link: https://patch.msgid.link/20260806140006.1412298-21-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/tas5805m.c

index f76e04b403b5e7697095a8e50c37e380474def0f..d32796a6fa7528f964ead31f5b1c0e90a1e67862 100644 (file)
@@ -457,7 +457,6 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c)
        struct tas5805m_priv *tas5805m;
        char filename[128];
        const char *config_name;
-       const struct firmware *fw;
        int ret;
 
        regmap = devm_regmap_init_i2c(i2c, &tas5805m_regmap);
@@ -502,24 +501,20 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c)
 
        snprintf(filename, sizeof(filename), "tas5805m_dsp_%s.bin",
                 config_name);
+       const struct firmware *fw __free(firmware) = NULL;
        ret = request_firmware(&fw, filename, dev);
        if (ret)
                return ret;
 
        if ((fw->size < 2) || (fw->size & 1)) {
                dev_err(dev, "firmware is invalid\n");
-               release_firmware(fw);
                return -EINVAL;
        }
 
        tas5805m->dsp_cfg_len = fw->size;
        tas5805m->dsp_cfg_data = devm_kmemdup(dev, fw->data, fw->size, GFP_KERNEL);
-       if (!tas5805m->dsp_cfg_data) {
-               release_firmware(fw);
+       if (!tas5805m->dsp_cfg_data)
                return -ENOMEM;
-       }
-
-       release_firmware(fw);
 
        /* Do the first part of the power-on here, while we can expect
         * the I2S interface to be quiet. We must raise PDN# and then