serial: imx: remove unbalanced clk_prepare
authorEduardo Valentin <edubezval@gmail.com>
Tue, 11 Aug 2015 17:21:20 +0000 (10:21 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Aug 2015 00:23:25 +0000 (17:23 -0700)
The current code attempts to prepare clk_per and clk_ipg
before using the device. However, the result is an extra
prepare call on each clock. Here is the output of uart
clocks (only uart enabled and used as console):

$  grep uart /sys/kernel/debug/clk/clk_summary
 uart_serial           1            2    80000000          0 0
       uart           1            2    66000000          0 0

This patch balances the calls of prepares. The result is:

$  grep uart /sys/kernel/debug/clk/clk_summary
 uart_serial           1            1    80000000          0 0
       uart           1            1    66000000          0 0

Cc: Fabio Estevam <festevam@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-serial@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c

index 9a248eb11308053c206e637ebbd06e39c5a8fd2d..b27c23256a51bfddb90c3a9abfe32ee79e3af728 100644 (file)
@@ -1630,12 +1630,12 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
        int locked = 1;
        int retval;
 
-       retval = clk_enable(sport->clk_per);
+       retval = clk_prepare_enable(sport->clk_per);
        if (retval)
                return;
-       retval = clk_enable(sport->clk_ipg);
+       retval = clk_prepare_enable(sport->clk_ipg);
        if (retval) {
-               clk_disable(sport->clk_per);
+               clk_disable_unprepare(sport->clk_per);
                return;
        }
 
@@ -1674,8 +1674,8 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
        if (locked)
                spin_unlock_irqrestore(&sport->port.lock, flags);
 
-       clk_disable(sport->clk_ipg);
-       clk_disable(sport->clk_per);
+       clk_disable_unprepare(sport->clk_ipg);
+       clk_disable_unprepare(sport->clk_per);
 }
 
 /*
@@ -1776,15 +1776,7 @@ imx_console_setup(struct console *co, char *options)
 
        retval = uart_set_options(&sport->port, co, baud, parity, bits, flow);
 
-       clk_disable(sport->clk_ipg);
-       if (retval) {
-               clk_unprepare(sport->clk_ipg);
-               goto error_console;
-       }
-
-       retval = clk_prepare(sport->clk_per);
-       if (retval)
-               clk_disable_unprepare(sport->clk_ipg);
+       clk_disable_unprepare(sport->clk_ipg);
 
 error_console:
        return retval;