linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: edward.cragg@codethink.co.uk
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-meson@googlegroups.com, linux-kernel@codethink.co.uk,
	Ben Dooks <ben.dooks@codethink.co.uk>,
	linux-serial@vger.kernel.org, Jiri Slaby <jslaby@suse.com>,
	carlo@caione.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/9] ARM: meson: serial: release region on port release
Date: Wed, 18 Nov 2015 14:41:11 +0000	[thread overview]
Message-ID: <1447857679-30158-2-git-send-email-ben.dooks@codethink.co.uk> (raw)
In-Reply-To: <1447857679-30158-1-git-send-email-ben.dooks@codethink.co.uk>

The meson_uart_release_port() unmaps the register area but does not release
it. The meson_uart_request_port() calls devm_request_mem_region so the
release should call devm_release_mem_region() for that area so that anyt
subsequent use of these calls will work.

This fixes an issue where the addition of reset code before registering
the uart stops the console from working.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/tty/serial/meson_uart.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index 0fc83c9..b9f0829 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -367,9 +367,26 @@ static int meson_uart_verify_port(struct uart_port *port,
 	return ret;
 }
 
+static int meson_uart_res_size(struct uart_port *port)
+{
+	struct platform_device *pdev = to_platform_device(port->dev);
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(port->dev, "cannot obtain I/O memory region");
+		return -ENODEV;
+	}
+
+	return resource_size(res);
+}
+
 static void meson_uart_release_port(struct uart_port *port)
 {
+	int size = meson_uart_res_size(port);
+
 	if (port->flags & UPF_IOREMAP) {
+		devm_release_mem_region(port->dev, port->mapbase, size);
 		devm_iounmap(port->dev, port->membase);
 		port->membase = NULL;
 	}
@@ -377,16 +394,10 @@ static void meson_uart_release_port(struct uart_port *port)
 
 static int meson_uart_request_port(struct uart_port *port)
 {
-	struct platform_device *pdev = to_platform_device(port->dev);
-	struct resource *res;
-	int size;
+	int size = meson_uart_res_size(port);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "cannot obtain I/O memory region");
-		return -ENODEV;
-	}
-	size = resource_size(res);
+	if (size < 0)
+		return size;
 
 	if (!devm_request_mem_region(port->dev, port->mapbase, size,
 				     dev_name(port->dev))) {
-- 
2.6.2

  reply	other threads:[~2015-11-18 14:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 14:41 AMLogic Meson serial driver fixes Ben Dooks
2015-11-18 14:41 ` Ben Dooks [this message]
2015-11-18 14:41 ` [PATCH 2/9] ARM: meson: serial: don't reset port on uart startup Ben Dooks
2015-11-18 14:41 ` [PATCH 3/9] ARM: meson: serial: tx_empty fails to check for transmitter busy Ben Dooks
2015-11-18 14:41 ` [PATCH 4/9] ARM: meson: serial: ensure console port uart enabled Ben Dooks
2015-11-18 14:41 ` [PATCH 5/9] ARM: meson: serial: only disable tx irq on stop Ben Dooks
2015-11-18 14:41 ` [PATCH 6/9] ARM: meson: serial: use meson_uart_tx_empty() to wait for empty Ben Dooks
2015-11-18 14:41 ` [PATCH 7/9] ARM: meson: serial: disable rx/tx irqs during console write Ben Dooks
2015-11-18 14:41 ` [PATCH 8/9] ARM: meson: serial: ensure tx irq on if more work to do Ben Dooks
2015-11-18 14:41 ` [PATCH 9/9] ARM: meson: serial: check for tx-irq enabled in irq code Ben Dooks
2015-11-23 11:52 ` [linux-meson] AMLogic Meson serial driver fixes Carlo Caione

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447857679-30158-2-git-send-email-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=carlo@caione.org \
    --cc=edward.cragg@codethink.co.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@codethink.co.uk \
    --cc=linux-meson@googlegroups.com \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).