linux-mips
[Top] [All Lists]

[PATCH 3/3] tty: of_serial: initialize port.iosize from resource

To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 3/3] tty: of_serial: initialize port.iosize from resource
From: John Crispin <blogic@openwrt.org>
Date: Sat, 13 Apr 2013 11:33:38 +0200
Cc: linux-mips@linux-mips.org, linux-serial@vger.kernel.org, Gabor Juhos <juhosg@openwrt.org>
In-reply-to: <1365845618-16040-1-git-send-email-blogic@openwrt.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1365845618-16040-1-git-send-email-blogic@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
From: Gabor Juhos <juhosg@openwrt.org>

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/tty/serial/of_serial.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 42f8550..e4be45b 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -88,10 +88,14 @@ static int of_platform_serial_setup(struct platform_device 
*ofdev,
 
        spin_lock_init(&port->lock);
        port->mapbase = resource.start;
+       port->iosize = 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;
+               if (prop > port->iosize)
+                       port->iosize -= prop;
+       }
 
        /* Check for registers offset within the devices address range */
        if (of_property_read_u32(np, "reg-shift", &prop) == 0)
-- 
1.7.10.4


<Prev in Thread] Current Thread [Next in Thread>