Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
b6202832
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b6202832
编写于
12月 16, 2009
作者:
L
Len Brown
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'wmi' into release
上级
1a544d28
1caab3c1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
173 addition
and
2 deletion
+173
-2
drivers/platform/x86/wmi.c
drivers/platform/x86/wmi.c
+173
-2
未找到文件。
drivers/platform/x86/wmi.c
浏览文件 @
b6202832
...
...
@@ -30,6 +30,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/acpi.h>
#include <acpi/acpi_bus.h>
...
...
@@ -65,6 +66,7 @@ struct wmi_block {
acpi_handle
handle
;
wmi_notify_handler
handler
;
void
*
handler_data
;
struct
device
*
dev
;
};
static
struct
wmi_block
wmi_blocks
;
...
...
@@ -195,6 +197,34 @@ static bool wmi_parse_guid(const u8 *src, u8 *dest)
return
true
;
}
/*
* Convert a raw GUID to the ACII string representation
*/
static
int
wmi_gtoa
(
const
char
*
in
,
char
*
out
)
{
int
i
;
for
(
i
=
3
;
i
>=
0
;
i
--
)
out
+=
sprintf
(
out
,
"%02X"
,
in
[
i
]
&
0xFF
);
out
+=
sprintf
(
out
,
"-"
);
out
+=
sprintf
(
out
,
"%02X"
,
in
[
5
]
&
0xFF
);
out
+=
sprintf
(
out
,
"%02X"
,
in
[
4
]
&
0xFF
);
out
+=
sprintf
(
out
,
"-"
);
out
+=
sprintf
(
out
,
"%02X"
,
in
[
7
]
&
0xFF
);
out
+=
sprintf
(
out
,
"%02X"
,
in
[
6
]
&
0xFF
);
out
+=
sprintf
(
out
,
"-"
);
out
+=
sprintf
(
out
,
"%02X"
,
in
[
8
]
&
0xFF
);
out
+=
sprintf
(
out
,
"%02X"
,
in
[
9
]
&
0xFF
);
out
+=
sprintf
(
out
,
"-"
);
for
(
i
=
10
;
i
<=
15
;
i
++
)
out
+=
sprintf
(
out
,
"%02X"
,
in
[
i
]
&
0xFF
);
out
=
'\0'
;
return
0
;
}
static
bool
find_guid
(
const
char
*
guid_string
,
struct
wmi_block
**
out
)
{
char
tmp
[
16
],
guid_input
[
16
];
...
...
@@ -554,6 +584,138 @@ bool wmi_has_guid(const char *guid_string)
}
EXPORT_SYMBOL_GPL
(
wmi_has_guid
);
/*
* sysfs interface
*/
static
ssize_t
show_modalias
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
char
guid_string
[
37
];
struct
wmi_block
*
wblock
;
wblock
=
dev_get_drvdata
(
dev
);
if
(
!
wblock
)
return
-
ENOMEM
;
wmi_gtoa
(
wblock
->
gblock
.
guid
,
guid_string
);
return
sprintf
(
buf
,
"wmi:%s
\n
"
,
guid_string
);
}
static
DEVICE_ATTR
(
modalias
,
S_IRUGO
,
show_modalias
,
NULL
);
static
int
wmi_dev_uevent
(
struct
device
*
dev
,
struct
kobj_uevent_env
*
env
)
{
char
guid_string
[
37
];
struct
wmi_block
*
wblock
;
if
(
add_uevent_var
(
env
,
"MODALIAS="
))
return
-
ENOMEM
;
wblock
=
dev_get_drvdata
(
dev
);
if
(
!
wblock
)
return
-
ENOMEM
;
wmi_gtoa
(
wblock
->
gblock
.
guid
,
guid_string
);
strcpy
(
&
env
->
buf
[
env
->
buflen
-
1
],
"wmi:"
);
memcpy
(
&
env
->
buf
[
env
->
buflen
-
1
+
4
],
guid_string
,
36
);
env
->
buflen
+=
40
;
return
0
;
}
static
void
wmi_dev_free
(
struct
device
*
dev
)
{
kfree
(
dev
);
}
static
struct
class
wmi_class
=
{
.
name
=
"wmi"
,
.
dev_release
=
wmi_dev_free
,
.
dev_uevent
=
wmi_dev_uevent
,
};
static
int
wmi_create_devs
(
void
)
{
int
result
;
char
guid_string
[
37
];
struct
guid_block
*
gblock
;
struct
wmi_block
*
wblock
;
struct
list_head
*
p
;
struct
device
*
guid_dev
;
/* Create devices for all the GUIDs */
list_for_each
(
p
,
&
wmi_blocks
.
list
)
{
wblock
=
list_entry
(
p
,
struct
wmi_block
,
list
);
guid_dev
=
kzalloc
(
sizeof
(
struct
device
),
GFP_KERNEL
);
if
(
!
guid_dev
)
return
-
ENOMEM
;
wblock
->
dev
=
guid_dev
;
guid_dev
->
class
=
&
wmi_class
;
dev_set_drvdata
(
guid_dev
,
wblock
);
gblock
=
&
wblock
->
gblock
;
wmi_gtoa
(
gblock
->
guid
,
guid_string
);
dev_set_name
(
guid_dev
,
guid_string
);
result
=
device_register
(
guid_dev
);
if
(
result
)
return
result
;
result
=
device_create_file
(
guid_dev
,
&
dev_attr_modalias
);
if
(
result
)
return
result
;
}
return
0
;
}
static
void
wmi_remove_devs
(
void
)
{
struct
guid_block
*
gblock
;
struct
wmi_block
*
wblock
;
struct
list_head
*
p
;
struct
device
*
guid_dev
;
/* Delete devices for all the GUIDs */
list_for_each
(
p
,
&
wmi_blocks
.
list
)
{
wblock
=
list_entry
(
p
,
struct
wmi_block
,
list
);
guid_dev
=
wblock
->
dev
;
gblock
=
&
wblock
->
gblock
;
device_remove_file
(
guid_dev
,
&
dev_attr_modalias
);
device_unregister
(
guid_dev
);
}
}
static
void
wmi_class_exit
(
void
)
{
wmi_remove_devs
();
class_unregister
(
&
wmi_class
);
}
static
int
wmi_class_init
(
void
)
{
int
ret
;
ret
=
class_register
(
&
wmi_class
);
if
(
ret
)
return
ret
;
ret
=
wmi_create_devs
();
if
(
ret
)
wmi_class_exit
();
return
ret
;
}
/*
* Parse the _WDG method for the GUID data blocks
*/
...
...
@@ -709,10 +871,17 @@ static int __init acpi_wmi_init(void)
if
(
result
<
0
)
{
printk
(
KERN_INFO
PREFIX
"Error loading mapper
\n
"
);
}
else
{
printk
(
KERN_INFO
PREFIX
"Mapper loaded
\n
"
);
return
-
ENODEV
;
}
result
=
wmi_class_init
();
if
(
result
)
{
acpi_bus_unregister_driver
(
&
acpi_wmi_driver
);
return
result
;
}
printk
(
KERN_INFO
PREFIX
"Mapper loaded
\n
"
);
return
result
;
}
...
...
@@ -721,6 +890,8 @@ static void __exit acpi_wmi_exit(void)
struct
list_head
*
p
,
*
tmp
;
struct
wmi_block
*
wblock
;
wmi_class_exit
();
acpi_bus_unregister_driver
(
&
acpi_wmi_driver
);
list_for_each_safe
(
p
,
tmp
,
&
wmi_blocks
.
list
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录