Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
698a7c24
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
698a7c24
编写于
4月 05, 2013
作者:
G
Guenter Roeck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hwmon: (nct6775) Support two SuperIO chips in the same system
Signed-off-by:
N
Guenter Roeck
<
linux@roeck-us.net
>
上级
f73cf632
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
50 deletion
+63
-50
drivers/hwmon/nct6775.c
drivers/hwmon/nct6775.c
+63
-50
未找到文件。
drivers/hwmon/nct6775.c
浏览文件 @
698a7c24
...
...
@@ -3484,11 +3484,11 @@ static const char * const nct6775_sio_names[] __initconst = {
};
/* nct6775_find() looks for a '627 in the Super-I/O config space */
static
int
__init
nct6775_find
(
int
sioaddr
,
unsigned
short
*
addr
,
struct
nct6775_sio_data
*
sio_data
)
static
int
__init
nct6775_find
(
int
sioaddr
,
struct
nct6775_sio_data
*
sio_data
)
{
u16
val
;
int
err
;
int
addr
;
err
=
superio_enter
(
sioaddr
);
if
(
err
)
...
...
@@ -3520,8 +3520,8 @@ static int __init nct6775_find(int sioaddr, unsigned short *addr,
superio_select
(
sioaddr
,
NCT6775_LD_HWM
);
val
=
(
superio_inb
(
sioaddr
,
SIO_REG_ADDR
)
<<
8
)
|
superio_inb
(
sioaddr
,
SIO_REG_ADDR
+
1
);
*
addr
=
val
&
IOREGION_ALIGNMENT
;
if
(
*
addr
==
0
)
{
addr
=
val
&
IOREGION_ALIGNMENT
;
if
(
addr
==
0
)
{
pr_err
(
"Refusing to enable a Super-I/O device with a base I/O port 0
\n
"
);
superio_exit
(
sioaddr
);
return
-
ENODEV
;
...
...
@@ -3535,11 +3535,11 @@ static int __init nct6775_find(int sioaddr, unsigned short *addr,
}
superio_exit
(
sioaddr
);
pr_info
(
"Found %s or compatible chip at %#x
\n
"
,
nct6775_sio_names
[
sio_data
->
kind
],
*
addr
);
pr_info
(
"Found %s or compatible chip at %#x
:%#x
\n
"
,
nct6775_sio_names
[
sio_data
->
kind
],
sioaddr
,
addr
);
sio_data
->
sioreg
=
sioaddr
;
return
0
;
return
addr
;
}
/*
...
...
@@ -3548,14 +3548,20 @@ static int __init nct6775_find(int sioaddr, unsigned short *addr,
* track of the nct6775 driver. But since we platform_device_alloc(), we
* must keep track of the device
*/
static
struct
platform_device
*
pdev
;
static
struct
platform_device
*
pdev
[
2
]
;
static
int
__init
sensors_nct6775_init
(
void
)
{
int
err
;
unsigned
short
address
;
int
i
,
err
;
bool
found
=
false
;
int
address
;
struct
resource
res
;
struct
nct6775_sio_data
sio_data
;
int
sioaddr
[
2
]
=
{
0x2e
,
0x4e
};
err
=
platform_driver_register
(
&
nct6775_driver
);
if
(
err
)
return
err
;
/*
* initialize sio_data->kind and sio_data->sioreg.
...
...
@@ -3564,64 +3570,71 @@ static int __init sensors_nct6775_init(void)
* driver will probe 0x2e and 0x4e and auto-detect the presence of a
* nct6775 hardware monitor, and call probe()
*/
if
(
nct6775_find
(
0x2e
,
&
address
,
&
sio_data
)
&&
nct6775_find
(
0x4e
,
&
address
,
&
sio_data
))
return
-
ENODEV
;
err
=
platform_driver_register
(
&
nct6775_driver
);
if
(
err
)
goto
exit
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
pdev
);
i
++
)
{
address
=
nct6775_find
(
sioaddr
[
i
],
&
sio_data
);
if
(
address
<=
0
)
continue
;
pdev
=
platform_device_alloc
(
DRVNAME
,
address
);
if
(
!
pdev
)
{
err
=
-
ENOMEM
;
pr_err
(
"Device allocation failed
\n
"
);
goto
exit_unregister
;
}
found
=
true
;
err
=
platform_device_add_data
(
pdev
,
&
sio_data
,
sizeof
(
struct
nct6775_sio_data
));
if
(
err
)
{
pr_err
(
"Platform data allocation failed
\n
"
);
goto
exit_device_put
;
}
pdev
[
i
]
=
platform_device_alloc
(
DRVNAME
,
address
);
if
(
!
pdev
[
i
])
{
err
=
-
ENOMEM
;
goto
exit_device_put
;
}
memset
(
&
res
,
0
,
sizeof
(
res
));
res
.
name
=
DRVNAME
;
res
.
start
=
address
+
IOREGION_OFFSET
;
res
.
end
=
address
+
IOREGION_OFFSET
+
IOREGION_LENGTH
-
1
;
res
.
flags
=
IORESOURCE_IO
;
err
=
platform_device_add_data
(
pdev
[
i
],
&
sio_data
,
sizeof
(
struct
nct6775_sio_data
));
if
(
err
)
goto
exit_device_put
;
memset
(
&
res
,
0
,
sizeof
(
res
));
res
.
name
=
DRVNAME
;
res
.
start
=
address
+
IOREGION_OFFSET
;
res
.
end
=
address
+
IOREGION_OFFSET
+
IOREGION_LENGTH
-
1
;
res
.
flags
=
IORESOURCE_IO
;
err
=
acpi_check_resource_conflict
(
&
res
);
if
(
err
)
{
platform_device_put
(
pdev
[
i
]);
pdev
[
i
]
=
NULL
;
continue
;
}
err
=
acpi_check_resource_conflict
(
&
res
);
if
(
err
)
goto
exit_device_put
;
err
=
platform_device_add_resources
(
pdev
[
i
],
&
res
,
1
);
if
(
err
)
goto
exit_device_put
;
err
=
platform_device_add_resources
(
pdev
,
&
res
,
1
);
if
(
err
)
{
pr_err
(
"Device resource addition failed (%d)
\n
"
,
err
);
goto
exit_device_put
;
/* platform_device_add calls probe() */
err
=
platform_device_add
(
pdev
[
i
]);
if
(
err
)
goto
exit_device_put
;
}
/* platform_device_add calls probe() */
err
=
platform_device_add
(
pdev
);
if
(
err
)
{
pr_err
(
"Device addition failed (%d)
\n
"
,
err
);
goto
exit_device_put
;
if
(
!
found
)
{
err
=
-
ENODEV
;
goto
exit_unregister
;
}
return
0
;
exit_device_put:
platform_device_put
(
pdev
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
pdev
);
i
++
)
{
if
(
pdev
[
i
])
platform_device_put
(
pdev
[
i
]);
}
exit_unregister:
platform_driver_unregister
(
&
nct6775_driver
);
exit:
return
err
;
}
static
void
__exit
sensors_nct6775_exit
(
void
)
{
platform_device_unregister
(
pdev
);
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
pdev
);
i
++
)
{
if
(
pdev
[
i
])
platform_device_unregister
(
pdev
[
i
]);
}
platform_driver_unregister
(
&
nct6775_driver
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录