[PATCH 27/31] ASoC: Intel: catpt: Use auto-cleanup for firmware loading
Takashi Iwai <[email protected]> Wed, 5 Aug 2026 15:52:28 +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: Cezary Rojewski <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- sound/soc/intel/catpt/loader.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c index e7ba9e1e60ae..724cbe337db4 100644 --- a/sound/soc/intel/catpt/loader.c +++ b/sound/soc/intel/catpt/loader.c @@ -568,27 +568,24 @@ static int catpt_request_load_firmware(struct catpt_dev *cdev, struct dma_chan * const char *name, bool restore) { struct catpt_fw_hdr *fw; - struct firmware *img; dma_addr_t paddr; void *vaddr; int ret; - ret = request_firmware((const struct firmware **)&img, name, cdev->dev); + const struct firmware *img __free(firmware) = NULL; + ret = request_firmware(&img, name, cdev->dev); if (ret) return ret; fw = (struct catpt_fw_hdr *)img->data; if (strncmp(fw->signature, FW_SIGNATURE, FW_SIGNATURE_SIZE)) { dev_err(cdev->dev, "firmware signature mismatch\n"); - ret = -EINVAL; - goto release_fw; + return -EINVAL; } vaddr = dma_alloc_coherent(cdev->dev, img->size, &paddr, GFP_KERNEL); - if (!vaddr) { - ret = -ENOMEM; - goto release_fw; - } + if (!vaddr) + return -ENOMEM; memcpy(vaddr, img->data, img->size); fw = (struct catpt_fw_hdr *)vaddr; @@ -598,8 +595,6 @@ static int catpt_request_load_firmware(struct catpt_dev *cdev, struct dma_chan * ret = catpt_load_firmware(cdev, chan, paddr, fw); dma_free_coherent(cdev->dev, img->size, vaddr, paddr); -release_fw: - release_firmware(img); return ret; } -- 2.55.0