Skip to content

Commit ff924ca

Browse files
ribaldamchehab
authored andcommitted
media: pci: mgb4: Refactor struct resources
The struct resource end field signifies the end address not the relative offset from the start field i.e size == (end - start) + 1. Amend the .end field to specify the end address not the relative size from the offset as is currently given. Fixes cocci check: drivers/media/pci/mgb4/mgb4_regs.c:13:22-25: WARNING: Suspicious code. resource_size is maybe missing with res Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-1-3c4865f5a4b0@chromium.org Reviewed-by: Martin Tůma <martin.tuma@digiteqautomotive.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 776f1bd commit ff924ca

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/media/pci/mgb4/mgb4_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,13 @@ static int mgb4_probe(struct pci_dev *pdev, const struct pci_device_id *id)
493493
struct mgb4_dev *mgbdev;
494494
struct resource video = {
495495
.start = 0x0,
496-
.end = 0x100,
496+
.end = 0xff,
497497
.flags = IORESOURCE_MEM,
498498
.name = "mgb4-video",
499499
};
500500
struct resource cmt = {
501501
.start = 0x1000,
502-
.end = 0x1800,
502+
.end = 0x17ff,
503503
.flags = IORESOURCE_MEM,
504504
.name = "mgb4-cmt",
505505
};

drivers/media/pci/mgb4/mgb4_regs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
int mgb4_regs_map(struct resource *res, struct mgb4_regs *regs)
1111
{
1212
regs->mapbase = res->start;
13-
regs->mapsize = res->end - res->start;
13+
regs->mapsize = resource_size(res);
1414

1515
if (!request_mem_region(regs->mapbase, regs->mapsize, res->name))
1616
return -EINVAL;

0 commit comments

Comments
 (0)