devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Cernekee <cernekee@gmail.com>
To: gregkh@linuxfoundation.org, jslaby@suse.cz
Cc: robh@kernel.org, grant.likely@linaro.org, arnd@arndb.de,
	geert@linux-m68k.org, f.fainelli@gmail.com, mbizon@freebox.fr,
	jogo@openwrt.org, linux-mips@linux-mips.org,
	linux-serial@vger.kernel.org, devicetree@vger.kernel.org
Subject: [PATCH V3 07/10] tty: serial: bcm63xx: Eliminate unnecessary request/release functions
Date: Tue, 21 Oct 2014 15:23:03 -0700	[thread overview]
Message-ID: <1413930186-23168-8-git-send-email-cernekee@gmail.com> (raw)
In-Reply-To: <1413930186-23168-1-git-send-email-cernekee@gmail.com>

We don't really need to perform the ioremap "on demand" so it's simpler
just to do it from the probe function.  This also lets us eliminate the
UART_REG_SIZE constant and rely on the resource information passed in
from the DT or platform code.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
 drivers/tty/serial/bcm63xx_uart.c | 30 ++++++++++--------------------
 include/linux/serial_bcm63xx.h    |  2 --
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index 109dea7..e04e580 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -588,20 +588,7 @@ static void bcm_uart_set_termios(struct uart_port *port,
  */
 static int bcm_uart_request_port(struct uart_port *port)
 {
-	unsigned int size;
-
-	size = UART_REG_SIZE;
-	if (!request_mem_region(port->mapbase, size, "bcm63xx")) {
-		dev_err(port->dev, "Memory region busy\n");
-		return -EBUSY;
-	}
-
-	port->membase = ioremap(port->mapbase, size);
-	if (!port->membase) {
-		dev_err(port->dev, "Unable to map registers\n");
-		release_mem_region(port->mapbase, size);
-		return -EBUSY;
-	}
+	/* UARTs always present */
 	return 0;
 }
 
@@ -610,8 +597,7 @@ static int bcm_uart_request_port(struct uart_port *port)
  */
 static void bcm_uart_release_port(struct uart_port *port)
 {
-	release_mem_region(port->mapbase, UART_REG_SIZE);
-	iounmap(port->membase);
+	/* Nothing to release ... */
 }
 
 /*
@@ -833,13 +819,20 @@ static int bcm_uart_probe(struct platform_device *pdev)
 	if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS)
 		return -EINVAL;
 
-	if (ports[pdev->id].membase)
+	port = &ports[pdev->id];
+	if (port->membase)
 		return -EBUSY;
+	memset(port, 0, sizeof(*port));
 
 	res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res_mem)
 		return -ENODEV;
 
+	port->mapbase = res_mem->start;
+	port->membase = devm_ioremap_resource(&pdev->dev, res_mem);
+	if (IS_ERR(port->membase))
+		return PTR_ERR(port->membase);
+
 	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res_irq)
 		return -ENODEV;
@@ -849,10 +842,7 @@ static int bcm_uart_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return -ENODEV;
 
-	port = &ports[pdev->id];
-	memset(port, 0, sizeof(*port));
 	port->iotype = UPIO_MEM;
-	port->mapbase = res_mem->start;
 	port->irq = res_irq->start;
 	port->ops = &bcm_uart_ops;
 	port->flags = UPF_BOOT_AUTOCONF;
diff --git a/include/linux/serial_bcm63xx.h b/include/linux/serial_bcm63xx.h
index a80aa1a..570e964 100644
--- a/include/linux/serial_bcm63xx.h
+++ b/include/linux/serial_bcm63xx.h
@@ -116,6 +116,4 @@
 					UART_FIFO_PARERR_MASK |		\
 					UART_FIFO_BRKDET_MASK)
 
-#define UART_REG_SIZE			24
-
 #endif /* _LINUX_SERIAL_BCM63XX_H */
-- 
2.1.1


  parent reply	other threads:[~2014-10-21 22:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21 22:22 [PATCH V3 00/10] bcm63xx_uart and of-serial updates Kevin Cernekee
2014-10-21 22:22 ` [PATCH V3 01/10] tty: serial: bcm63xx: Allow bcm63xx_uart to be built on other platforms Kevin Cernekee
2014-10-21 22:22 ` [PATCH V3 02/10] tty: serial: bcm63xx: Add support for unnamed clock outputs from DT Kevin Cernekee
2014-10-21 22:22 ` [PATCH V3 03/10] tty: serial: bcm63xx: Update the Kconfig help text Kevin Cernekee
2014-10-21 22:23 ` [PATCH V3 04/10] tty: serial: bcm63xx: Fix typo in MODULE_DESCRIPTION Kevin Cernekee
2014-10-21 22:23 ` [PATCH V3 05/10] Documentation: DT: Add entries for bcm63xx UART Kevin Cernekee
2014-10-21 22:23 ` [PATCH V3 06/10] tty: serial: bcm63xx: Enable DT earlycon support Kevin Cernekee
2014-10-21 22:23 ` Kevin Cernekee [this message]
2014-10-21 22:23 ` [PATCH V3 08/10] tty: serial: of-serial: Suppress warnings if OF earlycon is invoked twice Kevin Cernekee
2014-10-21 22:23 ` [PATCH V3 09/10] tty: serial: of-serial: Allow OF earlycon to default to "on" Kevin Cernekee
2014-10-22  9:27   ` Rob Herring
2014-10-23  3:25     ` Kevin Cernekee
2014-10-23  4:47       ` Rob Herring
2014-10-23 14:31         ` Kevin Cernekee
2014-10-29  4:12           ` Kevin Cernekee
2014-10-21 22:23 ` [PATCH V3 10/10] MAINTAINERS: Add entry for rp2 (Rocketport Express/Infinity) driver Kevin Cernekee
2014-11-06 18:49 ` [PATCH V3 00/10] bcm63xx_uart and of-serial updates Greg KH

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=1413930186-23168-8-git-send-email-cernekee@gmail.com \
    --to=cernekee@gmail.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jogo@openwrt.org \
    --cc=jslaby@suse.cz \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mbizon@freebox.fr \
    --cc=robh@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).