ASoC: Intel: catpt: Switch to resource_xxx() API

There is a number of interfaces available for manipulating instances of
struct resource. To improve readability, move away from manual editing
in favor of the common interface.

While at it, adjust spacing so that both code blocks, while found in
separate functions, looks cohesive.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20251126095523.3925364-3-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Cezary Rojewski 2025-11-26 10:55:19 +01:00 committed by Mark Brown
parent 1a0ce0a1e6
commit ea38b262a2
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 9 additions and 9 deletions

View File

@ -208,6 +208,7 @@ static int catpt_restore_memdumps(struct catpt_dev *cdev, struct dma_chan *chan)
for (i = 0; i < cdev->dx_ctx.num_meminfo; i++) { for (i = 0; i < cdev->dx_ctx.num_meminfo; i++) {
struct catpt_save_meminfo *info; struct catpt_save_meminfo *info;
struct resource r = {};
u32 off; u32 off;
int ret; int ret;
@ -216,7 +217,8 @@ static int catpt_restore_memdumps(struct catpt_dev *cdev, struct dma_chan *chan)
continue; continue;
off = catpt_to_host_offset(info->offset); off = catpt_to_host_offset(info->offset);
if (off < cdev->dram.start || off + info->size >= cdev->dram.end) resource_set_range(&r, off, info->size);
if (!resource_contains(&cdev->dram, &r))
continue; continue;
dev_dbg(cdev->dev, "restoring memdump: off 0x%08x size %d\n", dev_dbg(cdev->dev, "restoring memdump: off 0x%08x size %d\n",
@ -239,32 +241,30 @@ static int catpt_restore_fwimage(struct catpt_dev *cdev,
struct dma_chan *chan, dma_addr_t paddr, struct dma_chan *chan, dma_addr_t paddr,
struct catpt_fw_block_hdr *blk) struct catpt_fw_block_hdr *blk)
{ {
struct resource r1, r2, common; struct resource r1 = {};
int i; int i;
print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4, print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4,
blk, sizeof(*blk), false); blk, sizeof(*blk), false);
r1.start = cdev->dram.start + blk->ram_offset; resource_set_range(&r1, cdev->dram.start + blk->ram_offset, blk->size);
r1.end = r1.start + blk->size - 1;
/* advance to data area */ /* advance to data area */
paddr += sizeof(*blk); paddr += sizeof(*blk);
for (i = 0; i < cdev->dx_ctx.num_meminfo; i++) { for (i = 0; i < cdev->dx_ctx.num_meminfo; i++) {
struct catpt_save_meminfo *info; struct catpt_save_meminfo *info;
struct resource common = {};
struct resource r2 = {};
u32 off; u32 off;
int ret; int ret;
info = &cdev->dx_ctx.meminfo[i]; info = &cdev->dx_ctx.meminfo[i];
if (info->source != CATPT_DX_TYPE_FW_IMAGE) if (info->source != CATPT_DX_TYPE_FW_IMAGE)
continue; continue;
off = catpt_to_host_offset(info->offset); off = catpt_to_host_offset(info->offset);
r2.start = off; resource_set_range(&r2, off, info->size);
r2.end = r2.start + info->size - 1; if (!resource_contains(&cdev->dram, &r2))
if (r2.start < cdev->dram.start || r2.end > cdev->dram.end)
continue; continue;
if (!resource_intersection(&r2, &r1, &common)) if (!resource_intersection(&r2, &r1, &common))