Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753600Ab3IWUcU (ORCPT ); Mon, 23 Sep 2013 16:32:20 -0400 Received: from mail-vb0-f48.google.com ([209.85.212.48]:54527 "EHLO mail-vb0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752423Ab3IWUcS (ORCPT ); Mon, 23 Sep 2013 16:32:18 -0400 From: Rob Herring To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Rob Herring , Paolo Pisati , Tim Gardner , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH] TTY: hvc_dcc: probe for a JTAG connection before registering Date: Mon, 23 Sep 2013 15:30:34 -0500 Message-Id: <1379968234-23373-1-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.8.1.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2056 Lines: 71 From: Rob Herring Enabling the ARM DCC console and using without a JTAG connection will simply hang the system. Since distros like to turn on all options, this is a reoccurring problem to debug. We can do better by checking if anything is attached and handling characters. There is no way to probe this, so send a newline and check that it is handled. Cc: Paolo Pisati Cc: Tim Gardner Cc: Greg Kroah-Hartman Cc: Jiri Slaby Signed-off-by: Rob Herring --- drivers/tty/hvc/hvc_dcc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c index 44fbeba..44c8aff 100644 --- a/drivers/tty/hvc/hvc_dcc.c +++ b/drivers/tty/hvc/hvc_dcc.c @@ -86,6 +86,21 @@ static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count) return i; } +static bool hvc_dcc_check(void) +{ + unsigned long time = jiffies; + + /* Write a test character to check if it is handled */ + __dcc_putchar('\n'); + + while (jiffies < time + (HZ / 10)) { + if (!(__dcc_getstatus() & DCC_STATUS_TX)) + return true; + } + + return false; +} + static const struct hv_ops hvc_dcc_get_put_ops = { .get_chars = hvc_dcc_get_chars, .put_chars = hvc_dcc_put_chars, @@ -93,6 +108,9 @@ static const struct hv_ops hvc_dcc_get_put_ops = { static int __init hvc_dcc_console_init(void) { + if (!hvc_dcc_check()) + return -ENODEV; + hvc_instantiate(0, 0, &hvc_dcc_get_put_ops); return 0; } @@ -100,6 +118,9 @@ console_initcall(hvc_dcc_console_init); static int __init hvc_dcc_init(void) { + if (!hvc_dcc_check()) + return -ENODEV; + hvc_alloc(0, 0, &hvc_dcc_get_put_ops, 128); return 0; } -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/