diff options
author | Rob Herring <rob.herring@calxeda.com> | 2013-09-24 22:05:58 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-25 21:10:56 -0400 |
commit | f377775dc083506e2fd7739d8615971c46b5246e (patch) | |
tree | 9fac95e32736d6a172db90ccc376043af9ef039c | |
parent | 469d6d0631386e6865a30c9ded87a5cc0fdf8e2e (diff) |
TTY: hvc_dcc: probe for a JTAG connection before registering
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 <paolo.pisati@canonical.com>
Cc: Tim Gardner <tim.gardner@canonical.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/hvc/hvc_dcc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c index 44fbebab5075..3502a7bbb69e 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) | |||
86 | return i; | 86 | return i; |
87 | } | 87 | } |
88 | 88 | ||
89 | static bool hvc_dcc_check(void) | ||
90 | { | ||
91 | unsigned long time = jiffies + (HZ / 10); | ||
92 | |||
93 | /* Write a test character to check if it is handled */ | ||
94 | __dcc_putchar('\n'); | ||
95 | |||
96 | while (time_is_after_jiffies(time)) { | ||
97 | if (!(__dcc_getstatus() & DCC_STATUS_TX)) | ||
98 | return true; | ||
99 | } | ||
100 | |||
101 | return false; | ||
102 | } | ||
103 | |||
89 | static const struct hv_ops hvc_dcc_get_put_ops = { | 104 | static const struct hv_ops hvc_dcc_get_put_ops = { |
90 | .get_chars = hvc_dcc_get_chars, | 105 | .get_chars = hvc_dcc_get_chars, |
91 | .put_chars = hvc_dcc_put_chars, | 106 | .put_chars = hvc_dcc_put_chars, |
@@ -93,6 +108,9 @@ static const struct hv_ops hvc_dcc_get_put_ops = { | |||
93 | 108 | ||
94 | static int __init hvc_dcc_console_init(void) | 109 | static int __init hvc_dcc_console_init(void) |
95 | { | 110 | { |
111 | if (!hvc_dcc_check()) | ||
112 | return -ENODEV; | ||
113 | |||
96 | hvc_instantiate(0, 0, &hvc_dcc_get_put_ops); | 114 | hvc_instantiate(0, 0, &hvc_dcc_get_put_ops); |
97 | return 0; | 115 | return 0; |
98 | } | 116 | } |
@@ -100,6 +118,9 @@ console_initcall(hvc_dcc_console_init); | |||
100 | 118 | ||
101 | static int __init hvc_dcc_init(void) | 119 | static int __init hvc_dcc_init(void) |
102 | { | 120 | { |
121 | if (!hvc_dcc_check()) | ||
122 | return -ENODEV; | ||
123 | |||
103 | hvc_alloc(0, 0, &hvc_dcc_get_put_ops, 128); | 124 | hvc_alloc(0, 0, &hvc_dcc_get_put_ops, 128); |
104 | return 0; | 125 | return 0; |
105 | } | 126 | } |