Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rapidio: use resource_size()

The size calculation is done incorrectly here because it should include
both the start and end (end - start + 1). It's easiest to just use
resource_size() which does the right thing.

I was worried there was something non-standard going on because the
printk() subtracts "end - 1", but the rest of the file uses the normal
resource size calculations. This function is only called from
fsl_rio_setup() in arch/powerpc/sysdev/fsl_rio.c and the calculation
there is also:

port->iores.start = law_start;
port->iores.end = law_start + law_size - 1;

So I think this is the correct fix.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Cc: Alexandre Bounine <alexandre.bounine@idt.com>
Acked-by: Li Yang <leoli@freescale.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dan Carpenter and committed by
Linus Torvalds
88cf81fc 38b7a2ae

+2 -2
+2 -2
drivers/rapidio/rio.c
··· 1159 1159 1160 1160 list_for_each_entry(port, &rio_mports, node) { 1161 1161 if (!request_mem_region(port->iores.start, 1162 - port->iores.end - port->iores.start, 1162 + resource_size(&port->iores), 1163 1163 port->name)) { 1164 1164 printk(KERN_ERR 1165 1165 "RIO: Error requesting master port region 0x%016llx-0x%016llx\n", 1166 - (u64)port->iores.start, (u64)port->iores.end - 1); 1166 + (u64)port->iores.start, (u64)port->iores.end); 1167 1167 rc = -ENOMEM; 1168 1168 goto out; 1169 1169 }