Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
6a0af9fc
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6a0af9fc
编写于
6月 01, 2020
作者:
P
Petr Mladek
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'for-5.7-preferred-console' into for-linus
上级
e8cc2b97
33225d7b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
80 addition
and
45 deletion
+80
-45
include/linux/console.h
include/linux/console.h
+1
-1
kernel/printk/console_cmdline.h
kernel/printk/console_cmdline.h
+1
-0
kernel/printk/printk.c
kernel/printk/printk.c
+78
-44
未找到文件。
include/linux/console.h
浏览文件 @
6a0af9fc
...
...
@@ -135,7 +135,7 @@ static inline int con_debug_leave(void)
*/
#define CON_PRINTBUFFER (1)
#define CON_CONSDEV (2)
/*
Last on the command lin
e */
#define CON_CONSDEV (2)
/*
Preferred console, /dev/consol
e */
#define CON_ENABLED (4)
#define CON_BOOT (8)
#define CON_ANYTIME (16)
/* Safe to call when cpu is offline */
...
...
kernel/printk/console_cmdline.h
浏览文件 @
6a0af9fc
...
...
@@ -6,6 +6,7 @@ struct console_cmdline
{
char
name
[
16
];
/* Name of the driver */
int
index
;
/* Minor dev. to use */
bool
user_specified
;
/* Specified by command line vs. platform */
char
*
options
;
/* Options for the driver */
#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
char
*
brl_options
;
/* Options for braille driver */
...
...
kernel/printk/printk.c
浏览文件 @
6a0af9fc
...
...
@@ -280,6 +280,7 @@ static struct console *exclusive_console;
static
struct
console_cmdline
console_cmdline
[
MAX_CMDLINECONSOLES
];
static
int
preferred_console
=
-
1
;
static
bool
has_preferred_console
;
int
console_set_on_cmdline
;
EXPORT_SYMBOL
(
console_set_on_cmdline
);
...
...
@@ -2115,7 +2116,7 @@ asmlinkage __visible void early_printk(const char *fmt, ...)
#endif
static
int
__add_preferred_console
(
char
*
name
,
int
idx
,
char
*
options
,
char
*
brl_options
)
char
*
brl_options
,
bool
user_specified
)
{
struct
console_cmdline
*
c
;
int
i
;
...
...
@@ -2130,6 +2131,8 @@ static int __add_preferred_console(char *name, int idx, char *options,
if
(
strcmp
(
c
->
name
,
name
)
==
0
&&
c
->
index
==
idx
)
{
if
(
!
brl_options
)
preferred_console
=
i
;
if
(
user_specified
)
c
->
user_specified
=
true
;
return
0
;
}
}
...
...
@@ -2139,6 +2142,7 @@ static int __add_preferred_console(char *name, int idx, char *options,
preferred_console
=
i
;
strlcpy
(
c
->
name
,
name
,
sizeof
(
c
->
name
));
c
->
options
=
options
;
c
->
user_specified
=
user_specified
;
braille_set_options
(
c
,
brl_options
);
c
->
index
=
idx
;
...
...
@@ -2193,7 +2197,7 @@ static int __init console_setup(char *str)
idx
=
simple_strtoul
(
s
,
NULL
,
10
);
*
s
=
0
;
__add_preferred_console
(
buf
,
idx
,
options
,
brl_options
);
__add_preferred_console
(
buf
,
idx
,
options
,
brl_options
,
true
);
console_set_on_cmdline
=
1
;
return
1
;
}
...
...
@@ -2214,7 +2218,7 @@ __setup("console=", console_setup);
*/
int
add_preferred_console
(
char
*
name
,
int
idx
,
char
*
options
)
{
return
__add_preferred_console
(
name
,
idx
,
options
,
NULL
);
return
__add_preferred_console
(
name
,
idx
,
options
,
NULL
,
false
);
}
bool
console_suspend_enabled
=
true
;
...
...
@@ -2626,6 +2630,63 @@ static int __init keep_bootcon_setup(char *str)
early_param
(
"keep_bootcon"
,
keep_bootcon_setup
);
/*
* This is called by register_console() to try to match
* the newly registered console with any of the ones selected
* by either the command line or add_preferred_console() and
* setup/enable it.
*
* Care need to be taken with consoles that are statically
* enabled such as netconsole
*/
static
int
try_enable_new_console
(
struct
console
*
newcon
,
bool
user_specified
)
{
struct
console_cmdline
*
c
;
int
i
;
for
(
i
=
0
,
c
=
console_cmdline
;
i
<
MAX_CMDLINECONSOLES
&&
c
->
name
[
0
];
i
++
,
c
++
)
{
if
(
c
->
user_specified
!=
user_specified
)
continue
;
if
(
!
newcon
->
match
||
newcon
->
match
(
newcon
,
c
->
name
,
c
->
index
,
c
->
options
)
!=
0
)
{
/* default matching */
BUILD_BUG_ON
(
sizeof
(
c
->
name
)
!=
sizeof
(
newcon
->
name
));
if
(
strcmp
(
c
->
name
,
newcon
->
name
)
!=
0
)
continue
;
if
(
newcon
->
index
>=
0
&&
newcon
->
index
!=
c
->
index
)
continue
;
if
(
newcon
->
index
<
0
)
newcon
->
index
=
c
->
index
;
if
(
_braille_register_console
(
newcon
,
c
))
return
0
;
if
(
newcon
->
setup
&&
newcon
->
setup
(
newcon
,
c
->
options
)
!=
0
)
return
-
EIO
;
}
newcon
->
flags
|=
CON_ENABLED
;
if
(
i
==
preferred_console
)
{
newcon
->
flags
|=
CON_CONSDEV
;
has_preferred_console
=
true
;
}
return
0
;
}
/*
* Some consoles, such as pstore and netconsole, can be enabled even
* without matching. Accept the pre-enabled consoles only when match()
* and setup() had a change to be called.
*/
if
(
newcon
->
flags
&
CON_ENABLED
&&
c
->
user_specified
==
user_specified
)
return
0
;
return
-
ENOENT
;
}
/*
* The console driver calls this routine during kernel initialization
* to register the console printing procedure with printk() and to
...
...
@@ -2647,11 +2708,9 @@ early_param("keep_bootcon", keep_bootcon_setup);
*/
void
register_console
(
struct
console
*
newcon
)
{
int
i
;
unsigned
long
flags
;
struct
console
*
bcon
=
NULL
;
struct
console_cmdline
*
c
;
static
bool
has_preferred
;
int
err
;
if
(
console_drivers
)
for_each_console
(
bcon
)
...
...
@@ -2678,15 +2737,15 @@ void register_console(struct console *newcon)
if
(
console_drivers
&&
console_drivers
->
flags
&
CON_BOOT
)
bcon
=
console_drivers
;
if
(
!
has_preferred
||
bcon
||
!
console_drivers
)
has_preferred
=
preferred_console
>=
0
;
if
(
!
has_preferred
_console
||
bcon
||
!
console_drivers
)
has_preferred
_console
=
preferred_console
>=
0
;
/*
* See if we want to use this console driver. If we
* didn't select a console we take the first one
* that registers here.
*/
if
(
!
has_preferred
)
{
if
(
!
has_preferred
_console
)
{
if
(
newcon
->
index
<
0
)
newcon
->
index
=
0
;
if
(
newcon
->
setup
==
NULL
||
...
...
@@ -2694,47 +2753,20 @@ void register_console(struct console *newcon)
newcon
->
flags
|=
CON_ENABLED
;
if
(
newcon
->
device
)
{
newcon
->
flags
|=
CON_CONSDEV
;
has_preferred
=
true
;
has_preferred
_console
=
true
;
}
}
}
/*
* See if this console matches one we selected on
* the command line.
*/
for
(
i
=
0
,
c
=
console_cmdline
;
i
<
MAX_CMDLINECONSOLES
&&
c
->
name
[
0
];
i
++
,
c
++
)
{
if
(
!
newcon
->
match
||
newcon
->
match
(
newcon
,
c
->
name
,
c
->
index
,
c
->
options
)
!=
0
)
{
/* default matching */
BUILD_BUG_ON
(
sizeof
(
c
->
name
)
!=
sizeof
(
newcon
->
name
));
if
(
strcmp
(
c
->
name
,
newcon
->
name
)
!=
0
)
continue
;
if
(
newcon
->
index
>=
0
&&
newcon
->
index
!=
c
->
index
)
continue
;
if
(
newcon
->
index
<
0
)
newcon
->
index
=
c
->
index
;
if
(
_braille_register_console
(
newcon
,
c
))
return
;
if
(
newcon
->
setup
&&
newcon
->
setup
(
newcon
,
c
->
options
)
!=
0
)
break
;
}
/* See if this console matches one we selected on the command line */
err
=
try_enable_new_console
(
newcon
,
true
);
newcon
->
flags
|=
CON_ENABLED
;
if
(
i
==
preferred_console
)
{
newcon
->
flags
|=
CON_CONSDEV
;
has_preferred
=
true
;
}
break
;
}
/* If not, try to match against the platform default(s) */
if
(
err
==
-
ENOENT
)
err
=
try_enable_new_console
(
newcon
,
false
);
if
(
!
(
newcon
->
flags
&
CON_ENABLED
))
/* printk() messages are not printed to the Braille console. */
if
(
err
||
newcon
->
flags
&
CON_BRL
)
return
;
/*
...
...
@@ -2756,6 +2788,8 @@ void register_console(struct console *newcon)
console_drivers
=
newcon
;
if
(
newcon
->
next
)
newcon
->
next
->
flags
&=
~
CON_CONSDEV
;
/* Ensure this flag is always set for the head of the list */
newcon
->
flags
|=
CON_CONSDEV
;
}
else
{
newcon
->
next
=
console_drivers
->
next
;
console_drivers
->
next
=
newcon
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录