From abc7daad426ef93665ef6fbc1b3cd05a814e721e Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 29 Jul 2026 13:00:50 +0200 Subject: [PATCH 1/8] ASoC: Intel: catpt: Wrap the store firmware-context procedure All store/restore firmware operations are located in the loader.c file. All except the "store firmware context" procedure which is manually called during the runtime suspend, device.c file. Adding a wrapper alters functional flow slightly - DMA channel is requested after the DXSTATE IPC rather than before it but this has no real impact on the procedure. At the same time, such approach limits number of symbols exposed in the core.h file and improves code cohesiveness: all catpt_dma_xxx() definitions in dsp.c, all their usages in loader.c. Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20260729110057.342447-2-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/catpt/core.h | 4 +--- sound/soc/intel/catpt/device.c | 33 +++------------------------- sound/soc/intel/catpt/loader.c | 39 +++++++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/sound/soc/intel/catpt/core.h b/sound/soc/intel/catpt/core.h index 3881164422b8..f68807c454c9 100644 --- a/sound/soc/intel/catpt/core.h +++ b/sound/soc/intel/catpt/core.h @@ -139,9 +139,7 @@ int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request, int catpt_first_boot_firmware(struct catpt_dev *cdev); int catpt_boot_firmware(struct catpt_dev *cdev, bool restore); -int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan); -int catpt_store_module_states(struct catpt_dev *cdev, struct dma_chan *chan); -int catpt_store_memdumps(struct catpt_dev *cdev, struct dma_chan *chan); +int catpt_store_firmware_context(struct catpt_dev *cdev); int catpt_coredump(struct catpt_dev *cdev); #include diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c index b176aebea9d5..e36eea8b5408 100644 --- a/sound/soc/intel/catpt/device.c +++ b/sound/soc/intel/catpt/device.c @@ -28,44 +28,17 @@ static int catpt_do_suspend(struct device *dev) { struct catpt_dev *cdev = dev_get_drvdata(dev); - struct dma_chan *chan; int ret; - chan = catpt_dma_request_config_chan(cdev); - if (IS_ERR(chan)) - return PTR_ERR(chan); - memset(&cdev->dx_ctx, 0, sizeof(cdev->dx_ctx)); ret = catpt_ipc_enter_dxstate(cdev, CATPT_DX_STATE_D3, &cdev->dx_ctx); - if (ret) { - ret = CATPT_IPC_RET(ret); - goto release_dma_chan; - } - - ret = catpt_dsp_stall(cdev, true); if (ret) - goto release_dma_chan; + return CATPT_IPC_RET(ret); - ret = catpt_store_memdumps(cdev, chan); - if (ret) { - dev_err(cdev->dev, "store memdumps failed: %d\n", ret); - goto release_dma_chan; - } - - ret = catpt_store_module_states(cdev, chan); - if (ret) { - dev_err(cdev->dev, "store module states failed: %d\n", ret); - goto release_dma_chan; - } - - ret = catpt_store_streams_context(cdev, chan); - if (ret) - dev_err(cdev->dev, "store streams ctx failed: %d\n", ret); - -release_dma_chan: - dma_release_channel(chan); + ret = catpt_store_firmware_context(cdev); if (ret) return ret; + return catpt_dsp_power_down(cdev); } diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c index c577f2e17ddf..880f62896997 100644 --- a/sound/soc/intel/catpt/loader.c +++ b/sound/soc/intel/catpt/loader.c @@ -81,7 +81,7 @@ catpt_request_region(struct resource *root, resource_size_t size) return __request_region(root, addr, size, NULL, 0); } -int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan) +static int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan) { struct catpt_stream_runtime *stream; @@ -108,7 +108,7 @@ int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan) return 0; } -int catpt_store_module_states(struct catpt_dev *cdev, struct dma_chan *chan) +static int catpt_store_module_states(struct catpt_dev *cdev, struct dma_chan *chan) { int i; @@ -138,7 +138,7 @@ int catpt_store_module_states(struct catpt_dev *cdev, struct dma_chan *chan) return 0; } -int catpt_store_memdumps(struct catpt_dev *cdev, struct dma_chan *chan) +static int catpt_store_memdumps(struct catpt_dev *cdev, struct dma_chan *chan) { int i; @@ -171,6 +171,39 @@ int catpt_store_memdumps(struct catpt_dev *cdev, struct dma_chan *chan) return 0; } +int catpt_store_firmware_context(struct catpt_dev *cdev) +{ + struct dma_chan *chan; + int ret; + + chan = catpt_dma_request_config_chan(cdev); + if (IS_ERR(chan)) + return PTR_ERR(chan); + + ret = catpt_dsp_stall(cdev, true); + if (ret) + goto exit; + + ret = catpt_store_memdumps(cdev, chan); + if (ret) { + dev_err(cdev->dev, "store memdumps failed: %d\n", ret); + goto exit; + } + + ret = catpt_store_module_states(cdev, chan); + if (ret) { + dev_err(cdev->dev, "store module states failed: %d\n", ret); + goto exit; + } + + ret = catpt_store_streams_context(cdev, chan); + if (ret) + dev_err(cdev->dev, "store streams ctx failed: %d\n", ret); +exit: + dma_release_channel(chan); + return ret; +} + static int catpt_restore_streams_context(struct catpt_dev *cdev, struct dma_chan *chan) { From 05d3ba6258026e2c8c9feefefd63ebc82319a301 Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 29 Jul 2026 13:00:51 +0200 Subject: [PATCH 2/8] ASoC: Intel: catpt: Drop redundant else-if If the preceding if-statement ends with return, there is no need for else-if. Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20260729110057.342447-3-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/catpt/loader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c index 880f62896997..79742dceef53 100644 --- a/sound/soc/intel/catpt/loader.c +++ b/sound/soc/intel/catpt/loader.c @@ -652,10 +652,10 @@ int catpt_boot_firmware(struct catpt_dev *cdev, bool restore) if (!ret) { dev_err(cdev->dev, "firmware ready timeout\n"); return -ETIMEDOUT; - /* Wake up does not mean FW is ready, an exception could occur. */ - } else if (!cdev->ipc.ready) { - return -EREMOTEIO; } + /* Wake up does not mean FW is ready, an exception could occur. */ + if (!cdev->ipc.ready) + return -EREMOTEIO; /* update sram pg & clock once done booting */ catpt_dsp_update_srampge(cdev, &cdev->dram, cdev->spec->dram_mask); From f6c65bf0acc99079e5a9b43d4079ee2a8fe68332 Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 29 Jul 2026 13:00:52 +0200 Subject: [PATCH 3/8] ASoC: Intel: catpt: Drop redundant signature argument Initial design assumed the mechanism could be reused for loading external modules with signatures differing from the Intel's constant. No users with such characteristics ever appeared rendering the 'signature' argument useless. Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20260729110057.342447-4-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/catpt/loader.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c index 79742dceef53..775781489ded 100644 --- a/sound/soc/intel/catpt/loader.c +++ b/sound/soc/intel/catpt/loader.c @@ -569,8 +569,7 @@ static int catpt_load_firmware(struct catpt_dev *cdev, } static int catpt_load_image(struct catpt_dev *cdev, struct dma_chan *chan, - const char *name, const char *signature, - bool restore) + const char *name, bool restore) { struct catpt_fw_hdr *fw; struct firmware *img; @@ -583,7 +582,7 @@ static int catpt_load_image(struct catpt_dev *cdev, struct dma_chan *chan, return ret; fw = (struct catpt_fw_hdr *)img->data; - if (strncmp(fw->signature, signature, FW_SIGNATURE_SIZE)) { + if (strncmp(fw->signature, FW_SIGNATURE, FW_SIGNATURE_SIZE)) { dev_err(cdev->dev, "firmware signature mismatch\n"); ret = -EINVAL; goto release_fw; @@ -617,8 +616,7 @@ static int catpt_load_images(struct catpt_dev *cdev, bool restore) if (IS_ERR(chan)) return PTR_ERR(chan); - ret = catpt_load_image(cdev, chan, cdev->spec->fw_name, - FW_SIGNATURE, restore); + ret = catpt_load_image(cdev, chan, cdev->spec->fw_name, restore); if (ret) goto release_dma_chan; From 71d1229972e2fc298dff3b40e0b81a11544a8caf Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 29 Jul 2026 13:00:53 +0200 Subject: [PATCH 4/8] ASoC: Intel: catpt: Rename module header struct Goal is to match the name of its equivalent on the firmware side. Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20260729110057.342447-5-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/catpt/loader.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c index 775781489ded..06c8b043e292 100644 --- a/sound/soc/intel/catpt/loader.c +++ b/sound/soc/intel/catpt/loader.c @@ -26,7 +26,7 @@ struct catpt_fw_hdr { u32 reserved[4]; } __packed; -struct catpt_fw_mod_hdr { +struct catpt_fw_module_hdr { char signature[FW_SIGNATURE_SIZE]; u32 mod_size; u32 blocks; @@ -357,7 +357,7 @@ static int catpt_load_block(struct catpt_dev *cdev, static int catpt_restore_basefw(struct catpt_dev *cdev, struct dma_chan *chan, dma_addr_t paddr, - struct catpt_fw_mod_hdr *basefw) + struct catpt_fw_module_hdr *basefw) { u32 offset = sizeof(*basefw); int ret, i; @@ -400,7 +400,7 @@ static int catpt_restore_basefw(struct catpt_dev *cdev, static int catpt_restore_module(struct catpt_dev *cdev, struct dma_chan *chan, dma_addr_t paddr, - struct catpt_fw_mod_hdr *mod) + struct catpt_fw_module_hdr *mod) { u32 offset = sizeof(*mod); int i; @@ -441,7 +441,7 @@ static int catpt_restore_module(struct catpt_dev *cdev, static int catpt_load_module(struct catpt_dev *cdev, struct dma_chan *chan, dma_addr_t paddr, - struct catpt_fw_mod_hdr *mod) + struct catpt_fw_module_hdr *mod) { struct catpt_module_type *type; u32 offset = sizeof(*mod); @@ -497,10 +497,10 @@ static int catpt_restore_firmware(struct catpt_dev *cdev, fw, sizeof(*fw), false); for (i = 0; i < fw->modules; i++) { - struct catpt_fw_mod_hdr *mod; + struct catpt_fw_module_hdr *mod; int ret; - mod = (struct catpt_fw_mod_hdr *)((u8 *)fw + offset); + mod = (struct catpt_fw_module_hdr *)((u8 *)fw + offset); if (strncmp(fw->signature, mod->signature, FW_SIGNATURE_SIZE)) { dev_err(cdev->dev, "module signature mismatch\n"); @@ -543,10 +543,10 @@ static int catpt_load_firmware(struct catpt_dev *cdev, fw, sizeof(*fw), false); for (i = 0; i < fw->modules; i++) { - struct catpt_fw_mod_hdr *mod; + struct catpt_fw_module_hdr *mod; int ret; - mod = (struct catpt_fw_mod_hdr *)((u8 *)fw + offset); + mod = (struct catpt_fw_module_hdr *)((u8 *)fw + offset); if (strncmp(fw->signature, mod->signature, FW_SIGNATURE_SIZE)) { dev_err(cdev->dev, "module signature mismatch\n"); From e692a538a421602743df8d479631b55ea7d8cea4 Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 29 Jul 2026 13:00:54 +0200 Subject: [PATCH 5/8] ASoC: Intel: catpt: Rename firmware loading functions To make the firmware loading proceduce easier to understand, especially around restoring DRAM context, rename the following: catpt_load_images -> catpt_request_dma_load_firmware catpt_load_image -> catpt_request_load_firmware catpt_restore_fwimage -> catpt_restore_dram_rodata catpt_restore_memdumps -> catpt_restore_dram_data catpt_store_memdumps -> catpt_store_dram_data For the exact same reason, update a number of comments related to the subject. Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20260729110057.342447-6-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/catpt/loader.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c index 06c8b043e292..274af8fb8828 100644 --- a/sound/soc/intel/catpt/loader.c +++ b/sound/soc/intel/catpt/loader.c @@ -138,7 +138,7 @@ static int catpt_store_module_states(struct catpt_dev *cdev, struct dma_chan *ch return 0; } -static int catpt_store_memdumps(struct catpt_dev *cdev, struct dma_chan *chan) +static int catpt_store_dram_data(struct catpt_dev *cdev, struct dma_chan *chan) { int i; @@ -184,7 +184,7 @@ int catpt_store_firmware_context(struct catpt_dev *cdev) if (ret) goto exit; - ret = catpt_store_memdumps(cdev, chan); + ret = catpt_store_dram_data(cdev, chan); if (ret) { dev_err(cdev->dev, "store memdumps failed: %d\n", ret); goto exit; @@ -232,7 +232,7 @@ catpt_restore_streams_context(struct catpt_dev *cdev, struct dma_chan *chan) return 0; } -static int catpt_restore_memdumps(struct catpt_dev *cdev, struct dma_chan *chan) +static int catpt_restore_dram_data(struct catpt_dev *cdev, struct dma_chan *chan) { int i; @@ -267,9 +267,9 @@ static int catpt_restore_memdumps(struct catpt_dev *cdev, struct dma_chan *chan) return 0; } -static int catpt_restore_fwimage(struct catpt_dev *cdev, - struct dma_chan *chan, dma_addr_t paddr, - struct catpt_fw_block_hdr *blk) +static int catpt_restore_dram_rodata(struct catpt_dev *cdev, + struct dma_chan *chan, dma_addr_t paddr, + struct catpt_fw_block_hdr *blk) { struct resource r1 = {}; int i; @@ -365,7 +365,7 @@ static int catpt_restore_basefw(struct catpt_dev *cdev, print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4, basefw, sizeof(*basefw), false); - /* restore basefw image */ + /* Restore IRAM and .rodata for DRAM based on the firmware image. */ for (i = 0; i < basefw->blocks; i++) { struct catpt_fw_block_hdr *blk; @@ -377,8 +377,8 @@ static int catpt_restore_basefw(struct catpt_dev *cdev, blk, false); break; default: - ret = catpt_restore_fwimage(cdev, chan, paddr + offset, - blk); + ret = catpt_restore_dram_rodata(cdev, chan, paddr + offset, + blk); break; } @@ -390,8 +390,8 @@ static int catpt_restore_basefw(struct catpt_dev *cdev, offset += sizeof(*blk) + blk->size; } - /* then proceed with memory dumps */ - ret = catpt_restore_memdumps(cdev, chan); + /* Then proceed with DRAM .data saved before D3. */ + ret = catpt_restore_dram_data(cdev, chan); if (ret) dev_err(cdev->dev, "restore memdumps failed: %d\n", ret); @@ -568,8 +568,8 @@ static int catpt_load_firmware(struct catpt_dev *cdev, return 0; } -static int catpt_load_image(struct catpt_dev *cdev, struct dma_chan *chan, - const char *name, bool restore) +static int catpt_request_load_firmware(struct catpt_dev *cdev, struct dma_chan *chan, + const char *name, bool restore) { struct catpt_fw_hdr *fw; struct firmware *img; @@ -607,7 +607,7 @@ static int catpt_load_image(struct catpt_dev *cdev, struct dma_chan *chan, return ret; } -static int catpt_load_images(struct catpt_dev *cdev, bool restore) +static int catpt_request_dma_load_firmware(struct catpt_dev *cdev, bool restore) { struct dma_chan *chan; int ret; @@ -616,7 +616,7 @@ static int catpt_load_images(struct catpt_dev *cdev, bool restore) if (IS_ERR(chan)) return PTR_ERR(chan); - ret = catpt_load_image(cdev, chan, cdev->spec->fw_name, restore); + ret = catpt_request_load_firmware(cdev, chan, cdev->spec->fw_name, restore); if (ret) goto release_dma_chan; @@ -636,7 +636,7 @@ int catpt_boot_firmware(struct catpt_dev *cdev, bool restore) catpt_dsp_stall(cdev, true); - ret = catpt_load_images(cdev, restore); + ret = catpt_request_dma_load_firmware(cdev, restore); if (ret) { dev_err(cdev->dev, "load binaries failed: %d\n", ret); return ret; From ae6540c4909a0f347c43d0b996c512360867f539 Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 29 Jul 2026 13:00:55 +0200 Subject: [PATCH 6/8] ASoC: Intel: catpt: Streamline wording of offset variables Two words represent is currently: 'offset' and 'off'. Be cohesive and use one instead. Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20260729110057.342447-7-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/catpt/loader.c | 48 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c index 274af8fb8828..e7ba9e1e60ae 100644 --- a/sound/soc/intel/catpt/loader.c +++ b/sound/soc/intel/catpt/loader.c @@ -359,7 +359,7 @@ static int catpt_restore_basefw(struct catpt_dev *cdev, struct dma_chan *chan, dma_addr_t paddr, struct catpt_fw_module_hdr *basefw) { - u32 offset = sizeof(*basefw); + u32 off = sizeof(*basefw); int ret, i; print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4, @@ -369,16 +369,14 @@ static int catpt_restore_basefw(struct catpt_dev *cdev, for (i = 0; i < basefw->blocks; i++) { struct catpt_fw_block_hdr *blk; - blk = (struct catpt_fw_block_hdr *)((u8 *)basefw + offset); + blk = (struct catpt_fw_block_hdr *)((u8 *)basefw + off); switch (blk->ram_type) { case CATPT_RAM_TYPE_IRAM: - ret = catpt_load_block(cdev, chan, paddr + offset, - blk, false); + ret = catpt_load_block(cdev, chan, paddr + off, blk, false); break; default: - ret = catpt_restore_dram_rodata(cdev, chan, paddr + offset, - blk); + ret = catpt_restore_dram_rodata(cdev, chan, paddr + off, blk); break; } @@ -387,7 +385,7 @@ static int catpt_restore_basefw(struct catpt_dev *cdev, return ret; } - offset += sizeof(*blk) + blk->size; + off += sizeof(*blk) + blk->size; } /* Then proceed with DRAM .data saved before D3. */ @@ -402,7 +400,7 @@ static int catpt_restore_module(struct catpt_dev *cdev, struct dma_chan *chan, dma_addr_t paddr, struct catpt_fw_module_hdr *mod) { - u32 offset = sizeof(*mod); + u32 off = sizeof(*mod); int i; print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4, @@ -412,7 +410,7 @@ static int catpt_restore_module(struct catpt_dev *cdev, struct catpt_fw_block_hdr *blk; int ret; - blk = (struct catpt_fw_block_hdr *)((u8 *)mod + offset); + blk = (struct catpt_fw_block_hdr *)((u8 *)mod + off); switch (blk->ram_type) { case CATPT_RAM_TYPE_INSTANCE: @@ -423,7 +421,7 @@ static int catpt_restore_module(struct catpt_dev *cdev, ALIGN(blk->size, 4)); break; default: - ret = catpt_load_block(cdev, chan, paddr + offset, + ret = catpt_load_block(cdev, chan, paddr + off, blk, false); break; } @@ -433,7 +431,7 @@ static int catpt_restore_module(struct catpt_dev *cdev, return ret; } - offset += sizeof(*blk) + blk->size; + off += sizeof(*blk) + blk->size; } return 0; @@ -444,7 +442,7 @@ static int catpt_load_module(struct catpt_dev *cdev, struct catpt_fw_module_hdr *mod) { struct catpt_module_type *type; - u32 offset = sizeof(*mod); + u32 off = sizeof(*mod); int i; print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4, @@ -456,9 +454,9 @@ static int catpt_load_module(struct catpt_dev *cdev, struct catpt_fw_block_hdr *blk; int ret; - blk = (struct catpt_fw_block_hdr *)((u8 *)mod + offset); + blk = (struct catpt_fw_block_hdr *)((u8 *)mod + off); - ret = catpt_load_block(cdev, chan, paddr + offset, blk, true); + ret = catpt_load_block(cdev, chan, paddr + off, blk, true); if (ret) { dev_err(cdev->dev, "load block failed: %d\n", ret); return ret; @@ -473,7 +471,7 @@ static int catpt_load_module(struct catpt_dev *cdev, type->state_size = blk->size; } - offset += sizeof(*blk) + blk->size; + off += sizeof(*blk) + blk->size; } /* init module type static info */ @@ -490,7 +488,7 @@ static int catpt_restore_firmware(struct catpt_dev *cdev, struct dma_chan *chan, dma_addr_t paddr, struct catpt_fw_hdr *fw) { - u32 offset = sizeof(*fw); + u32 off = sizeof(*fw); int i; print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4, @@ -500,7 +498,7 @@ static int catpt_restore_firmware(struct catpt_dev *cdev, struct catpt_fw_module_hdr *mod; int ret; - mod = (struct catpt_fw_module_hdr *)((u8 *)fw + offset); + mod = (struct catpt_fw_module_hdr *)((u8 *)fw + off); if (strncmp(fw->signature, mod->signature, FW_SIGNATURE_SIZE)) { dev_err(cdev->dev, "module signature mismatch\n"); @@ -512,12 +510,10 @@ static int catpt_restore_firmware(struct catpt_dev *cdev, switch (mod->module_id) { case CATPT_MODID_BASE_FW: - ret = catpt_restore_basefw(cdev, chan, paddr + offset, - mod); + ret = catpt_restore_basefw(cdev, chan, paddr + off, mod); break; default: - ret = catpt_restore_module(cdev, chan, paddr + offset, - mod); + ret = catpt_restore_module(cdev, chan, paddr + off, mod); break; } @@ -526,7 +522,7 @@ static int catpt_restore_firmware(struct catpt_dev *cdev, return ret; } - offset += sizeof(*mod) + mod->mod_size; + off += sizeof(*mod) + mod->mod_size; } return 0; @@ -536,7 +532,7 @@ static int catpt_load_firmware(struct catpt_dev *cdev, struct dma_chan *chan, dma_addr_t paddr, struct catpt_fw_hdr *fw) { - u32 offset = sizeof(*fw); + u32 off = sizeof(*fw); int i; print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4, @@ -546,7 +542,7 @@ static int catpt_load_firmware(struct catpt_dev *cdev, struct catpt_fw_module_hdr *mod; int ret; - mod = (struct catpt_fw_module_hdr *)((u8 *)fw + offset); + mod = (struct catpt_fw_module_hdr *)((u8 *)fw + off); if (strncmp(fw->signature, mod->signature, FW_SIGNATURE_SIZE)) { dev_err(cdev->dev, "module signature mismatch\n"); @@ -556,13 +552,13 @@ static int catpt_load_firmware(struct catpt_dev *cdev, if (mod->module_id > CATPT_MODID_LAST) return -EINVAL; - ret = catpt_load_module(cdev, chan, paddr + offset, mod); + ret = catpt_load_module(cdev, chan, paddr + off, mod); if (ret) { dev_err(cdev->dev, "load module failed: %d\n", ret); return ret; } - offset += sizeof(*mod) + mod->mod_size; + off += sizeof(*mod) + mod->mod_size; } return 0; From a0acf55be73414db280372e2ad5aae705b9de403 Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 29 Jul 2026 13:00:56 +0200 Subject: [PATCH 7/8] ASoC: Intel: catpt: Streamline runtime-variables naming Mimic naming pattern commonly found in the ASoC code: - 'rtd' in case of struct snd_soc_pcm_runtime - 'runtime' in case of struct snd_pcm_runtime Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20260729110057.342447-8-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/catpt/pcm.c | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c index 8fb0efb67eb1..12a5226cf12c 100644 --- a/sound/soc/intel/catpt/pcm.c +++ b/sound/soc/intel/catpt/pcm.c @@ -75,8 +75,8 @@ static struct catpt_stream_template *catpt_topology[] = { static struct catpt_stream_template * catpt_get_stream_template(struct snd_pcm_substream *substream) { - struct snd_soc_pcm_runtime *rtm = snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtm, 0); + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); enum catpt_stream_type type; type = cpu_dai->driver->id; @@ -159,11 +159,11 @@ static void catpt_stream_read_position(struct catpt_dev *cdev, static void catpt_arrange_page_table(struct snd_pcm_substream *substream, struct snd_dma_buffer *pgtbl) { - struct snd_pcm_runtime *rtm = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_dma_buffer *databuf = snd_pcm_get_dma_buf(substream); int i, pages; - pages = snd_sgbuf_aligned_pages(rtm->dma_bytes); + pages = snd_sgbuf_aligned_pages(runtime->dma_bytes); for (i = 0; i < pages; i++) { u32 pfn, offset; @@ -386,7 +386,7 @@ static int catpt_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_pcm_runtime *rtm = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_dma_buffer *dmab; struct catpt_stream_runtime *stream; struct catpt_audio_format afmt; @@ -412,8 +412,8 @@ static int catpt_dai_hw_params(struct snd_pcm_substream *substream, memset(&rinfo, 0, sizeof(rinfo)); rinfo.page_table_addr = stream->pgtbl.addr; - rinfo.num_pages = DIV_ROUND_UP(rtm->dma_bytes, PAGE_SIZE); - rinfo.size = rtm->dma_bytes; + rinfo.num_pages = DIV_ROUND_UP(runtime->dma_bytes, PAGE_SIZE); + rinfo.size = runtime->dma_bytes; rinfo.offset = 0; rinfo.ring_first_page_pfn = PFN_DOWN(snd_sgbuf_get_addr(dmab, 0)); @@ -544,11 +544,11 @@ void catpt_stream_update_position(struct catpt_dev *cdev, struct catpt_notify_position *pos) { struct snd_pcm_substream *substream = stream->substream; - struct snd_pcm_runtime *r = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t dsppos, newpos; int ret; - dsppos = bytes_to_frames(r, pos->stream_position); + dsppos = bytes_to_frames(runtime, pos->stream_position); if (!stream->prepared) goto exit; @@ -556,8 +556,8 @@ void catpt_stream_update_position(struct catpt_dev *cdev, if (stream->template->type != CATPT_STRM_TYPE_RENDER) goto exit; - if (dsppos >= r->buffer_size / 2) - newpos = r->buffer_size / 2; + if (dsppos >= runtime->buffer_size / 2) + newpos = runtime->buffer_size / 2; else newpos = 0; /* @@ -565,7 +565,7 @@ void catpt_stream_update_position(struct catpt_dev *cdev, * (buffer half consumed) update wp to allow stream progression. */ ret = catpt_ipc_set_write_pos(cdev, stream->info.stream_hw_id, - frames_to_bytes(r, newpos), + frames_to_bytes(runtime, newpos), false, false); if (ret) { dev_err(cdev->dev, "update position for stream %d failed: %d\n", @@ -600,11 +600,11 @@ static const struct snd_pcm_hardware catpt_pcm_hardware = { }; static int catpt_component_pcm_new(struct snd_soc_component *component, - struct snd_soc_pcm_runtime *rtm) + struct snd_soc_pcm_runtime *rtd) { struct catpt_dev *cdev = dev_get_drvdata(component->dev); - snd_pcm_set_managed_buffer_all(rtm->pcm, SNDRV_DMA_TYPE_DEV_SG, + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV_SG, cdev->dev, catpt_pcm_hardware.buffer_bytes_max, catpt_pcm_hardware.buffer_bytes_max); @@ -615,9 +615,9 @@ static int catpt_component_pcm_new(struct snd_soc_component *component, static int catpt_component_open(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - struct snd_soc_pcm_runtime *rtm = snd_soc_substream_to_rtd(substream); + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - if (!rtm->dai_link->no_pcm) + if (!rtd->dai_link->no_pcm) snd_soc_set_runtime_hwparams(substream, &catpt_pcm_hardware); return 0; } @@ -626,13 +626,13 @@ static snd_pcm_uframes_t catpt_component_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - struct snd_soc_pcm_runtime *rtm = snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtm, 0); + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); struct catpt_stream_runtime *stream; struct catpt_dev *cdev = dev_get_drvdata(component->dev); u32 pos; - if (rtm->dai_link->no_pcm) + if (rtd->dai_link->no_pcm) return 0; stream = snd_soc_dai_get_dma_data(cpu_dai, substream); @@ -650,10 +650,10 @@ static const struct snd_soc_dai_ops catpt_fe_dai_ops = { .trigger = catpt_dai_trigger, }; -static int catpt_dai_pcm_new(struct snd_soc_pcm_runtime *rtm, +static int catpt_dai_pcm_new(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) { - struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtm, 0); + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); struct catpt_ssp_device_format devfmt; struct catpt_dev *cdev = dev_get_drvdata(dai->dev); int ret; From 4075b9d256ef5c22688e2ae812c1b89ac791182a Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 29 Jul 2026 13:00:57 +0200 Subject: [PATCH 8/8] ASoC: Intel: catpt: Streamline control-variables naming Two naming patterns exist currently in the code: 'kcontrol' and 'kctl'. Pick one and stick with it. Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20260729110057.342447-9-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/catpt/pcm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c index 12a5226cf12c..f23c580ba051 100644 --- a/sound/soc/intel/catpt/pcm.c +++ b/sound/soc/intel/catpt/pcm.c @@ -871,8 +871,7 @@ static int catpt_set_dspvol(struct catpt_dev *cdev, u8 stream_id, long *ctlvol) return CATPT_IPC_RET(ret); } -static int catpt_volume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) +static int catpt_volume_info(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = CATPT_CHANNELS_MAX;