Skip to content

Commit ea38b26

Browse files
crojewsk-intelbroonie
authored andcommitted
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>
1 parent 1a0ce0a commit ea38b26

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

sound/soc/intel/catpt/loader.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ static int catpt_restore_memdumps(struct catpt_dev *cdev, struct dma_chan *chan)
208208

209209
for (i = 0; i < cdev->dx_ctx.num_meminfo; i++) {
210210
struct catpt_save_meminfo *info;
211+
struct resource r = {};
211212
u32 off;
212213
int ret;
213214

@@ -216,7 +217,8 @@ static int catpt_restore_memdumps(struct catpt_dev *cdev, struct dma_chan *chan)
216217
continue;
217218

218219
off = catpt_to_host_offset(info->offset);
219-
if (off < cdev->dram.start || off + info->size >= cdev->dram.end)
220+
resource_set_range(&r, off, info->size);
221+
if (!resource_contains(&cdev->dram, &r))
220222
continue;
221223

222224
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,
239241
struct dma_chan *chan, dma_addr_t paddr,
240242
struct catpt_fw_block_hdr *blk)
241243
{
242-
struct resource r1, r2, common;
244+
struct resource r1 = {};
243245
int i;
244246

245247
print_hex_dump_debug(__func__, DUMP_PREFIX_OFFSET, 8, 4,
246248
blk, sizeof(*blk), false);
247249

248-
r1.start = cdev->dram.start + blk->ram_offset;
249-
r1.end = r1.start + blk->size - 1;
250+
resource_set_range(&r1, cdev->dram.start + blk->ram_offset, blk->size);
250251
/* advance to data area */
251252
paddr += sizeof(*blk);
252253

253254
for (i = 0; i < cdev->dx_ctx.num_meminfo; i++) {
254255
struct catpt_save_meminfo *info;
256+
struct resource common = {};
257+
struct resource r2 = {};
255258
u32 off;
256259
int ret;
257260

258261
info = &cdev->dx_ctx.meminfo[i];
259-
260262
if (info->source != CATPT_DX_TYPE_FW_IMAGE)
261263
continue;
262264

263265
off = catpt_to_host_offset(info->offset);
264-
r2.start = off;
265-
r2.end = r2.start + info->size - 1;
266-
267-
if (r2.start < cdev->dram.start || r2.end > cdev->dram.end)
266+
resource_set_range(&r2, off, info->size);
267+
if (!resource_contains(&cdev->dram, &r2))
268268
continue;
269269

270270
if (!resource_intersection(&r2, &r1, &common))

0 commit comments

Comments
 (0)