Patchwork [v2,39/45] drivers: tty: serial: efm32-uart: use devm_* functions

mail settings
Submitter Enrico Weigelt, metux IT consult
Date March 14, 2019, 10:34 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/749101/
State New
Headers show


Enrico Weigelt, metux IT consult - March 14, 2019, 10:34 p.m.
Use the safer devm versions of memory mapping functions.

Signed-off-by: Enrico Weigelt, metux IT consult <>
 drivers/tty/serial/efm32-uart.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Uwe Kleine-König - March 15, 2019, 7:46 a.m.
Hello Enrico,

On Thu, Mar 14, 2019 at 11:34:09PM +0100, Enrico Weigelt, metux IT consult wrote:
> Use the safer devm versions of memory mapping functions.

In which aspect is devm_ioremap safer than ioremap?

The only upside I'm aware of is that the memory is automatically
unmapped on device unbind. But we don't benefit from this because an
UART port is "released" before the device is unbound and we call
devm_iounmap() then anyhow. So this patch just adds a memory allocation
(side note: on a platform that is quite tight on RAM) with no added

I didn't look at the other patches in this series, but assuming that
they are similar in spirit, the same question applies for them.

Do I miss anything?

Best regards


diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c
index d6b5e54..a79cadc 100644
--- a/drivers/tty/serial/efm32-uart.c
+++ b/drivers/tty/serial/efm32-uart.c
@@ -437,7 +437,7 @@  static void efm32_uart_release_port(struct uart_port *port)
-	iounmap(port->membase);
+	devm_iounmap(port->dev, port->membase);
 static int efm32_uart_request_port(struct uart_port *port)
@@ -445,7 +445,7 @@  static int efm32_uart_request_port(struct uart_port *port)
 	struct efm32_uart_port *efm_port = to_efm_port(port);
 	int ret;
-	port->membase = ioremap(port->mapbase, 60);
+	port->membase = devm_ioremap(port->dev, port->mapbase, 60);
 	if (!efm_port->port.membase) {
 		ret = -ENOMEM;
 		efm_debug(efm_port, "failed to remap\n");
@@ -464,7 +464,7 @@  static int efm32_uart_request_port(struct uart_port *port)
-		iounmap(port->membase);
+		devm_iounmap(port->dev, port->membase);
 		return ret;