Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
79e0273d
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 3 年多
通知
13
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
79e0273d
编写于
6月 04, 2012
作者:
R
Richard Weinberger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
um: fully use tty_port
... use all tty_port helpers Signed-off-by:
N
Richard Weinberger
<
richard@nod.at
>
上级
df7b86f3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
78 deletion
+65
-78
arch/um/drivers/line.c
arch/um/drivers/line.c
+45
-57
arch/um/drivers/line.h
arch/um/drivers/line.h
+5
-1
arch/um/drivers/ssl.c
arch/um/drivers/ssl.c
+6
-9
arch/um/drivers/stdio_console.c
arch/um/drivers/stdio_console.c
+9
-11
未找到文件。
arch/um/drivers/line.c
浏览文件 @
79e0273d
...
...
@@ -296,43 +296,14 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
return
err
;
}
/*
* Normally, a driver like this can rely mostly on the tty layer
* locking, particularly when it comes to the driver structure.
* However, in this case, mconsole requests can come in "from the
* side", and race with opens and closes.
*
* mconsole config requests will want to be sure the device isn't in
* use, and get_config, open, and close will want a stable
* configuration. The checking and modification of the configuration
* is done under a spinlock. Checking whether the device is in use is
* line->tty->count > 1, also under the spinlock.
*
* line->count serves to decide whether the device should be enabled or
* disabled on the host. If it's equal to 0, then we are doing the
* first open or last close. Otherwise, open and close just return.
*/
int
line_open
(
struct
line
*
lines
,
struct
tty_struct
*
tty
)
static
int
line_activate
(
struct
tty_port
*
port
,
struct
tty_struct
*
tty
)
{
struct
line
*
line
=
&
lines
[
tty
->
index
];
int
err
=
-
ENODEV
;
mutex_lock
(
&
line
->
count_lock
);
if
(
!
line
->
valid
)
goto
out_unlock
;
err
=
0
;
if
(
line
->
port
.
count
++
)
goto
out_unlock
;
BUG_ON
(
tty
->
driver_data
);
tty
->
driver_data
=
line
;
tty_port_tty_set
(
&
line
->
port
,
tty
);
int
ret
;
struct
line
*
line
=
tty
->
driver_data
;
err
=
enable_chan
(
line
);
if
(
err
)
/* line_close() will be called by our caller */
goto
out_unlock
;
ret
=
enable_chan
(
line
);
if
(
ret
)
return
ret
;
if
(
!
line
->
sigio
)
{
chan_enable_winch
(
line
->
chan_out
,
tty
);
...
...
@@ -340,44 +311,60 @@ int line_open(struct line *lines, struct tty_struct *tty)
}
chan_window_size
(
line
,
&
tty
->
winsize
.
ws_row
,
&
tty
->
winsize
.
ws_col
);
out_unlock:
mutex_unlock
(
&
line
->
count_lock
);
return
err
;
&
tty
->
winsize
.
ws_col
);
return
0
;
}
static
void
unregister_winch
(
struct
tty_struct
*
tty
);
static
const
struct
tty_port_operations
line_port_ops
=
{
.
activate
=
line_activate
,
};
void
line_close
(
struct
tty_struct
*
tty
,
struct
file
*
filp
)
int
line_open
(
struct
tty_struct
*
tty
,
struct
file
*
filp
)
{
struct
line
*
line
=
tty
->
driver_data
;
/*
* If line_open fails (and tty->driver_data is never set),
* tty_open will call line_close. So just return in this case.
*/
if
(
line
==
NULL
)
return
;
return
tty_port_open
(
&
line
->
port
,
tty
,
filp
);
}
/* We ignore the error anyway! */
flush_buffer
(
line
);
int
line_install
(
struct
tty_driver
*
driver
,
struct
tty_struct
*
tty
,
struct
line
*
line
)
{
int
ret
;
mutex_lock
(
&
line
->
count_lock
);
BUG_ON
(
!
line
->
valid
);
ret
=
tty_standard_install
(
driver
,
tty
);
if
(
ret
)
return
ret
;
tty
->
driver_data
=
line
;
if
(
--
line
->
port
.
count
)
goto
out_unlock
;
return
0
;
}
static
void
unregister_winch
(
struct
tty_struct
*
tty
);
tty_port_tty_set
(
&
line
->
port
,
NULL
);
tty
->
driver_data
=
NULL
;
void
line_cleanup
(
struct
tty_struct
*
tty
)
{
struct
line
*
line
=
tty
->
driver_data
;
if
(
line
->
sigio
)
{
unregister_winch
(
tty
);
line
->
sigio
=
0
;
}
}
out_unlock:
mutex_unlock
(
&
line
->
count_lock
);
void
line_close
(
struct
tty_struct
*
tty
,
struct
file
*
filp
)
{
struct
line
*
line
=
tty
->
driver_data
;
tty_port_close
(
&
line
->
port
,
tty
,
filp
);
}
void
line_hangup
(
struct
tty_struct
*
tty
)
{
struct
line
*
line
=
tty
->
driver_data
;
tty_port_hangup
(
&
line
->
port
);
}
void
close_lines
(
struct
line
*
lines
,
int
nlines
)
...
...
@@ -589,6 +576,7 @@ int register_lines(struct line_driver *line_driver,
for
(
i
=
0
;
i
<
nlines
;
i
++
)
{
tty_port_init
(
&
lines
[
i
].
port
);
lines
[
i
].
port
.
ops
=
&
line_port_ops
;
spin_lock_init
(
&
lines
[
i
].
lock
);
mutex_init
(
&
lines
[
i
].
count_lock
);
lines
[
i
].
driver
=
line_driver
;
...
...
arch/um/drivers/line.h
浏览文件 @
79e0273d
...
...
@@ -58,7 +58,11 @@ struct line {
};
extern
void
line_close
(
struct
tty_struct
*
tty
,
struct
file
*
filp
);
extern
int
line_open
(
struct
line
*
lines
,
struct
tty_struct
*
tty
);
extern
int
line_open
(
struct
tty_struct
*
tty
,
struct
file
*
filp
);
extern
int
line_install
(
struct
tty_driver
*
driver
,
struct
tty_struct
*
tty
,
struct
line
*
line
);
extern
void
line_cleanup
(
struct
tty_struct
*
tty
);
extern
void
line_hangup
(
struct
tty_struct
*
tty
);
extern
int
line_setup
(
char
**
conf
,
unsigned
nlines
,
char
**
def
,
char
*
init
,
char
*
name
);
extern
int
line_write
(
struct
tty_struct
*
tty
,
const
unsigned
char
*
buf
,
...
...
arch/um/drivers/ssl.c
浏览文件 @
79e0273d
...
...
@@ -87,19 +87,13 @@ static int ssl_remove(int n, char **error_out)
error_out
);
}
static
int
ssl_
open
(
struct
tty_struct
*
tty
,
struct
file
*
filp
)
static
int
ssl_
install
(
struct
tty_driver
*
driver
,
struct
tty_struct
*
tty
)
{
int
err
=
line_open
(
serial_lines
,
tty
);
if
(
err
)
printk
(
KERN_ERR
"Failed to open serial line %d, err = %d
\n
"
,
tty
->
index
,
err
);
return
err
;
return
line_install
(
driver
,
tty
,
&
serial_lines
[
tty
->
index
]);
}
static
const
struct
tty_operations
ssl_ops
=
{
.
open
=
ssl
_open
,
.
open
=
line
_open
,
.
close
=
line_close
,
.
write
=
line_write
,
.
put_char
=
line_put_char
,
...
...
@@ -110,6 +104,9 @@ static const struct tty_operations ssl_ops = {
.
set_termios
=
line_set_termios
,
.
throttle
=
line_throttle
,
.
unthrottle
=
line_unthrottle
,
.
install
=
ssl_install
,
.
cleanup
=
line_cleanup
,
.
hangup
=
line_hangup
,
};
/* Changed by ssl_init and referenced by ssl_exit, which are both serialized
...
...
arch/um/drivers/stdio_console.c
浏览文件 @
79e0273d
...
...
@@ -89,21 +89,17 @@ static int con_remove(int n, char **error_out)
return
line_remove
(
vts
,
ARRAY_SIZE
(
vts
),
n
,
error_out
);
}
static
int
con_open
(
struct
tty_struct
*
tty
,
struct
file
*
filp
)
{
int
err
=
line_open
(
vts
,
tty
);
if
(
err
)
printk
(
KERN_ERR
"Failed to open console %d, err = %d
\n
"
,
tty
->
index
,
err
);
return
err
;
}
/* Set in an initcall, checked in an exitcall */
static
int
con_init_done
=
0
;
static
int
con_install
(
struct
tty_driver
*
driver
,
struct
tty_struct
*
tty
)
{
return
line_install
(
driver
,
tty
,
&
vts
[
tty
->
index
]);
}
static
const
struct
tty_operations
console_ops
=
{
.
open
=
con_open
,
.
open
=
line_open
,
.
install
=
con_install
,
.
close
=
line_close
,
.
write
=
line_write
,
.
put_char
=
line_put_char
,
...
...
@@ -114,6 +110,8 @@ static const struct tty_operations console_ops = {
.
set_termios
=
line_set_termios
,
.
throttle
=
line_throttle
,
.
unthrottle
=
line_unthrottle
,
.
cleanup
=
line_cleanup
,
.
hangup
=
line_hangup
,
};
static
void
uml_console_write
(
struct
console
*
console
,
const
char
*
string
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录