Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
a7b986b3
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看板
提交
a7b986b3
编写于
6月 20, 2005
作者:
G
Greg Kroah-Hartman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PATCH] USB: convert usbfs/devio.c to use usb notifiers
Signed-off-by:
N
Greg Kroah-Hartman
<
gregkh@suse.de
>
上级
3099e75a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
34 addition
and
11 deletion
+34
-11
drivers/usb/core/devio.c
drivers/usb/core/devio.c
+34
-7
drivers/usb/core/hub.c
drivers/usb/core/hub.c
+0
-2
drivers/usb/core/usb.h
drivers/usb/core/usb.h
+0
-2
未找到文件。
drivers/usb/core/devio.c
浏览文件 @
a7b986b3
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
#include <linux/usb.h>
#include <linux/usb.h>
#include <linux/usbdevice_fs.h>
#include <linux/usbdevice_fs.h>
#include <linux/cdev.h>
#include <linux/cdev.h>
#include <linux/notifier.h>
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
#include <asm/byteorder.h>
#include <linux/moduleparam.h>
#include <linux/moduleparam.h>
...
@@ -1550,7 +1551,7 @@ struct file_operations usbfs_device_file_operations = {
...
@@ -1550,7 +1551,7 @@ struct file_operations usbfs_device_file_operations = {
.
release
=
usbdev_release
,
.
release
=
usbdev_release
,
};
};
void
usbdev_add
(
struct
usb_device
*
dev
)
static
void
usbdev_add
(
struct
usb_device
*
dev
)
{
{
int
minor
=
((
dev
->
bus
->
busnum
-
1
)
*
128
)
+
(
dev
->
devnum
-
1
);
int
minor
=
((
dev
->
bus
->
busnum
-
1
)
*
128
)
+
(
dev
->
devnum
-
1
);
...
@@ -1561,11 +1562,29 @@ void usbdev_add(struct usb_device *dev)
...
@@ -1561,11 +1562,29 @@ void usbdev_add(struct usb_device *dev)
dev
->
class_dev
->
class_data
=
dev
;
dev
->
class_dev
->
class_data
=
dev
;
}
}
void
usbdev_remove
(
struct
usb_device
*
dev
)
static
void
usbdev_remove
(
struct
usb_device
*
dev
)
{
{
class_device_unregister
(
dev
->
class_dev
);
class_device_unregister
(
dev
->
class_dev
);
}
}
static
int
usbdev_notify
(
struct
notifier_block
*
self
,
unsigned
long
action
,
void
*
dev
)
{
switch
(
action
)
{
case
USB_DEVICE_ADD
:
usbdev_add
(
dev
);
break
;
case
USB_DEVICE_REMOVE
:
usbdev_remove
(
dev
);
break
;
}
return
NOTIFY_OK
;
}
static
struct
notifier_block
usbdev_nb
=
{
.
notifier_call
=
usbdev_notify
,
};
static
struct
cdev
usb_device_cdev
=
{
static
struct
cdev
usb_device_cdev
=
{
.
kobj
=
{.
name
=
"usb_device"
,
},
.
kobj
=
{.
name
=
"usb_device"
,
},
.
owner
=
THIS_MODULE
,
.
owner
=
THIS_MODULE
,
...
@@ -1585,24 +1604,32 @@ int __init usbdev_init(void)
...
@@ -1585,24 +1604,32 @@ int __init usbdev_init(void)
retval
=
cdev_add
(
&
usb_device_cdev
,
USB_DEVICE_DEV
,
USB_DEVICE_MAX
);
retval
=
cdev_add
(
&
usb_device_cdev
,
USB_DEVICE_DEV
,
USB_DEVICE_MAX
);
if
(
retval
)
{
if
(
retval
)
{
err
(
"unable to get usb_device major %d"
,
USB_DEVICE_MAJOR
);
err
(
"unable to get usb_device major %d"
,
USB_DEVICE_MAJOR
);
unregister_chrdev_region
(
USB_DEVICE_DEV
,
USB_DEVICE_MAX
);
goto
error_cdev
;
goto
out
;
}
}
usb_device_class
=
class_create
(
THIS_MODULE
,
"usb_device"
);
usb_device_class
=
class_create
(
THIS_MODULE
,
"usb_device"
);
if
(
IS_ERR
(
usb_device_class
))
{
if
(
IS_ERR
(
usb_device_class
))
{
err
(
"unable to register usb_device class"
);
err
(
"unable to register usb_device class"
);
retval
=
PTR_ERR
(
usb_device_class
);
retval
=
PTR_ERR
(
usb_device_class
);
usb_device_class
=
NULL
;
goto
error_class
;
cdev_del
(
&
usb_device_cdev
);
unregister_chrdev_region
(
USB_DEVICE_DEV
,
USB_DEVICE_MAX
);
}
}
usb_register_notify
(
&
usbdev_nb
);
out:
out:
return
retval
;
return
retval
;
error_class:
usb_device_class
=
NULL
;
cdev_del
(
&
usb_device_cdev
);
error_cdev:
unregister_chrdev_region
(
USB_DEVICE_DEV
,
USB_DEVICE_MAX
);
goto
out
;
}
}
void
usbdev_cleanup
(
void
)
void
usbdev_cleanup
(
void
)
{
{
usb_unregister_notify
(
&
usbdev_nb
);
class_destroy
(
usb_device_class
);
class_destroy
(
usb_device_class
);
cdev_del
(
&
usb_device_cdev
);
cdev_del
(
&
usb_device_cdev
);
unregister_chrdev_region
(
USB_DEVICE_DEV
,
USB_DEVICE_MAX
);
unregister_chrdev_region
(
USB_DEVICE_DEV
,
USB_DEVICE_MAX
);
...
...
drivers/usb/core/hub.c
浏览文件 @
a7b986b3
...
@@ -1137,7 +1137,6 @@ void usb_disconnect(struct usb_device **pdev)
...
@@ -1137,7 +1137,6 @@ void usb_disconnect(struct usb_device **pdev)
dev_dbg
(
&
udev
->
dev
,
"unregistering device
\n
"
);
dev_dbg
(
&
udev
->
dev
,
"unregistering device
\n
"
);
release_address
(
udev
);
release_address
(
udev
);
usbfs_remove_device
(
udev
);
usbfs_remove_device
(
udev
);
usbdev_remove
(
udev
);
usb_remove_sysfs_dev_files
(
udev
);
usb_remove_sysfs_dev_files
(
udev
);
/* Avoid races with recursively_mark_NOTATTACHED() */
/* Avoid races with recursively_mark_NOTATTACHED() */
...
@@ -1376,7 +1375,6 @@ int usb_new_device(struct usb_device *udev)
...
@@ -1376,7 +1375,6 @@ int usb_new_device(struct usb_device *udev)
usb_notify_add_device
(
udev
);
usb_notify_add_device
(
udev
);
/* add a /proc/bus/usb entry */
/* add a /proc/bus/usb entry */
usbdev_add
(
udev
);
usbfs_add_device
(
udev
);
usbfs_add_device
(
udev
);
return
0
;
return
0
;
...
...
drivers/usb/core/usb.h
浏览文件 @
a7b986b3
...
@@ -62,8 +62,6 @@ extern void usbfs_conn_disc_event(void);
...
@@ -62,8 +62,6 @@ extern void usbfs_conn_disc_event(void);
extern
int
usbdev_init
(
void
);
extern
int
usbdev_init
(
void
);
extern
void
usbdev_cleanup
(
void
);
extern
void
usbdev_cleanup
(
void
);
extern
void
usbdev_add
(
struct
usb_device
*
dev
);
extern
void
usbdev_remove
(
struct
usb_device
*
dev
);
struct
dev_state
{
struct
dev_state
{
struct
list_head
list
;
/* state list */
struct
list_head
list
;
/* state list */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录