]> 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 <monstr@monstr.eu>
Tue, 6 Mar 2018 14:48:04 +0000 (15:48 +0100)
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 1222c005fb9889ea21f279882f43c27da5a34c43..7d40cdd0c39b9bc48357075e9dcf0df256e6a8cc 100644 (file)
@@ -102,8 +102,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)