Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
2d06236a
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 4 年多
通知
15
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看板
提交
2d06236a
编写于
6月 04, 2018
作者:
J
James Morris
浏览文件
操作
浏览文件
下载
差异文件
Merge tag 'tpmdd-next-20180602' of
git://git.infradead.org/users/jjs/linux-tpmdd
into next-tpm
tpmdd fixes for Linux 4.17 (just missed 4.17)
上级
82e5b032
3ab2011e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
19 addition
and
23 deletion
+19
-23
drivers/char/tpm/tpm-dev-common.c
drivers/char/tpm/tpm-dev-common.c
+18
-22
drivers/char/tpm/tpm-dev.h
drivers/char/tpm/tpm-dev.h
+1
-1
未找到文件。
drivers/char/tpm/tpm-dev-common.c
浏览文件 @
2d06236a
...
@@ -37,7 +37,7 @@ static void timeout_work(struct work_struct *work)
...
@@ -37,7 +37,7 @@ static void timeout_work(struct work_struct *work)
struct
file_priv
*
priv
=
container_of
(
work
,
struct
file_priv
,
work
);
struct
file_priv
*
priv
=
container_of
(
work
,
struct
file_priv
,
work
);
mutex_lock
(
&
priv
->
buffer_mutex
);
mutex_lock
(
&
priv
->
buffer_mutex
);
atomic_set
(
&
priv
->
data_pending
,
0
)
;
priv
->
data_pending
=
0
;
memset
(
priv
->
data_buffer
,
0
,
sizeof
(
priv
->
data_buffer
));
memset
(
priv
->
data_buffer
,
0
,
sizeof
(
priv
->
data_buffer
));
mutex_unlock
(
&
priv
->
buffer_mutex
);
mutex_unlock
(
&
priv
->
buffer_mutex
);
}
}
...
@@ -46,7 +46,6 @@ void tpm_common_open(struct file *file, struct tpm_chip *chip,
...
@@ -46,7 +46,6 @@ void tpm_common_open(struct file *file, struct tpm_chip *chip,
struct
file_priv
*
priv
)
struct
file_priv
*
priv
)
{
{
priv
->
chip
=
chip
;
priv
->
chip
=
chip
;
atomic_set
(
&
priv
->
data_pending
,
0
);
mutex_init
(
&
priv
->
buffer_mutex
);
mutex_init
(
&
priv
->
buffer_mutex
);
timer_setup
(
&
priv
->
user_read_timer
,
user_reader_timeout
,
0
);
timer_setup
(
&
priv
->
user_read_timer
,
user_reader_timeout
,
0
);
INIT_WORK
(
&
priv
->
work
,
timeout_work
);
INIT_WORK
(
&
priv
->
work
,
timeout_work
);
...
@@ -58,29 +57,24 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
...
@@ -58,29 +57,24 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
size_t
size
,
loff_t
*
off
)
size_t
size
,
loff_t
*
off
)
{
{
struct
file_priv
*
priv
=
file
->
private_data
;
struct
file_priv
*
priv
=
file
->
private_data
;
ssize_t
ret_size
;
ssize_t
ret_size
=
0
;
ssize_t
orig_ret_size
;
int
rc
;
int
rc
;
del_singleshot_timer_sync
(
&
priv
->
user_read_timer
);
del_singleshot_timer_sync
(
&
priv
->
user_read_timer
);
flush_work
(
&
priv
->
work
);
flush_work
(
&
priv
->
work
);
ret_size
=
atomic_read
(
&
priv
->
data_pending
);
if
(
ret_size
>
0
)
{
/* relay data */
orig_ret_size
=
ret_size
;
if
(
size
<
ret_size
)
ret_size
=
size
;
mutex_lock
(
&
priv
->
buffer_mutex
);
mutex_lock
(
&
priv
->
buffer_mutex
);
if
(
priv
->
data_pending
)
{
ret_size
=
min_t
(
ssize_t
,
size
,
priv
->
data_pending
);
rc
=
copy_to_user
(
buf
,
priv
->
data_buffer
,
ret_size
);
rc
=
copy_to_user
(
buf
,
priv
->
data_buffer
,
ret_size
);
memset
(
priv
->
data_buffer
,
0
,
orig_ret_size
);
memset
(
priv
->
data_buffer
,
0
,
priv
->
data_pending
);
if
(
rc
)
if
(
rc
)
ret_size
=
-
EFAULT
;
ret_size
=
-
EFAULT
;
mutex_unlock
(
&
priv
->
buffer_mutex
)
;
priv
->
data_pending
=
0
;
}
}
atomic_set
(
&
priv
->
data_pending
,
0
);
mutex_unlock
(
&
priv
->
buffer_mutex
);
return
ret_size
;
return
ret_size
;
}
}
...
@@ -91,17 +85,19 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
...
@@ -91,17 +85,19 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
size_t
in_size
=
size
;
size_t
in_size
=
size
;
ssize_t
out_size
;
ssize_t
out_size
;
if
(
in_size
>
TPM_BUFSIZE
)
return
-
E2BIG
;
mutex_lock
(
&
priv
->
buffer_mutex
);
/* Cannot perform a write until the read has cleared either via
/* Cannot perform a write until the read has cleared either via
* tpm_read or a user_read_timer timeout. This also prevents split
* tpm_read or a user_read_timer timeout. This also prevents split
* buffered writes from blocking here.
* buffered writes from blocking here.
*/
*/
if
(
atomic_read
(
&
priv
->
data_pending
)
!=
0
)
if
(
priv
->
data_pending
!=
0
)
{
mutex_unlock
(
&
priv
->
buffer_mutex
);
return
-
EBUSY
;
return
-
EBUSY
;
}
if
(
in_size
>
TPM_BUFSIZE
)
return
-
E2BIG
;
mutex_lock
(
&
priv
->
buffer_mutex
);
if
(
copy_from_user
if
(
copy_from_user
(
priv
->
data_buffer
,
(
void
__user
*
)
buf
,
in_size
))
{
(
priv
->
data_buffer
,
(
void
__user
*
)
buf
,
in_size
))
{
...
@@ -132,7 +128,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
...
@@ -132,7 +128,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
return
out_size
;
return
out_size
;
}
}
atomic_set
(
&
priv
->
data_pending
,
out_size
)
;
priv
->
data_pending
=
out_size
;
mutex_unlock
(
&
priv
->
buffer_mutex
);
mutex_unlock
(
&
priv
->
buffer_mutex
);
/* Set a timeout by which the reader must come claim the result */
/* Set a timeout by which the reader must come claim the result */
...
@@ -149,5 +145,5 @@ void tpm_common_release(struct file *file, struct file_priv *priv)
...
@@ -149,5 +145,5 @@ void tpm_common_release(struct file *file, struct file_priv *priv)
del_singleshot_timer_sync
(
&
priv
->
user_read_timer
);
del_singleshot_timer_sync
(
&
priv
->
user_read_timer
);
flush_work
(
&
priv
->
work
);
flush_work
(
&
priv
->
work
);
file
->
private_data
=
NULL
;
file
->
private_data
=
NULL
;
atomic_set
(
&
priv
->
data_pending
,
0
)
;
priv
->
data_pending
=
0
;
}
}
drivers/char/tpm/tpm-dev.h
浏览文件 @
2d06236a
...
@@ -8,7 +8,7 @@ struct file_priv {
...
@@ -8,7 +8,7 @@ struct file_priv {
struct
tpm_chip
*
chip
;
struct
tpm_chip
*
chip
;
/* Data passed to and from the tpm via the read/write calls */
/* Data passed to and from the tpm via the read/write calls */
atomic
_t
data_pending
;
size
_t
data_pending
;
struct
mutex
buffer_mutex
;
struct
mutex
buffer_mutex
;
struct
timer_list
user_read_timer
;
/* user needs to claim result */
struct
timer_list
user_read_timer
;
/* user needs to claim result */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录