Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
17c50b41
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,发现更多精彩内容 >>
提交
17c50b41
编写于
7月 22, 2007
作者:
L
Len Brown
浏览文件
操作
浏览文件
下载
差异文件
Pull tables-in-sysfs into release branch
上级
0d090b68
d4c5f047
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
144 addition
and
21 deletion
+144
-21
drivers/acpi/system.c
drivers/acpi/system.c
+144
-21
未找到文件。
drivers/acpi/system.c
浏览文件 @
17c50b41
...
...
@@ -39,15 +39,12 @@ ACPI_MODULE_NAME("system");
#define ACPI_SYSTEM_CLASS "system"
#define ACPI_SYSTEM_DEVICE_NAME "System"
#define ACPI_SYSTEM_FILE_INFO "info"
#define ACPI_SYSTEM_FILE_EVENT "event"
#define ACPI_SYSTEM_FILE_DSDT "dsdt"
#define ACPI_SYSTEM_FILE_FADT "fadt"
/*
* Make ACPICA version work as module param
*/
static
int
param_get_acpica_version
(
char
*
buffer
,
struct
kernel_param
*
kp
)
{
static
int
param_get_acpica_version
(
char
*
buffer
,
struct
kernel_param
*
kp
)
{
int
result
;
result
=
sprintf
(
buffer
,
"%x"
,
ACPI_CA_VERSION
);
...
...
@@ -57,10 +54,127 @@ static int param_get_acpica_version(char *buffer, struct kernel_param *kp) {
module_param_call
(
acpica_version
,
NULL
,
param_get_acpica_version
,
NULL
,
0444
);
/* --------------------------------------------------------------------------
FS Interface (/sys)
-------------------------------------------------------------------------- */
static
LIST_HEAD
(
acpi_table_attr_list
);
static
struct
kobject
tables_kobj
;
struct
acpi_table_attr
{
struct
bin_attribute
attr
;
char
name
[
8
];
int
instance
;
struct
list_head
node
;
};
static
ssize_t
acpi_table_show
(
struct
kobject
*
kobj
,
struct
bin_attribute
*
bin_attr
,
char
*
buf
,
loff_t
offset
,
size_t
count
)
{
struct
acpi_table_attr
*
table_attr
=
container_of
(
bin_attr
,
struct
acpi_table_attr
,
attr
);
struct
acpi_table_header
*
table_header
=
NULL
;
acpi_status
status
;
ssize_t
ret_count
=
count
;
status
=
acpi_get_table
(
table_attr
->
name
,
table_attr
->
instance
,
&
table_header
);
if
(
ACPI_FAILURE
(
status
))
return
-
ENODEV
;
if
(
offset
>=
table_header
->
length
)
{
ret_count
=
0
;
goto
end
;
}
if
(
offset
+
ret_count
>
table_header
->
length
)
ret_count
=
table_header
->
length
-
offset
;
memcpy
(
buf
,
((
char
*
)
table_header
)
+
offset
,
ret_count
);
end:
return
ret_count
;
}
static
void
acpi_table_attr_init
(
struct
acpi_table_attr
*
table_attr
,
struct
acpi_table_header
*
table_header
)
{
struct
acpi_table_header
*
header
=
NULL
;
struct
acpi_table_attr
*
attr
=
NULL
;
memcpy
(
table_attr
->
name
,
table_header
->
signature
,
ACPI_NAME_SIZE
);
list_for_each_entry
(
attr
,
&
acpi_table_attr_list
,
node
)
{
if
(
!
memcmp
(
table_header
->
signature
,
attr
->
name
,
ACPI_NAME_SIZE
))
if
(
table_attr
->
instance
<
attr
->
instance
)
table_attr
->
instance
=
attr
->
instance
;
}
table_attr
->
instance
++
;
if
(
table_attr
->
instance
>
1
||
(
table_attr
->
instance
==
1
&&
!
acpi_get_table
(
table_header
->
signature
,
2
,
&
header
)))
sprintf
(
table_attr
->
name
+
4
,
"%d"
,
table_attr
->
instance
);
table_attr
->
attr
.
size
=
0
;
table_attr
->
attr
.
read
=
acpi_table_show
;
table_attr
->
attr
.
attr
.
name
=
table_attr
->
name
;
table_attr
->
attr
.
attr
.
mode
=
0444
;
table_attr
->
attr
.
attr
.
owner
=
THIS_MODULE
;
return
;
}
static
int
acpi_system_sysfs_init
(
void
)
{
struct
acpi_table_attr
*
table_attr
;
struct
acpi_table_header
*
table_header
=
NULL
;
int
table_index
=
0
;
int
result
;
tables_kobj
.
parent
=
&
acpi_subsys
.
kobj
;
kobject_set_name
(
&
tables_kobj
,
"tables"
);
result
=
kobject_register
(
&
tables_kobj
);
if
(
result
)
return
result
;
do
{
result
=
acpi_get_table_by_index
(
table_index
,
&
table_header
);
if
(
!
result
)
{
table_index
++
;
table_attr
=
NULL
;
table_attr
=
kzalloc
(
sizeof
(
struct
acpi_table_attr
),
GFP_KERNEL
);
if
(
!
table_attr
)
return
-
ENOMEM
;
acpi_table_attr_init
(
table_attr
,
table_header
);
result
=
sysfs_create_bin_file
(
&
tables_kobj
,
&
table_attr
->
attr
);
if
(
result
)
{
kfree
(
table_attr
);
return
result
;
}
else
list_add_tail
(
&
table_attr
->
node
,
&
acpi_table_attr_list
);
}
}
while
(
!
result
);
return
0
;
}
/* --------------------------------------------------------------------------
FS Interface (/proc)
-------------------------------------------------------------------------- */
#ifdef CONFIG_ACPI_PROCFS
#define ACPI_SYSTEM_FILE_INFO "info"
#define ACPI_SYSTEM_FILE_EVENT "event"
#define ACPI_SYSTEM_FILE_DSDT "dsdt"
#define ACPI_SYSTEM_FILE_FADT "fadt"
static
int
acpi_system_read_info
(
struct
seq_file
*
seq
,
void
*
offset
)
{
...
...
@@ -80,7 +194,6 @@ static const struct file_operations acpi_system_info_ops = {
.
llseek
=
seq_lseek
,
.
release
=
single_release
,
};
#endif
static
ssize_t
acpi_system_read_dsdt
(
struct
file
*
,
char
__user
*
,
size_t
,
loff_t
*
);
...
...
@@ -97,13 +210,11 @@ acpi_system_read_dsdt(struct file *file,
struct
acpi_table_header
*
dsdt
=
NULL
;
ssize_t
res
;
status
=
acpi_get_table
(
ACPI_SIG_DSDT
,
1
,
&
dsdt
);
if
(
ACPI_FAILURE
(
status
))
return
-
ENODEV
;
res
=
simple_read_from_buffer
(
buffer
,
count
,
ppos
,
dsdt
,
dsdt
->
length
);
res
=
simple_read_from_buffer
(
buffer
,
count
,
ppos
,
dsdt
,
dsdt
->
length
);
return
res
;
}
...
...
@@ -123,28 +234,21 @@ acpi_system_read_fadt(struct file *file,
struct
acpi_table_header
*
fadt
=
NULL
;
ssize_t
res
;
status
=
acpi_get_table
(
ACPI_SIG_FADT
,
1
,
&
fadt
);
if
(
ACPI_FAILURE
(
status
))
return
-
ENODEV
;
res
=
simple_read_from_buffer
(
buffer
,
count
,
ppos
,
fadt
,
fadt
->
length
);
res
=
simple_read_from_buffer
(
buffer
,
count
,
ppos
,
fadt
,
fadt
->
length
);
return
res
;
}
static
int
__init
acpi_system
_init
(
void
)
static
int
acpi_system_procfs
_init
(
void
)
{
struct
proc_dir_entry
*
entry
;
int
error
=
0
;
char
*
name
;
if
(
acpi_disabled
)
return
0
;
#ifdef CONFIG_ACPI_PROCFS
/* 'info' [R] */
name
=
ACPI_SYSTEM_FILE_INFO
;
entry
=
create_proc_entry
(
name
,
S_IRUGO
,
acpi_root_dir
);
...
...
@@ -153,7 +257,6 @@ static int __init acpi_system_init(void)
else
{
entry
->
proc_fops
=
&
acpi_system_info_ops
;
}
#endif
/* 'dsdt' [R] */
name
=
ACPI_SYSTEM_FILE_DSDT
;
...
...
@@ -177,12 +280,32 @@ static int __init acpi_system_init(void)
Error:
remove_proc_entry
(
ACPI_SYSTEM_FILE_FADT
,
acpi_root_dir
);
remove_proc_entry
(
ACPI_SYSTEM_FILE_DSDT
,
acpi_root_dir
);
#ifdef CONFIG_ACPI_PROCFS
remove_proc_entry
(
ACPI_SYSTEM_FILE_INFO
,
acpi_root_dir
);
#endif
error
=
-
EFAULT
;
goto
Done
;
}
#else
static
int
acpi_system_procfs_init
(
void
)
{
return
0
;
}
#endif
static
int
__init
acpi_system_init
(
void
)
{
int
result
=
0
;
if
(
acpi_disabled
)
return
0
;
result
=
acpi_system_procfs_init
();
if
(
result
)
return
result
;
result
=
acpi_system_sysfs_init
();
return
result
;
}
subsys_initcall
(
acpi_system_init
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录