提交 23475408 编写于 作者: J Joe Perches 提交者: Linus Torvalds

printk: use pointer for console_cmdline indexing

Make the code a bit more compact by always using a pointer for the active
console_cmdline.

Move overly indented code to correct indent level.
Signed-off-by: NJoe Perches <joe@perches.com>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Ming Lei <ming.lei@canonical.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 bbeddf52
...@@ -1756,18 +1756,19 @@ static int __add_preferred_console(char *name, int idx, char *options, ...@@ -1756,18 +1756,19 @@ static int __add_preferred_console(char *name, int idx, char *options,
* See if this tty is not yet registered, and * See if this tty is not yet registered, and
* if we have a slot free. * if we have a slot free.
*/ */
for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++) for (i = 0, c = console_cmdline;
if (strcmp(console_cmdline[i].name, name) == 0 && i < MAX_CMDLINECONSOLES && c->name[0];
console_cmdline[i].index == idx) { i++, c++) {
if (!brl_options) if (strcmp(c->name, name) == 0 && c->index == idx) {
selected_console = i; if (!brl_options)
return 0; selected_console = i;
return 0;
} }
}
if (i == MAX_CMDLINECONSOLES) if (i == MAX_CMDLINECONSOLES)
return -E2BIG; return -E2BIG;
if (!brl_options) if (!brl_options)
selected_console = i; selected_console = i;
c = &console_cmdline[i];
strlcpy(c->name, name, sizeof(c->name)); strlcpy(c->name, name, sizeof(c->name));
c->options = options; c->options = options;
braille_set_options(c, brl_options); braille_set_options(c, brl_options);
...@@ -1840,15 +1841,15 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha ...@@ -1840,15 +1841,15 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha
struct console_cmdline *c; struct console_cmdline *c;
int i; int i;
for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++) for (i = 0, c = console_cmdline;
if (strcmp(console_cmdline[i].name, name) == 0 && i < MAX_CMDLINECONSOLES && c->name[0];
console_cmdline[i].index == idx) { i++, c++)
c = &console_cmdline[i]; if (strcmp(c->name, name) == 0 && c->index == idx) {
strlcpy(c->name, name_new, sizeof(c->name)); strlcpy(c->name, name_new, sizeof(c->name));
c->name[sizeof(c->name) - 1] = 0; c->name[sizeof(c->name) - 1] = 0;
c->options = options; c->options = options;
c->index = idx_new; c->index = idx_new;
return i; return i;
} }
/* not found */ /* not found */
return -1; return -1;
...@@ -2223,6 +2224,7 @@ void register_console(struct console *newcon) ...@@ -2223,6 +2224,7 @@ void register_console(struct console *newcon)
int i; int i;
unsigned long flags; unsigned long flags;
struct console *bcon = NULL; struct console *bcon = NULL;
struct console_cmdline *c;
/* /*
* before we register a new CON_BOOT console, make sure we don't * before we register a new CON_BOOT console, make sure we don't
...@@ -2270,24 +2272,25 @@ void register_console(struct console *newcon) ...@@ -2270,24 +2272,25 @@ void register_console(struct console *newcon)
* See if this console matches one we selected on * See if this console matches one we selected on
* the command line. * the command line.
*/ */
for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; for (i = 0, c = console_cmdline;
i++) { i < MAX_CMDLINECONSOLES && c->name[0];
if (strcmp(console_cmdline[i].name, newcon->name) != 0) i++, c++) {
if (strcmp(c->name, newcon->name) != 0)
continue; continue;
if (newcon->index >= 0 && if (newcon->index >= 0 &&
newcon->index != console_cmdline[i].index) newcon->index != c->index)
continue; continue;
if (newcon->index < 0) if (newcon->index < 0)
newcon->index = console_cmdline[i].index; newcon->index = c->index;
if (_braille_register_console(newcon, &console_cmdline[i])) if (_braille_register_console(newcon, c))
return; return;
if (newcon->setup && if (newcon->setup &&
newcon->setup(newcon, console_cmdline[i].options) != 0) newcon->setup(newcon, console_cmdline[i].options) != 0)
break; break;
newcon->flags |= CON_ENABLED; newcon->flags |= CON_ENABLED;
newcon->index = console_cmdline[i].index; newcon->index = c->index;
if (i == selected_console) { if (i == selected_console) {
newcon->flags |= CON_CONSDEV; newcon->flags |= CON_CONSDEV;
preferred_console = selected_console; preferred_console = selected_console;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册