]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
tty: serial: of_serial: Do not allocate greater space than required
authorMichal Simek <michal.simek@xilinx.com>
Tue, 23 Aug 2016 15:21:26 +0000 (17:21 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 23 Aug 2016 17:43:07 +0000 (19:43 +0200)
The patch fixes the problem when there is another IP on higher addresses
which require allocation.
For example:
uart16550: 0x44a00000 - 0x44a10000 (reg offset: 0x1000)
IP: 0x44a10000 - 0x44aX0000

Current code is shifting base address with reg-offset value
(0x44a01000) but the size is the same that's why requested memory
region for ioremap is from 0x44a01000 with 0x10000 size which overlap
the next IP where requesting memory region is failing because the part
of region is already mapped.

The patch decreases mapped size with reg-offset not to overlap selected
memory address ranges.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/tty/serial/8250/8250_of.c

index c7ed3d2bc8b22bac300e0b28e2657ff758dd07b2..3e83e7dc6caaedc0ff558488ef3816b1ba4a6abf 100644 (file)
@@ -94,8 +94,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
        port->mapsize = resource_size(&resource);
 
        /* Check for shifted address mapping */
-       if (of_property_read_u32(np, "reg-offset", &prop) == 0)
+       if (of_property_read_u32(np, "reg-offset", &prop) == 0) {
                port->mapbase += prop;
+               port->mapsize -= prop;
+       }
 
        /* Check for registers offset within the devices address range */
        if (of_property_read_u32(np, "reg-shift", &prop) == 0)