]> git.hungrycats.org Git - linux/commitdiff
ASoC: rt722-sdca: Use auto-cleanup for firmware loading
authorTakashi Iwai <tiwai@suse.de>
Thu, 6 Aug 2026 13:59:48 +0000 (15:59 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 10 Aug 2026 14:33:57 +0000 (15:33 +0100)
Simplify the code to manage the firmware loading with __free(firmware)
auto-cleanup, as well as the firmware file name being released with
__free(kfree).

Only the code refactoring, no functional changes.

Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260806140006.1412298-17-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt722-sdca.c

index 27bb0eb1ece789aace24aa29d001230f13263c10..4cbe9e9095856f95b5f7cba9d98e7bddde77e48f 100644 (file)
@@ -352,8 +352,6 @@ static int rt722_cae_load(struct rt722_sdca_priv *rt722)
        static const char func_tag[] = "FUNC";
        static const char xu_tag[] = "XU";
        const char *dmi_vendor, *dmi_product, *dmi_sku;
-       char *cae_filename;
-       const struct firmware *cae_fw = NULL;
        unsigned int cae_st_spk, cae_st_hp, cae_st_mic;
        unsigned int func, value;
        unsigned int combined_val;
@@ -385,7 +383,8 @@ static int rt722_cae_load(struct rt722_sdca_priv *rt722)
        space = strchr(dmi_sku, ' ');
        s_len = space ? space - dmi_sku : strlen(dmi_sku);
 
-       cae_filename = kasprintf(GFP_KERNEL,
+       char *cae_filename __free(kfree) =
+               kasprintf(GFP_KERNEL,
                                 "realtek/rt722/rt722_RAE_%.*s_%.*s_%.*s.dat",
                                 v_len, dmi_vendor,
                                 p_len, dmi_product,
@@ -399,8 +398,8 @@ static int rt722_cae_load(struct rt722_sdca_priv *rt722)
        regmap_write(rt722->regmap, RT722_MIC_CAE_PARAM39, 0x5f);
        usleep_range(50000, 60000);
 
+       const struct firmware *cae_fw __free(firmware) = NULL;
        request_firmware(&cae_fw, cae_filename, dev);
-       kfree(cae_filename);
        if (!cae_fw) {
                dev_err(dev, "%s: Failed to load CAE firmware\n", __func__);
                return -ENOENT;
@@ -555,7 +554,6 @@ static int rt722_cae_load(struct rt722_sdca_priv *rt722)
        regcache_cache_bypass(rt722->regmap, false);
        rt722->cae_update_done = 1;
        dev_dbg(dev, "%s: CAE FW update done.\n", __func__);
-       release_firmware(cae_fw);
        return 0;
 
 verify_abort:
@@ -565,7 +563,6 @@ verify_abort:
 out_release:
        rt722_sdca_index_update_bits(rt722, RT722_VENDOR_REG,
                        RT722_MISC_CTRL1, 0x8000, 0x0000);
-       release_firmware(cae_fw);
        dev_err(dev, "%s: CAE FW update aborted (ret=%d).\n", __func__, ret);
        return ret;
 }