Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
bd0ef235
L
linux
项目概览
Linux-御风守护者
/
linux
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd0ef235
编写于
11月 20, 2005
作者:
D
Dmitry Torokhov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Input: handle failures in input_register_device()
Signed-off-by:
N
Dmitry Torokhov
<
dtor@mail.ru
>
上级
e597f0c8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
27 deletion
+36
-27
drivers/input/input.c
drivers/input/input.c
+36
-27
未找到文件。
drivers/input/input.c
浏览文件 @
bd0ef235
...
@@ -536,7 +536,7 @@ static struct attribute *input_dev_attrs[] = {
...
@@ -536,7 +536,7 @@ static struct attribute *input_dev_attrs[] = {
NULL
NULL
};
};
static
struct
attribute_group
input_dev_group
=
{
static
struct
attribute_group
input_dev_
attr_
group
=
{
.
attrs
=
input_dev_attrs
,
.
attrs
=
input_dev_attrs
,
};
};
...
@@ -717,35 +717,14 @@ struct input_dev *input_allocate_device(void)
...
@@ -717,35 +717,14 @@ struct input_dev *input_allocate_device(void)
return
dev
;
return
dev
;
}
}
static
void
input_register_classdevice
(
struct
input_dev
*
dev
)
{
static
atomic_t
input_no
=
ATOMIC_INIT
(
0
);
const
char
*
path
;
__module_get
(
THIS_MODULE
);
dev
->
dev
=
dev
->
cdev
.
dev
;
snprintf
(
dev
->
cdev
.
class_id
,
sizeof
(
dev
->
cdev
.
class_id
),
"input%ld"
,
(
unsigned
long
)
atomic_inc_return
(
&
input_no
)
-
1
);
path
=
kobject_get_path
(
&
dev
->
cdev
.
class
->
subsys
.
kset
.
kobj
,
GFP_KERNEL
);
printk
(
KERN_INFO
"input: %s as %s/%s
\n
"
,
dev
->
name
?
dev
->
name
:
"Unspecified device"
,
path
?
path
:
""
,
dev
->
cdev
.
class_id
);
kfree
(
path
);
class_device_add
(
&
dev
->
cdev
);
sysfs_create_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_group
);
sysfs_create_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_id_attr_group
);
sysfs_create_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_caps_attr_group
);
}
int
input_register_device
(
struct
input_dev
*
dev
)
int
input_register_device
(
struct
input_dev
*
dev
)
{
{
static
atomic_t
input_no
=
ATOMIC_INIT
(
0
);
struct
input_handle
*
handle
;
struct
input_handle
*
handle
;
struct
input_handler
*
handler
;
struct
input_handler
*
handler
;
struct
input_device_id
*
id
;
struct
input_device_id
*
id
;
const
char
*
path
;
int
error
;
if
(
!
dev
->
dynalloc
)
{
if
(
!
dev
->
dynalloc
)
{
printk
(
KERN_WARNING
"input: device %s is statically allocated, will not register
\n
"
printk
(
KERN_WARNING
"input: device %s is statically allocated, will not register
\n
"
...
@@ -773,7 +752,32 @@ int input_register_device(struct input_dev *dev)
...
@@ -773,7 +752,32 @@ int input_register_device(struct input_dev *dev)
INIT_LIST_HEAD
(
&
dev
->
h_list
);
INIT_LIST_HEAD
(
&
dev
->
h_list
);
list_add_tail
(
&
dev
->
node
,
&
input_dev_list
);
list_add_tail
(
&
dev
->
node
,
&
input_dev_list
);
input_register_classdevice
(
dev
);
dev
->
cdev
.
class
=
&
input_class
;
snprintf
(
dev
->
cdev
.
class_id
,
sizeof
(
dev
->
cdev
.
class_id
),
"input%ld"
,
(
unsigned
long
)
atomic_inc_return
(
&
input_no
)
-
1
);
error
=
class_device_add
(
&
dev
->
cdev
);
if
(
error
)
return
error
;
error
=
sysfs_create_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_attr_group
);
if
(
error
)
goto
fail1
;
error
=
sysfs_create_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_id_attr_group
);
if
(
error
)
goto
fail2
;
error
=
sysfs_create_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_caps_attr_group
);
if
(
error
)
goto
fail3
;
__module_get
(
THIS_MODULE
);
path
=
kobject_get_path
(
&
dev
->
cdev
.
kobj
,
GFP_KERNEL
);
printk
(
KERN_INFO
"input: %s as %s
\n
"
,
dev
->
name
?
dev
->
name
:
"Unspecified device"
,
path
?
path
:
"N/A"
);
kfree
(
path
);
list_for_each_entry
(
handler
,
&
input_handler_list
,
node
)
list_for_each_entry
(
handler
,
&
input_handler_list
,
node
)
if
(
!
handler
->
blacklist
||
!
input_match_device
(
handler
->
blacklist
,
dev
))
if
(
!
handler
->
blacklist
||
!
input_match_device
(
handler
->
blacklist
,
dev
))
...
@@ -784,6 +788,11 @@ int input_register_device(struct input_dev *dev)
...
@@ -784,6 +788,11 @@ int input_register_device(struct input_dev *dev)
input_wakeup_procfs_readers
();
input_wakeup_procfs_readers
();
return
0
;
return
0
;
fail3:
sysfs_remove_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_id_attr_group
);
fail2:
sysfs_remove_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_attr_group
);
fail1:
class_device_del
(
&
dev
->
cdev
);
return
error
;
}
}
void
input_unregister_device
(
struct
input_dev
*
dev
)
void
input_unregister_device
(
struct
input_dev
*
dev
)
...
@@ -805,7 +814,7 @@ void input_unregister_device(struct input_dev *dev)
...
@@ -805,7 +814,7 @@ void input_unregister_device(struct input_dev *dev)
sysfs_remove_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_caps_attr_group
);
sysfs_remove_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_caps_attr_group
);
sysfs_remove_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_id_attr_group
);
sysfs_remove_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_id_attr_group
);
sysfs_remove_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_group
);
sysfs_remove_group
(
&
dev
->
cdev
.
kobj
,
&
input_dev_
attr_
group
);
class_device_unregister
(
&
dev
->
cdev
);
class_device_unregister
(
&
dev
->
cdev
);
input_wakeup_procfs_readers
();
input_wakeup_procfs_readers
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录