Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
e8b495fe
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看板
提交
e8b495fe
编写于
7月 22, 2007
作者:
L
Len Brown
浏览文件
操作
浏览文件
下载
差异文件
Pull dock-bay into release branch
上级
22aadf8a
9254bc84
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
106 addition
and
40 deletion
+106
-40
drivers/acpi/bay.c
drivers/acpi/bay.c
+9
-10
drivers/acpi/dock.c
drivers/acpi/dock.c
+97
-30
未找到文件。
drivers/acpi/bay.c
浏览文件 @
e8b495fe
...
...
@@ -288,6 +288,11 @@ static int bay_add(acpi_handle handle, int id)
new_bay
->
pdev
=
pdev
;
platform_set_drvdata
(
pdev
,
new_bay
);
/*
* we want the bay driver to be able to send uevents
*/
pdev
->
dev
.
uevent_suppress
=
0
;
if
(
acpi_bay_add_fs
(
new_bay
))
{
platform_device_unregister
(
new_bay
->
pdev
);
goto
bay_add_err
;
...
...
@@ -328,18 +333,12 @@ static void bay_notify(acpi_handle handle, u32 event, void *data)
{
struct
bay
*
bay_dev
=
(
struct
bay
*
)
data
;
struct
device
*
dev
=
&
bay_dev
->
pdev
->
dev
;
char
event_string
[
12
];
char
*
envp
[]
=
{
event_string
,
NULL
};
bay_dprintk
(
handle
,
"Bay event"
);
switch
(
event
)
{
case
ACPI_NOTIFY_BUS_CHECK
:
case
ACPI_NOTIFY_DEVICE_CHECK
:
case
ACPI_NOTIFY_EJECT_REQUEST
:
kobject_uevent
(
&
dev
->
kobj
,
KOBJ_CHANGE
);
break
;
default:
printk
(
KERN_ERR
PREFIX
"Bay: unknown event %d
\n
"
,
event
);
}
sprintf
(
event_string
,
"BAY_EVENT=%d
\n
"
,
event
);
kobject_uevent_env
(
&
dev
->
kobj
,
KOBJ_CHANGE
,
envp
);
}
static
acpi_status
...
...
drivers/acpi/dock.c
浏览文件 @
e8b495fe
...
...
@@ -40,8 +40,15 @@ MODULE_AUTHOR("Kristen Carlson Accardi");
MODULE_DESCRIPTION
(
ACPI_DOCK_DRIVER_DESCRIPTION
);
MODULE_LICENSE
(
"GPL"
);
static
int
immediate_undock
=
1
;
module_param
(
immediate_undock
,
bool
,
0644
);
MODULE_PARM_DESC
(
immediate_undock
,
"1 (default) will cause the driver to "
"undock immediately when the undock button is pressed, 0 will cause"
" the driver to wait for userspace to write the undock sysfs file "
" before undocking"
);
static
struct
atomic_notifier_head
dock_notifier_list
;
static
struct
platform_device
dock_device
;
static
struct
platform_device
*
dock_device
;
static
char
dock_device_name
[]
=
"dock"
;
struct
dock_station
{
...
...
@@ -63,6 +70,7 @@ struct dock_dependent_device {
};
#define DOCK_DOCKING 0x00000001
#define DOCK_UNDOCKING 0x00000002
#define DOCK_EVENT 3
#define UNDOCK_EVENT 2
...
...
@@ -327,12 +335,20 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
static
void
dock_event
(
struct
dock_station
*
ds
,
u32
event
,
int
num
)
{
struct
device
*
dev
=
&
dock_device
.
dev
;
struct
device
*
dev
=
&
dock_device
->
dev
;
char
event_string
[
7
];
char
*
envp
[]
=
{
event_string
,
NULL
};
if
(
num
==
UNDOCK_EVENT
)
sprintf
(
event_string
,
"UNDOCK"
);
else
sprintf
(
event_string
,
"DOCK"
);
/*
* Indicate that the status of the dock station has
* changed.
*/
kobject_uevent
(
&
dev
->
kobj
,
KOBJ_CHANGE
);
kobject_uevent
_env
(
&
dev
->
kobj
,
KOBJ_CHANGE
,
envp
);
}
/**
...
...
@@ -380,12 +396,11 @@ static void handle_dock(struct dock_station *ds, int dock)
union
acpi_object
arg
;
struct
acpi_buffer
buffer
=
{
ACPI_ALLOCATE_BUFFER
,
NULL
};
struct
acpi_buffer
name_buffer
=
{
ACPI_ALLOCATE_BUFFER
,
NULL
};
union
acpi_object
*
obj
;
acpi_get_name
(
ds
->
handle
,
ACPI_FULL_PATHNAME
,
&
name_buffer
);
obj
=
name_buffer
.
pointer
;
printk
(
KERN_INFO
PREFIX
"%s
\n
"
,
dock
?
"docking"
:
"undocking"
);
printk
(
KERN_INFO
PREFIX
"%s - %s
\n
"
,
(
char
*
)
name_buffer
.
pointer
,
dock
?
"docking"
:
"undocking"
);
/* _DCK method has one argument */
arg_list
.
count
=
1
;
...
...
@@ -394,7 +409,8 @@ static void handle_dock(struct dock_station *ds, int dock)
arg
.
integer
.
value
=
dock
;
status
=
acpi_evaluate_object
(
ds
->
handle
,
"_DCK"
,
&
arg_list
,
&
buffer
);
if
(
ACPI_FAILURE
(
status
))
pr_debug
(
"%s: failed to execute _DCK
\n
"
,
obj
->
string
.
pointer
);
printk
(
KERN_ERR
PREFIX
"%s - failed to execute _DCK
\n
"
,
(
char
*
)
name_buffer
.
pointer
);
kfree
(
buffer
.
pointer
);
kfree
(
name_buffer
.
pointer
);
}
...
...
@@ -420,6 +436,16 @@ static inline void complete_dock(struct dock_station *ds)
ds
->
last_dock_time
=
jiffies
;
}
static
inline
void
begin_undock
(
struct
dock_station
*
ds
)
{
ds
->
flags
|=
DOCK_UNDOCKING
;
}
static
inline
void
complete_undock
(
struct
dock_station
*
ds
)
{
ds
->
flags
&=
~
(
DOCK_UNDOCKING
);
}
/**
* dock_in_progress - see if we are in the middle of handling a dock event
* @ds: the dock station
...
...
@@ -550,7 +576,7 @@ static int handle_eject_request(struct dock_station *ds, u32 event)
printk
(
KERN_ERR
PREFIX
"Unable to undock!
\n
"
);
return
-
EBUSY
;
}
complete_undock
(
ds
);
return
0
;
}
...
...
@@ -594,7 +620,11 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
* to the driver who wish to hotplug.
*/
case
ACPI_NOTIFY_EJECT_REQUEST
:
handle_eject_request
(
ds
,
event
);
begin_undock
(
ds
);
if
(
immediate_undock
)
handle_eject_request
(
ds
,
event
);
else
dock_event
(
ds
,
event
,
UNDOCK_EVENT
);
break
;
default:
printk
(
KERN_ERR
PREFIX
"Unknown dock event %d
\n
"
,
event
);
...
...
@@ -652,6 +682,17 @@ static ssize_t show_docked(struct device *dev,
}
DEVICE_ATTR
(
docked
,
S_IRUGO
,
show_docked
,
NULL
);
/*
* show_flags - read method for flags file in sysfs
*/
static
ssize_t
show_flags
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
return
snprintf
(
buf
,
PAGE_SIZE
,
"%d
\n
"
,
dock_station
->
flags
);
}
DEVICE_ATTR
(
flags
,
S_IRUGO
,
show_flags
,
NULL
);
/*
* write_undock - write method for "undock" file in sysfs
*/
...
...
@@ -675,16 +716,15 @@ static ssize_t show_dock_uid(struct device *dev,
struct
device_attribute
*
attr
,
char
*
buf
)
{
unsigned
long
lbuf
;
acpi_status
status
=
acpi_evaluate_integer
(
dock_station
->
handle
,
"_UID"
,
NULL
,
&
lbuf
);
if
(
ACPI_FAILURE
(
status
))
{
acpi_status
status
=
acpi_evaluate_integer
(
dock_station
->
handle
,
"_UID"
,
NULL
,
&
lbuf
);
if
(
ACPI_FAILURE
(
status
))
return
0
;
}
return
snprintf
(
buf
,
PAGE_SIZE
,
"%lx
\n
"
,
lbuf
);
}
DEVICE_ATTR
(
uid
,
S_IRUGO
,
show_dock_uid
,
NULL
);
/**
* dock_add - add a new dock station
* @handle: the dock station handle
...
...
@@ -711,33 +751,53 @@ static int dock_add(acpi_handle handle)
ATOMIC_INIT_NOTIFIER_HEAD
(
&
dock_notifier_list
);
/* initialize platform device stuff */
dock_device
.
name
=
dock_device_name
;
ret
=
platform_device_register
(
&
dock_device
);
dock_device
=
platform_device_register_simple
(
dock_device_name
,
0
,
NULL
,
0
);
if
(
IS_ERR
(
dock_device
))
{
kfree
(
dock_station
);
dock_station
=
NULL
;
return
PTR_ERR
(
dock_device
);
}
/* we want the dock device to send uevents */
dock_device
->
dev
.
uevent_suppress
=
0
;
ret
=
device_create_file
(
&
dock_device
->
dev
,
&
dev_attr_docked
);
if
(
ret
)
{
printk
(
KERN_ERR
PREFIX
"Error %d registering dock device
\n
"
,
ret
);
printk
(
"Error %d adding sysfs file
\n
"
,
ret
);
platform_device_unregister
(
dock_device
);
kfree
(
dock_station
);
dock_station
=
NULL
;
return
ret
;
}
ret
=
device_create_file
(
&
dock_device
.
dev
,
&
dev_attr_docked
);
ret
=
device_create_file
(
&
dock_device
->
dev
,
&
dev_attr_undock
);
if
(
ret
)
{
printk
(
"Error %d adding sysfs file
\n
"
,
ret
);
platform_device_unregister
(
&
dock_device
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_docked
);
platform_device_unregister
(
dock_device
);
kfree
(
dock_station
);
dock_station
=
NULL
;
return
ret
;
}
ret
=
device_create_file
(
&
dock_device
.
dev
,
&
dev_attr_undock
);
ret
=
device_create_file
(
&
dock_device
->
dev
,
&
dev_attr_uid
);
if
(
ret
)
{
printk
(
"Error %d adding sysfs file
\n
"
,
ret
);
device_remove_file
(
&
dock_device
.
dev
,
&
dev_attr_docked
);
platform_device_unregister
(
&
dock_device
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_docked
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_undock
);
platform_device_unregister
(
dock_device
);
kfree
(
dock_station
);
dock_station
=
NULL
;
return
ret
;
}
ret
=
device_create_file
(
&
dock_device
.
dev
,
&
dev_attr_uid
);
ret
=
device_create_file
(
&
dock_device
->
dev
,
&
dev_attr_flags
);
if
(
ret
)
{
printk
(
"Error %d adding sysfs file
\n
"
,
ret
);
platform_device_unregister
(
&
dock_device
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_docked
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_undock
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_uid
);
platform_device_unregister
(
dock_device
);
kfree
(
dock_station
);
dock_station
=
NULL
;
return
ret
;
}
...
...
@@ -750,6 +810,7 @@ static int dock_add(acpi_handle handle)
dd
=
alloc_dock_dependent_device
(
handle
);
if
(
!
dd
)
{
kfree
(
dock_station
);
dock_station
=
NULL
;
ret
=
-
ENOMEM
;
goto
dock_add_err_unregister
;
}
...
...
@@ -773,10 +834,13 @@ static int dock_add(acpi_handle handle)
dock_add_err:
kfree
(
dd
);
dock_add_err_unregister:
device_remove_file
(
&
dock_device
.
dev
,
&
dev_attr_docked
);
device_remove_file
(
&
dock_device
.
dev
,
&
dev_attr_undock
);
platform_device_unregister
(
&
dock_device
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_docked
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_undock
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_uid
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_flags
);
platform_device_unregister
(
dock_device
);
kfree
(
dock_station
);
dock_station
=
NULL
;
return
ret
;
}
...
...
@@ -804,12 +868,15 @@ static int dock_remove(void)
printk
(
KERN_ERR
"Error removing notify handler
\n
"
);
/* cleanup sysfs */
device_remove_file
(
&
dock_device
.
dev
,
&
dev_attr_docked
);
device_remove_file
(
&
dock_device
.
dev
,
&
dev_attr_undock
);
platform_device_unregister
(
&
dock_device
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_docked
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_undock
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_uid
);
device_remove_file
(
&
dock_device
->
dev
,
&
dev_attr_flags
);
platform_device_unregister
(
dock_device
);
/* free dock station memory */
kfree
(
dock_station
);
dock_station
=
NULL
;
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录