Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
826d5982
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
826d5982
编写于
7月 19, 2006
作者:
D
Dmitry Torokhov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Input: hiddev - use standard list implementation
Fixes Coverity #id 303 Signed-off-by:
N
Dmitry Torokhov
<
dtor@mail.ru
>
上级
b6d786db
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
34 deletion
+38
-34
drivers/usb/input/hiddev.c
drivers/usb/input/hiddev.c
+38
-34
未找到文件。
drivers/usb/input/hiddev.c
浏览文件 @
826d5982
...
...
@@ -49,7 +49,7 @@ struct hiddev {
int
open
;
wait_queue_head_t
wait
;
struct
hid_device
*
hid
;
struct
hiddev_list
*
list
;
struct
list_head
list
;
};
struct
hiddev_list
{
...
...
@@ -59,7 +59,7 @@ struct hiddev_list {
unsigned
flags
;
struct
fasync_struct
*
fasync
;
struct
hiddev
*
hiddev
;
struct
hiddev_list
*
next
;
struct
list_head
node
;
};
static
struct
hiddev
*
hiddev_table
[
HIDDEV_MINORS
];
...
...
@@ -73,12 +73,15 @@ static struct hiddev *hiddev_table[HIDDEV_MINORS];
static
struct
hid_report
*
hiddev_lookup_report
(
struct
hid_device
*
hid
,
struct
hiddev_report_info
*
rinfo
)
{
unsigned
flags
=
rinfo
->
report_id
&
~
HID_REPORT_ID_MASK
;
unsigned
int
flags
=
rinfo
->
report_id
&
~
HID_REPORT_ID_MASK
;
unsigned
int
rid
=
rinfo
->
report_id
&
HID_REPORT_ID_MASK
;
struct
hid_report_enum
*
report_enum
;
struct
hid_report
*
report
;
struct
list_head
*
list
;
if
(
rinfo
->
report_type
<
HID_REPORT_TYPE_MIN
||
rinfo
->
report_type
>
HID_REPORT_TYPE_MAX
)
return
NULL
;
rinfo
->
report_type
>
HID_REPORT_TYPE_MAX
)
return
NULL
;
report_enum
=
hid
->
report_enum
+
(
rinfo
->
report_type
-
HID_REPORT_TYPE_MIN
);
...
...
@@ -88,21 +91,25 @@ hiddev_lookup_report(struct hid_device *hid, struct hiddev_report_info *rinfo)
break
;
case
HID_REPORT_ID_FIRST
:
list
=
report_enum
->
report_list
.
next
;
if
(
list
==
&
report_enum
->
report_list
)
if
(
list_empty
(
&
report_enum
->
report_list
))
return
NULL
;
rinfo
->
report_id
=
((
struct
hid_report
*
)
list
)
->
id
;
list
=
report_enum
->
report_list
.
next
;
report
=
list_entry
(
list
,
struct
hid_report
,
list
);
rinfo
->
report_id
=
report
->
id
;
break
;
case
HID_REPORT_ID_NEXT
:
list
=
(
struct
list_head
*
)
report_enum
->
report_id_hash
[
rinfo
->
report_id
&
HID_REPORT_ID_MASK
];
if
(
list
==
NULL
)
report
=
report_enum
->
report_id_hash
[
rid
];
if
(
!
report
)
return
NULL
;
list
=
list
->
next
;
list
=
report
->
list
.
next
;
if
(
list
==
&
report_enum
->
report_list
)
return
NULL
;
rinfo
->
report_id
=
((
struct
hid_report
*
)
list
)
->
id
;
report
=
list_entry
(
list
,
struct
hid_report
,
list
);
rinfo
->
report_id
=
report
->
id
;
break
;
default:
...
...
@@ -125,12 +132,13 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)
struct
hid_field
*
field
;
if
(
uref
->
report_type
<
HID_REPORT_TYPE_MIN
||
uref
->
report_type
>
HID_REPORT_TYPE_MAX
)
return
NULL
;
uref
->
report_type
>
HID_REPORT_TYPE_MAX
)
return
NULL
;
report_enum
=
hid
->
report_enum
+
(
uref
->
report_type
-
HID_REPORT_TYPE_MIN
);
list_for_each_entry
(
report
,
&
report_enum
->
report_list
,
list
)
list_for_each_entry
(
report
,
&
report_enum
->
report_list
,
list
)
{
for
(
i
=
0
;
i
<
report
->
maxfield
;
i
++
)
{
field
=
report
->
field
[
i
];
for
(
j
=
0
;
j
<
field
->
maxusage
;
j
++
)
{
...
...
@@ -142,6 +150,7 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)
}
}
}
}
return
NULL
;
}
...
...
@@ -150,9 +159,9 @@ static void hiddev_send_event(struct hid_device *hid,
struct
hiddev_usage_ref
*
uref
)
{
struct
hiddev
*
hiddev
=
hid
->
hiddev
;
struct
hiddev_list
*
list
=
hiddev
->
list
;
struct
hiddev_list
*
list
;
while
(
list
)
{
list_for_each_entry
(
list
,
&
hiddev
->
list
,
node
)
{
if
(
uref
->
field_index
!=
HID_FIELD_INDEX_NONE
||
(
list
->
flags
&
HIDDEV_FLAG_REPORT
)
!=
0
)
{
list
->
buffer
[
list
->
head
]
=
*
uref
;
...
...
@@ -160,8 +169,6 @@ static void hiddev_send_event(struct hid_device *hid,
(
HIDDEV_BUFFER_SIZE
-
1
);
kill_fasync
(
&
list
->
fasync
,
SIGIO
,
POLL_IN
);
}
list
=
list
->
next
;
}
wake_up_interruptible
(
&
hiddev
->
wait
);
...
...
@@ -180,7 +187,7 @@ void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
uref
.
report_type
=
(
type
==
HID_INPUT_REPORT
)
?
HID_REPORT_TYPE_INPUT
:
((
type
==
HID_OUTPUT_REPORT
)
?
HID_REPORT_TYPE_OUTPUT
:
((
type
==
HID_FEATURE_REPORT
)
?
HID_REPORT_TYPE_FEATURE
:
0
));
((
type
==
HID_FEATURE_REPORT
)
?
HID_REPORT_TYPE_FEATURE
:
0
));
uref
.
report_id
=
field
->
report
->
id
;
uref
.
field_index
=
field
->
index
;
uref
.
usage_index
=
(
usage
-
field
->
usage
);
...
...
@@ -200,7 +207,7 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
uref
.
report_type
=
(
type
==
HID_INPUT_REPORT
)
?
HID_REPORT_TYPE_INPUT
:
((
type
==
HID_OUTPUT_REPORT
)
?
HID_REPORT_TYPE_OUTPUT
:
((
type
==
HID_FEATURE_REPORT
)
?
HID_REPORT_TYPE_FEATURE
:
0
));
((
type
==
HID_FEATURE_REPORT
)
?
HID_REPORT_TYPE_FEATURE
:
0
));
uref
.
report_id
=
report
->
id
;
uref
.
field_index
=
HID_FIELD_INDEX_NONE
;
...
...
@@ -213,7 +220,9 @@ static int hiddev_fasync(int fd, struct file *file, int on)
{
int
retval
;
struct
hiddev_list
*
list
=
file
->
private_data
;
retval
=
fasync_helper
(
fd
,
file
,
on
,
&
list
->
fasync
);
return
retval
<
0
?
retval
:
0
;
}
...
...
@@ -224,14 +233,9 @@ static int hiddev_fasync(int fd, struct file *file, int on)
static
int
hiddev_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
struct
hiddev_list
*
list
=
file
->
private_data
;
struct
hiddev_list
**
listptr
;
listptr
=
&
list
->
hiddev
->
list
;
hiddev_fasync
(
-
1
,
file
,
0
);
while
(
*
listptr
&&
(
*
listptr
!=
list
))
listptr
=
&
((
*
listptr
)
->
next
);
*
listptr
=
(
*
listptr
)
->
next
;
list_del
(
&
list
->
node
);
if
(
!--
list
->
hiddev
->
open
)
{
if
(
list
->
hiddev
->
exist
)
...
...
@@ -248,7 +252,8 @@ static int hiddev_release(struct inode * inode, struct file * file)
/*
* open file op
*/
static
int
hiddev_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
static
int
hiddev_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
struct
hiddev_list
*
list
;
int
i
=
iminor
(
inode
)
-
HIDDEV_MINOR_BASE
;
...
...
@@ -260,9 +265,7 @@ static int hiddev_open(struct inode * inode, struct file * file) {
return
-
ENOMEM
;
list
->
hiddev
=
hiddev_table
[
i
];
list
->
next
=
hiddev_table
[
i
]
->
list
;
hiddev_table
[
i
]
->
list
=
list
;
list_add_tail
(
&
list
->
node
,
&
hiddev_table
[
i
]
->
list
);
file
->
private_data
=
list
;
if
(
!
list
->
hiddev
->
open
++
)
...
...
@@ -362,6 +365,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
static
unsigned
int
hiddev_poll
(
struct
file
*
file
,
poll_table
*
wait
)
{
struct
hiddev_list
*
list
=
file
->
private_data
;
poll_wait
(
file
,
&
list
->
hiddev
->
wait
,
wait
);
if
(
list
->
head
!=
list
->
tail
)
return
POLLIN
|
POLLRDNORM
;
...
...
@@ -382,7 +386,7 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
struct
hiddev_collection_info
cinfo
;
struct
hiddev_report_info
rinfo
;
struct
hiddev_field_info
finfo
;
struct
hiddev_usage_ref_multi
*
uref_multi
=
NULL
;
struct
hiddev_usage_ref_multi
*
uref_multi
=
NULL
;
struct
hiddev_usage_ref
*
uref
;
struct
hiddev_devinfo
dinfo
;
struct
hid_report
*
report
;
...
...
@@ -764,15 +768,15 @@ int hiddev_connect(struct hid_device *hid)
}
init_waitqueue_head
(
&
hiddev
->
wait
);
hiddev_table
[
hid
->
intf
->
minor
-
HIDDEV_MINOR_BASE
]
=
hiddev
;
INIT_LIST_HEAD
(
&
hiddev
->
list
);
hiddev
->
hid
=
hid
;
hiddev
->
exist
=
1
;
hid
->
minor
=
hid
->
intf
->
minor
;
hid
->
hiddev
=
hiddev
;
hiddev_table
[
hid
->
intf
->
minor
-
HIDDEV_MINOR_BASE
]
=
hiddev
;
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录