linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix serial console on SNI RM400 machines
@ 2017-05-31 20:21 Thomas Bogendoerfer
  2017-06-07 13:47 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Bogendoerfer @ 2017-05-31 20:21 UTC (permalink / raw)
  To: gregkh, jslaby, linux-serial, linux-kernel; +Cc: linux

sccnxp driver doesn't get the correct uart clock rate, if CONFIG_HAVE_CLOCK
is disabled. Correct usage of clk API to make it work with/without it.

Fixes: 90efa75f7ab0 (serial: sccnxp: Using CLK API for getting UART clock)

Suggested-by: Russell King - ARM Linux <linux@armlinux.org.uk>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
 drivers/tty/serial/sccnxp.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index fcf803f..cdd2f94 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -884,14 +884,19 @@ static int sccnxp_probe(struct platform_device *pdev)
 
 	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
-		if (PTR_ERR(clk) == -EPROBE_DEFER) {
-			ret = -EPROBE_DEFER;
+		ret = PTR_ERR(clk);
+		if (ret == -EPROBE_DEFER)
 			goto err_out;
-		}
+		uartclk = 0;
+	} else {
+		clk_prepare_enable(clk);
+		uartclk = clk_get_rate(clk);
+	}
+
+	if (!uartclk) {
 		dev_notice(&pdev->dev, "Using default clock frequency\n");
 		uartclk = s->chip->freq_std;
-	} else
-		uartclk = clk_get_rate(clk);
+	}
 
 	/* Check input frequency */
 	if ((uartclk < s->chip->freq_min) || (uartclk > s->chip->freq_max)) {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix serial console on SNI RM400 machines
  2017-05-31 20:21 [PATCH] Fix serial console on SNI RM400 machines Thomas Bogendoerfer
@ 2017-06-07 13:47 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2017-06-07 13:47 UTC (permalink / raw)
  To: Thomas Bogendoerfer
  Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel,
	Russell King - ARM Linux

On Wed, May 31, 2017 at 11:21 PM, Thomas Bogendoerfer
<tsbogend@alpha.franken.de> wrote:
> sccnxp driver doesn't get the correct uart clock rate, if CONFIG_HAVE_CLOCK
> is disabled. Correct usage of clk API to make it work with/without it.

uart -> UART
clk -> CLK

>         clk = devm_clk_get(&pdev->dev, NULL);
>         if (IS_ERR(clk)) {
> -               if (PTR_ERR(clk) == -EPROBE_DEFER) {
> -                       ret = -EPROBE_DEFER;
> +               ret = PTR_ERR(clk);
> +               if (ret == -EPROBE_DEFER)
>                         goto err_out;
> -               }
> +               uartclk = 0;
> +       } else {

> +               clk_prepare_enable(clk);

This might fail.

> +               uartclk = clk_get_rate(clk);
> +       }

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-07 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31 20:21 [PATCH] Fix serial console on SNI RM400 machines Thomas Bogendoerfer
2017-06-07 13:47 ` Andy Shevchenko

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).