@@ -122,25 +122,18 @@ static int kdb_read_get_key(char *buffer, size_t bufsize)
touch_nmi_watchdog();
f = &kdb_poll_funcs[0];
}
- if (escape_delay == 2) {
- *ped = '\0';
- ped = escape_data;
- --escape_delay;
- }
- if (escape_delay == 1) {
- key = *ped++;
- if (!*ped)
- --escape_delay;
- break;
- }
+
key = (*f)();
+
if (key == -1) {
if (escape_delay) {
udelay(ESCAPE_UDELAY);
- --escape_delay;
+ if (--escape_delay == 0)
+ return '\e';
}
continue;
}
+
if (bufsize <= 2) {
if (key == '\r')
key = '\n';
@@ -148,28 +141,25 @@ static int kdb_read_get_key(char *buffer, size_t bufsize)
*buffer = '\0';
return -1;
}
+
if (escape_delay == 0 && key == '\e') {
escape_delay = ESCAPE_DELAY;
ped = escape_data;
f_escape = f;
}
if (escape_delay) {
- *ped++ = key;
- if (f_escape != f) {
- escape_delay = 2;
- continue;
- }
+ if (f_escape != f)
+ return '\e';
+ *ped++ = key;
key = kdb_read_handle_escape(escape_data,
ped - escape_data);
- if (key > 0) {
- escape_data[0] = key;
- escape_data[1] = '\0';
- }
- if (key)
- escape_delay = 2;
- continue;
+ if (key < 0)
+ return '\e';
+ if (key == 0)
+ continue;
}
+
break; /* A key to process */
}
return key;