Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
8d373552
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 4 年多
通知
15
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8d373552
编写于
9月 01, 2013
作者:
G
Guenter Roeck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hwmon: (max6697) Convert to use devm_hwmon_device_register_with_groups
Signed-off-by:
N
Guenter Roeck
<
linux@roeck-us.net
>
上级
3710263f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
37 deletion
+17
-37
drivers/hwmon/max6697.c
drivers/hwmon/max6697.c
+17
-37
未找到文件。
drivers/hwmon/max6697.c
浏览文件 @
8d373552
...
@@ -77,7 +77,7 @@ struct max6697_chip_data {
...
@@ -77,7 +77,7 @@ struct max6697_chip_data {
};
};
struct
max6697_data
{
struct
max6697_data
{
struct
device
*
hwmon_dev
;
struct
i2c_client
*
client
;
enum
chips
type
;
enum
chips
type
;
const
struct
max6697_chip_data
*
chip
;
const
struct
max6697_chip_data
*
chip
;
...
@@ -181,8 +181,8 @@ static const struct max6697_chip_data max6697_chip_data[] = {
...
@@ -181,8 +181,8 @@ static const struct max6697_chip_data max6697_chip_data[] = {
static
struct
max6697_data
*
max6697_update_device
(
struct
device
*
dev
)
static
struct
max6697_data
*
max6697_update_device
(
struct
device
*
dev
)
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
max6697_data
*
data
=
dev_get_drvdata
(
dev
);
struct
max6697_data
*
data
=
i2c_get_clientdata
(
client
)
;
struct
i2c_client
*
client
=
data
->
client
;
struct
max6697_data
*
ret
=
data
;
struct
max6697_data
*
ret
=
data
;
int
val
;
int
val
;
int
i
;
int
i
;
...
@@ -303,8 +303,7 @@ static ssize_t set_temp(struct device *dev,
...
@@ -303,8 +303,7 @@ static ssize_t set_temp(struct device *dev,
{
{
int
nr
=
to_sensor_dev_attr_2
(
devattr
)
->
nr
;
int
nr
=
to_sensor_dev_attr_2
(
devattr
)
->
nr
;
int
index
=
to_sensor_dev_attr_2
(
devattr
)
->
index
;
int
index
=
to_sensor_dev_attr_2
(
devattr
)
->
index
;
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
max6697_data
*
data
=
dev_get_drvdata
(
dev
);
struct
max6697_data
*
data
=
i2c_get_clientdata
(
client
);
long
temp
;
long
temp
;
int
ret
;
int
ret
;
...
@@ -316,7 +315,7 @@ static ssize_t set_temp(struct device *dev,
...
@@ -316,7 +315,7 @@ static ssize_t set_temp(struct device *dev,
temp
=
DIV_ROUND_CLOSEST
(
temp
,
1000
)
+
data
->
temp_offset
;
temp
=
DIV_ROUND_CLOSEST
(
temp
,
1000
)
+
data
->
temp_offset
;
temp
=
clamp_val
(
temp
,
0
,
data
->
type
==
max6581
?
255
:
127
);
temp
=
clamp_val
(
temp
,
0
,
data
->
type
==
max6581
?
255
:
127
);
data
->
temp
[
nr
][
index
]
=
temp
;
data
->
temp
[
nr
][
index
]
=
temp
;
ret
=
i2c_smbus_write_byte_data
(
client
,
ret
=
i2c_smbus_write_byte_data
(
data
->
client
,
index
==
2
?
MAX6697_REG_MAX
[
nr
]
index
==
2
?
MAX6697_REG_MAX
[
nr
]
:
MAX6697_REG_CRIT
[
nr
],
:
MAX6697_REG_CRIT
[
nr
],
temp
);
temp
);
...
@@ -405,8 +404,7 @@ static umode_t max6697_is_visible(struct kobject *kobj, struct attribute *attr,
...
@@ -405,8 +404,7 @@ static umode_t max6697_is_visible(struct kobject *kobj, struct attribute *attr,
int
index
)
int
index
)
{
{
struct
device
*
dev
=
container_of
(
kobj
,
struct
device
,
kobj
);
struct
device
*
dev
=
container_of
(
kobj
,
struct
device
,
kobj
);
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
max6697_data
*
data
=
dev_get_drvdata
(
dev
);
struct
max6697_data
*
data
=
i2c_get_clientdata
(
client
);
const
struct
max6697_chip_data
*
chip
=
data
->
chip
;
const
struct
max6697_chip_data
*
chip
=
data
->
chip
;
int
channel
=
index
/
6
;
/* channel number */
int
channel
=
index
/
6
;
/* channel number */
int
nr
=
index
%
6
;
/* attribute index within channel */
int
nr
=
index
%
6
;
/* attribute index within channel */
...
@@ -489,6 +487,7 @@ static struct attribute *max6697_attributes[] = {
...
@@ -489,6 +487,7 @@ static struct attribute *max6697_attributes[] = {
static
const
struct
attribute_group
max6697_group
=
{
static
const
struct
attribute_group
max6697_group
=
{
.
attrs
=
max6697_attributes
,
.
is_visible
=
max6697_is_visible
,
.
attrs
=
max6697_attributes
,
.
is_visible
=
max6697_is_visible
,
};
};
__ATTRIBUTE_GROUPS
(
max6697
);
static
void
max6697_get_config_of
(
struct
device_node
*
node
,
static
void
max6697_get_config_of
(
struct
device_node
*
node
,
struct
max6697_platform_data
*
pdata
)
struct
max6697_platform_data
*
pdata
)
...
@@ -525,9 +524,9 @@ static void max6697_get_config_of(struct device_node *node,
...
@@ -525,9 +524,9 @@ static void max6697_get_config_of(struct device_node *node,
}
}
}
}
static
int
max6697_init_chip
(
struct
i2c_client
*
client
)
static
int
max6697_init_chip
(
struct
max6697_data
*
data
,
struct
i2c_client
*
client
)
{
{
struct
max6697_data
*
data
=
i2c_get_clientdata
(
client
);
struct
max6697_platform_data
*
pdata
=
dev_get_platdata
(
&
client
->
dev
);
struct
max6697_platform_data
*
pdata
=
dev_get_platdata
(
&
client
->
dev
);
struct
max6697_platform_data
p
;
struct
max6697_platform_data
p
;
const
struct
max6697_chip_data
*
chip
=
data
->
chip
;
const
struct
max6697_chip_data
*
chip
=
data
->
chip
;
...
@@ -625,6 +624,7 @@ static int max6697_probe(struct i2c_client *client,
...
@@ -625,6 +624,7 @@ static int max6697_probe(struct i2c_client *client,
struct
i2c_adapter
*
adapter
=
client
->
adapter
;
struct
i2c_adapter
*
adapter
=
client
->
adapter
;
struct
device
*
dev
=
&
client
->
dev
;
struct
device
*
dev
=
&
client
->
dev
;
struct
max6697_data
*
data
;
struct
max6697_data
*
data
;
struct
device
*
hwmon_dev
;
int
err
;
int
err
;
if
(
!
i2c_check_functionality
(
adapter
,
I2C_FUNC_SMBUS_BYTE_DATA
))
if
(
!
i2c_check_functionality
(
adapter
,
I2C_FUNC_SMBUS_BYTE_DATA
))
...
@@ -636,37 +636,18 @@ static int max6697_probe(struct i2c_client *client,
...
@@ -636,37 +636,18 @@ static int max6697_probe(struct i2c_client *client,
data
->
type
=
id
->
driver_data
;
data
->
type
=
id
->
driver_data
;
data
->
chip
=
&
max6697_chip_data
[
data
->
type
];
data
->
chip
=
&
max6697_chip_data
[
data
->
type
];
data
->
client
=
client
;
i2c_set_clientdata
(
client
,
data
);
mutex_init
(
&
data
->
update_lock
);
mutex_init
(
&
data
->
update_lock
);
err
=
max6697_init_chip
(
client
);
err
=
max6697_init_chip
(
data
,
client
);
if
(
err
)
if
(
err
)
return
err
;
return
err
;
err
=
sysfs_create_group
(
&
client
->
dev
.
kobj
,
&
max6697_group
);
hwmon_dev
=
devm_hwmon_device_register_with_groups
(
dev
,
client
->
name
,
if
(
err
)
data
,
return
err
;
max6697_groups
);
if
(
IS_ERR
(
hwmon_dev
))
data
->
hwmon_dev
=
hwmon_device_register
(
dev
);
return
PTR_ERR
(
hwmon_dev
);
if
(
IS_ERR
(
data
->
hwmon_dev
))
{
err
=
PTR_ERR
(
data
->
hwmon_dev
);
goto
error
;
}
return
0
;
error:
sysfs_remove_group
(
&
client
->
dev
.
kobj
,
&
max6697_group
);
return
err
;
}
static
int
max6697_remove
(
struct
i2c_client
*
client
)
{
struct
max6697_data
*
data
=
i2c_get_clientdata
(
client
);
hwmon_device_unregister
(
data
->
hwmon_dev
);
sysfs_remove_group
(
&
client
->
dev
.
kobj
,
&
max6697_group
);
return
0
;
return
0
;
}
}
...
@@ -692,7 +673,6 @@ static struct i2c_driver max6697_driver = {
...
@@ -692,7 +673,6 @@ static struct i2c_driver max6697_driver = {
.
name
=
"max6697"
,
.
name
=
"max6697"
,
},
},
.
probe
=
max6697_probe
,
.
probe
=
max6697_probe
,
.
remove
=
max6697_remove
,
.
id_table
=
max6697_id
,
.
id_table
=
max6697_id
,
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录