Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
152c12f5
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
161
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看板
提交
152c12f5
编写于
6月 30, 2005
作者:
D
Dmitry Torokhov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Input: clean up uinput driver (formatting, extra braces)
Signed-off-by:
N
Dmitry Torokhov
<
dtor@mail.ru
>
上级
9b4311ee
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
46 deletion
+35
-46
drivers/input/misc/uinput.c
drivers/input/misc/uinput.c
+35
-46
未找到文件。
drivers/input/misc/uinput.c
浏览文件 @
152c12f5
...
...
@@ -36,16 +36,6 @@
#include <linux/miscdevice.h>
#include <linux/uinput.h>
static
int
uinput_dev_open
(
struct
input_dev
*
dev
)
{
return
0
;
}
static
void
uinput_dev_close
(
struct
input_dev
*
dev
)
{
}
static
int
uinput_dev_event
(
struct
input_dev
*
dev
,
unsigned
int
type
,
unsigned
int
code
,
int
value
)
{
struct
uinput_device
*
udev
;
...
...
@@ -68,17 +58,20 @@ static int uinput_request_alloc_id(struct input_dev *dev, struct uinput_request
/* Atomically allocate an ID for the given request. Returns 0 on success. */
struct
uinput_device
*
udev
=
dev
->
private
;
int
id
;
int
err
=
-
1
;
down
(
&
udev
->
requests_sem
);
for
(
id
=
0
;
id
<
UINPUT_NUM_REQUESTS
;
id
++
)
for
(
id
=
0
;
id
<
UINPUT_NUM_REQUESTS
;
id
++
)
if
(
!
udev
->
requests
[
id
])
{
udev
->
requests
[
id
]
=
request
;
request
->
id
=
id
;
up
(
&
udev
->
requests_sem
)
;
return
0
;
err
=
0
;
break
;
}
up
(
&
udev
->
requests_sem
);
return
-
1
;
return
err
;
}
static
struct
uinput_request
*
uinput_request_find
(
struct
uinput_device
*
udev
,
int
id
)
...
...
@@ -101,7 +94,7 @@ static void uinput_request_init(struct input_dev *dev, struct uinput_request *re
/* Allocate an ID. If none are available right away, wait. */
request
->
retval
=
wait_event_interruptible
(
udev
->
requests_waitq
,
!
uinput_request_alloc_id
(
dev
,
request
));
!
uinput_request_alloc_id
(
dev
,
request
));
}
static
void
uinput_request_submit
(
struct
input_dev
*
dev
,
struct
uinput_request
*
request
)
...
...
@@ -159,32 +152,30 @@ static int uinput_create_device(struct uinput_device *udev)
return
-
EINVAL
;
}
udev
->
dev
->
open
=
uinput_dev_open
;
udev
->
dev
->
close
=
uinput_dev_close
;
udev
->
dev
->
event
=
uinput_dev_event
;
udev
->
dev
->
upload_effect
=
uinput_dev_upload_effect
;
udev
->
dev
->
erase_effect
=
uinput_dev_erase_effect
;
udev
->
dev
->
private
=
udev
;
init_waitqueue_head
(
&
(
udev
->
waitq
)
);
init_waitqueue_head
(
&
udev
->
waitq
);
input_register_device
(
udev
->
dev
);
set_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
);
set_bit
(
UIST_CREATED
,
&
udev
->
state
);
return
0
;
}
static
int
uinput_destroy_device
(
struct
uinput_device
*
udev
)
{
if
(
!
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
{
if
(
!
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
{
printk
(
KERN_WARNING
"%s: create the device first
\n
"
,
UINPUT_NAME
);
return
-
EINVAL
;
}
input_unregister_device
(
udev
->
dev
);
clear_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
);
clear_bit
(
UIST_CREATED
,
&
udev
->
state
);
return
0
;
}
...
...
@@ -253,15 +244,15 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
struct
uinput_user_dev
*
user_dev
;
struct
input_dev
*
dev
;
struct
uinput_device
*
udev
;
int
size
,
retval
;
int
size
;
int
retval
;
retval
=
count
;
udev
=
file
->
private_data
;
dev
=
udev
->
dev
;
user_dev
=
kmalloc
(
sizeof
(
*
user_dev
),
GFP_KERNEL
);
user_dev
=
kmalloc
(
sizeof
(
struct
uinput_
user_dev
),
GFP_KERNEL
);
if
(
!
user_dev
)
{
retval
=
-
ENOMEM
;
goto
exit
;
...
...
@@ -272,7 +263,7 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
goto
exit
;
}
if
(
NULL
!=
dev
->
name
)
if
(
dev
->
name
)
kfree
(
dev
->
name
);
size
=
strnlen
(
user_dev
->
name
,
UINPUT_MAX_NAME_SIZE
)
+
1
;
...
...
@@ -314,14 +305,13 @@ static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t
{
struct
uinput_device
*
udev
=
file
->
private_data
;
if
(
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
{
if
(
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
{
struct
input_event
ev
;
if
(
copy_from_user
(
&
ev
,
buffer
,
sizeof
(
struct
input_event
)))
return
-
EFAULT
;
input_event
(
udev
->
dev
,
ev
.
type
,
ev
.
code
,
ev
.
value
);
}
else
}
else
count
=
uinput_alloc_device
(
file
,
buffer
,
count
);
return
count
;
...
...
@@ -332,26 +322,24 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count,
struct
uinput_device
*
udev
=
file
->
private_data
;
int
retval
=
0
;
if
(
!
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
if
(
!
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
return
-
ENODEV
;
if
(
(
udev
->
head
==
udev
->
tail
)
&&
(
file
->
f_flags
&
O_NONBLOCK
))
if
(
udev
->
head
==
udev
->
tail
&&
(
file
->
f_flags
&
O_NONBLOCK
))
return
-
EAGAIN
;
retval
=
wait_event_interruptible
(
udev
->
waitq
,
(
udev
->
head
!=
udev
->
tail
)
||
!
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)));
udev
->
head
!=
udev
->
tail
||
!
test_bit
(
UIST_CREATED
,
&
udev
->
state
));
if
(
retval
)
return
retval
;
if
(
!
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
if
(
!
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
return
-
ENODEV
;
while
((
udev
->
head
!=
udev
->
tail
)
&&
(
retval
+
sizeof
(
struct
input_event
)
<=
count
))
{
if
(
copy_to_user
(
buffer
+
retval
,
&
(
udev
->
buff
[
udev
->
tail
]),
sizeof
(
struct
input_event
)))
return
-
EFAULT
;
if
(
copy_to_user
(
buffer
+
retval
,
&
udev
->
buff
[
udev
->
tail
],
sizeof
(
struct
input_event
)))
return
-
EFAULT
;
udev
->
tail
=
(
udev
->
tail
+
1
)
%
UINPUT_BUFFER_SIZE
;
retval
+=
sizeof
(
struct
input_event
);
}
...
...
@@ -373,12 +361,12 @@ static unsigned int uinput_poll(struct file *file, poll_table *wait)
static
int
uinput_burn_device
(
struct
uinput_device
*
udev
)
{
if
(
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
if
(
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
uinput_destroy_device
(
udev
);
if
(
NULL
!=
udev
->
dev
->
name
)
if
(
udev
->
dev
->
name
)
kfree
(
udev
->
dev
->
name
);
if
(
NULL
!=
udev
->
dev
->
phys
)
if
(
udev
->
dev
->
phys
)
kfree
(
udev
->
dev
->
phys
);
kfree
(
udev
->
dev
);
...
...
@@ -389,7 +377,8 @@ static int uinput_burn_device(struct uinput_device *udev)
static
int
uinput_close
(
struct
inode
*
inode
,
struct
file
*
file
)
{
return
uinput_burn_device
(
file
->
private_data
);
uinput_burn_device
(
file
->
private_data
);
return
0
;
}
static
int
uinput_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
...
...
@@ -415,7 +404,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
case
UI_SET_SNDBIT
:
case
UI_SET_FFBIT
:
case
UI_SET_PHYS
:
if
(
test_bit
(
UIST_CREATED
,
&
(
udev
->
state
)
))
if
(
test_bit
(
UIST_CREATED
,
&
udev
->
state
))
return
-
EINVAL
;
}
...
...
@@ -511,7 +500,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
udev
->
dev
->
phys
=
NULL
;
break
;
}
udev
->
dev
->
phys
[
length
-
1
]
=
'\0'
;
udev
->
dev
->
phys
[
length
-
1
]
=
'\0'
;
break
;
case
UI_BEGIN_FF_UPLOAD
:
...
...
@@ -520,7 +509,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break
;
}
req
=
uinput_request_find
(
udev
,
ff_up
.
request_id
);
if
(
!
(
req
&&
req
->
code
==
UI_FF_UPLOAD
&&
req
->
u
.
effect
))
{
if
(
!
(
req
&&
req
->
code
==
UI_FF_UPLOAD
&&
req
->
u
.
effect
))
{
retval
=
-
EINVAL
;
break
;
}
...
...
@@ -538,7 +527,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break
;
}
req
=
uinput_request_find
(
udev
,
ff_erase
.
request_id
);
if
(
!
(
req
&&
req
->
code
==
UI_FF_ERASE
))
{
if
(
!
(
req
&&
req
->
code
==
UI_FF_ERASE
))
{
retval
=
-
EINVAL
;
break
;
}
...
...
@@ -556,7 +545,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break
;
}
req
=
uinput_request_find
(
udev
,
ff_up
.
request_id
);
if
(
!
(
req
&&
req
->
code
==
UI_FF_UPLOAD
&&
req
->
u
.
effect
))
{
if
(
!
(
req
&&
req
->
code
==
UI_FF_UPLOAD
&&
req
->
u
.
effect
))
{
retval
=
-
EINVAL
;
break
;
}
...
...
@@ -572,7 +561,7 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
break
;
}
req
=
uinput_request_find
(
udev
,
ff_erase
.
request_id
);
if
(
!
(
req
&&
req
->
code
==
UI_FF_ERASE
))
{
if
(
!
(
req
&&
req
->
code
==
UI_FF_ERASE
))
{
retval
=
-
EINVAL
;
break
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录