Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
905ab9d1
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
905ab9d1
编写于
6月 01, 2005
作者:
D
Dmitry Torokhov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Input: cleanup ps2_command() timeout handling in libps2.
Signed-off-by:
N
Dmitry Torokhov
<
dtor@mail.ru
>
上级
c611763d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
62 addition
and
28 deletion
+62
-28
drivers/input/serio/libps2.c
drivers/input/serio/libps2.c
+62
-28
未找到文件。
drivers/input/serio/libps2.c
浏览文件 @
905ab9d1
...
...
@@ -97,6 +97,66 @@ void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout)
up
(
&
ps2dev
->
cmd_sem
);
}
/*
* ps2_is_keyboard_id() checks received ID byte against the list of
* known keyboard IDs.
*/
static
inline
int
ps2_is_keyboard_id
(
char
id_byte
)
{
static
char
keyboard_ids
[]
=
{
0xab
,
/* Regular keyboards */
0xac
,
/* NCD Sun keyboard */
0x2b
,
/* Trust keyboard, translated */
0x5d
,
/* Trust keyboard */
0x60
,
/* NMB SGI keyboard, translated */
0x47
,
/* NMB SGI keyboard */
};
return
memchr
(
keyboard_ids
,
id_byte
,
sizeof
(
keyboard_ids
))
!=
NULL
;
}
/*
* ps2_adjust_timeout() is called after receiving 1st byte of command
* response and tries to reduce remaining timeout to speed up command
* completion.
*/
static
int
ps2_adjust_timeout
(
struct
ps2dev
*
ps2dev
,
int
command
,
int
timeout
)
{
switch
(
command
)
{
case
PS2_CMD_RESET_BAT
:
/*
* Device has sent the first response byte after
* reset command, reset is thus done, so we can
* shorten the timeout.
* The next byte will come soon (keyboard) or not
* at all (mouse).
*/
if
(
timeout
>
msecs_to_jiffies
(
100
))
timeout
=
msecs_to_jiffies
(
100
);
break
;
case
PS2_CMD_GETID
:
/*
* If device behind the port is not a keyboard there
* won't be 2nd byte of ID response.
*/
if
(
!
ps2_is_keyboard_id
(
ps2dev
->
cmdbuf
[
1
]))
{
serio_pause_rx
(
ps2dev
->
serio
);
ps2dev
->
flags
=
ps2dev
->
cmdcnt
=
0
;
serio_continue_rx
(
ps2dev
->
serio
);
timeout
=
0
;
}
break
;
default:
break
;
}
return
timeout
;
}
/*
* ps2_command() sends a command and its parameters to the mouse,
* then waits for the response and puts it in the param array.
...
...
@@ -150,33 +210,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
if
(
ps2dev
->
cmdcnt
&&
timeout
>
0
)
{
if
(
command
==
PS2_CMD_RESET_BAT
&&
timeout
>
msecs_to_jiffies
(
100
))
{
/*
* Device has sent the first response byte
* after a reset command, reset is thus done,
* shorten the timeout. The next byte will come
* soon (keyboard) or not at all (mouse).
*/
timeout
=
msecs_to_jiffies
(
100
);
}
if
(
command
==
PS2_CMD_GETID
&&
ps2dev
->
cmdbuf
[
receive
-
1
]
!=
0xab
&&
/* Regular keyboards */
ps2dev
->
cmdbuf
[
receive
-
1
]
!=
0xac
&&
/* NCD Sun keyboard */
ps2dev
->
cmdbuf
[
receive
-
1
]
!=
0x2b
&&
/* Trust keyboard, translated */
ps2dev
->
cmdbuf
[
receive
-
1
]
!=
0x5d
&&
/* Trust keyboard */
ps2dev
->
cmdbuf
[
receive
-
1
]
!=
0x60
&&
/* NMB SGI keyboard, translated */
ps2dev
->
cmdbuf
[
receive
-
1
]
!=
0x47
)
{
/* NMB SGI keyboard */
/*
* Device behind the port is not a keyboard
* so we don't need to wait for the 2nd byte
* of ID response.
*/
serio_pause_rx
(
ps2dev
->
serio
);
ps2dev
->
flags
=
ps2dev
->
cmdcnt
=
0
;
serio_continue_rx
(
ps2dev
->
serio
);
}
timeout
=
ps2_adjust_timeout
(
ps2dev
,
command
,
timeout
);
wait_event_timeout
(
ps2dev
->
wait
,
!
(
ps2dev
->
flags
&
PS2_FLAG_CMD
),
timeout
);
}
...
...
@@ -190,7 +224,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
rc
=
0
;
out:
out:
serio_pause_rx
(
ps2dev
->
serio
);
ps2dev
->
flags
=
0
;
serio_continue_rx
(
ps2dev
->
serio
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录