Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
62f9a57c
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看板
提交
62f9a57c
编写于
9月 05, 2013
作者:
G
Guenter Roeck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hwmon: (jc42) Convert to use devm_hwmon_device_register_with_groups
Signed-off-by:
N
Guenter Roeck
<
linux@roeck-us.net
>
上级
38f150fe
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
25 addition
and
36 deletion
+25
-36
drivers/hwmon/jc42.c
drivers/hwmon/jc42.c
+25
-36
未找到文件。
drivers/hwmon/jc42.c
浏览文件 @
62f9a57c
...
@@ -163,7 +163,7 @@ static struct jc42_chips jc42_chips[] = {
...
@@ -163,7 +163,7 @@ static struct jc42_chips jc42_chips[] = {
/* Each client has this additional data */
/* Each client has this additional data */
struct
jc42_data
{
struct
jc42_data
{
struct
device
*
hwmon_dev
;
struct
i2c_client
*
client
;
struct
mutex
update_lock
;
/* protect register access */
struct
mutex
update_lock
;
/* protect register access */
bool
extended
;
/* true if extended range supported */
bool
extended
;
/* true if extended range supported */
bool
valid
;
bool
valid
;
...
@@ -193,21 +193,21 @@ MODULE_DEVICE_TABLE(i2c, jc42_id);
...
@@ -193,21 +193,21 @@ MODULE_DEVICE_TABLE(i2c, jc42_id);
static
int
jc42_suspend
(
struct
device
*
dev
)
static
int
jc42_suspend
(
struct
device
*
dev
)
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
jc42_data
*
data
=
dev_get_drvdata
(
dev
);
struct
jc42_data
*
data
=
i2c_get_clientdata
(
client
);
data
->
config
|=
JC42_CFG_SHUTDOWN
;
data
->
config
|=
JC42_CFG_SHUTDOWN
;
i2c_smbus_write_word_swapped
(
client
,
JC42_REG_CONFIG
,
data
->
config
);
i2c_smbus_write_word_swapped
(
data
->
client
,
JC42_REG_CONFIG
,
data
->
config
);
return
0
;
return
0
;
}
}
static
int
jc42_resume
(
struct
device
*
dev
)
static
int
jc42_resume
(
struct
device
*
dev
)
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
jc42_data
*
data
=
dev_get_drvdata
(
dev
);
struct
jc42_data
*
data
=
i2c_get_clientdata
(
client
);
data
->
config
&=
~
JC42_CFG_SHUTDOWN
;
data
->
config
&=
~
JC42_CFG_SHUTDOWN
;
i2c_smbus_write_word_swapped
(
client
,
JC42_REG_CONFIG
,
data
->
config
);
i2c_smbus_write_word_swapped
(
data
->
client
,
JC42_REG_CONFIG
,
data
->
config
);
return
0
;
return
0
;
}
}
...
@@ -317,15 +317,14 @@ static ssize_t set_##value(struct device *dev, \
...
@@ -317,15 +317,14 @@ static ssize_t set_##value(struct device *dev, \
struct device_attribute *attr, \
struct device_attribute *attr, \
const char *buf, size_t count) \
const char *buf, size_t count) \
{ \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct jc42_data *data = dev_get_drvdata(dev); \
struct jc42_data *data = i2c_get_clientdata(client); \
int err, ret = count; \
int err, ret = count; \
long val; \
long val; \
if (kstrtol(buf, 10, &val) < 0) \
if (kstrtol(buf, 10, &val) < 0) \
return -EINVAL; \
return -EINVAL; \
mutex_lock(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = jc42_temp_to_reg(val, data->extended); \
data->value = jc42_temp_to_reg(val, data->extended); \
err = i2c_smbus_write_word_swapped(
client, reg, data->value);
\
err = i2c_smbus_write_word_swapped(
data->client, reg, data->value);
\
if (err < 0) \
if (err < 0) \
ret = err; \
ret = err; \
mutex_unlock(&data->update_lock); \
mutex_unlock(&data->update_lock); \
...
@@ -344,8 +343,7 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
...
@@ -344,8 +343,7 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
struct
device_attribute
*
attr
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
const
char
*
buf
,
size_t
count
)
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
jc42_data
*
data
=
dev_get_drvdata
(
dev
);
struct
jc42_data
*
data
=
i2c_get_clientdata
(
client
);
unsigned
long
val
;
unsigned
long
val
;
int
diff
,
hyst
;
int
diff
,
hyst
;
int
err
;
int
err
;
...
@@ -368,7 +366,7 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
...
@@ -368,7 +366,7 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
mutex_lock
(
&
data
->
update_lock
);
mutex_lock
(
&
data
->
update_lock
);
data
->
config
=
(
data
->
config
&
~
JC42_CFG_HYST_MASK
)
data
->
config
=
(
data
->
config
&
~
JC42_CFG_HYST_MASK
)
|
(
hyst
<<
JC42_CFG_HYST_SHIFT
);
|
(
hyst
<<
JC42_CFG_HYST_SHIFT
);
err
=
i2c_smbus_write_word_swapped
(
client
,
JC42_REG_CONFIG
,
err
=
i2c_smbus_write_word_swapped
(
data
->
client
,
JC42_REG_CONFIG
,
data
->
config
);
data
->
config
);
if
(
err
<
0
)
if
(
err
<
0
)
ret
=
err
;
ret
=
err
;
...
@@ -430,8 +428,7 @@ static umode_t jc42_attribute_mode(struct kobject *kobj,
...
@@ -430,8 +428,7 @@ static umode_t jc42_attribute_mode(struct kobject *kobj,
struct
attribute
*
attr
,
int
index
)
struct
attribute
*
attr
,
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
jc42_data
*
data
=
dev_get_drvdata
(
dev
);
struct
jc42_data
*
data
=
i2c_get_clientdata
(
client
);
unsigned
int
config
=
data
->
config
;
unsigned
int
config
=
data
->
config
;
bool
readonly
;
bool
readonly
;
...
@@ -452,6 +449,7 @@ static const struct attribute_group jc42_group = {
...
@@ -452,6 +449,7 @@ static const struct attribute_group jc42_group = {
.
attrs
=
jc42_attributes
,
.
attrs
=
jc42_attributes
,
.
is_visible
=
jc42_attribute_mode
,
.
is_visible
=
jc42_attribute_mode
,
};
};
__ATTRIBUTE_GROUPS
(
jc42
);
/* Return 0 if detection is successful, -ENODEV otherwise */
/* Return 0 if detection is successful, -ENODEV otherwise */
static
int
jc42_detect
(
struct
i2c_client
*
client
,
struct
i2c_board_info
*
info
)
static
int
jc42_detect
(
struct
i2c_client
*
client
,
struct
i2c_board_info
*
info
)
...
@@ -487,14 +485,16 @@ static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info)
...
@@ -487,14 +485,16 @@ static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info)
static
int
jc42_probe
(
struct
i2c_client
*
client
,
const
struct
i2c_device_id
*
id
)
static
int
jc42_probe
(
struct
i2c_client
*
client
,
const
struct
i2c_device_id
*
id
)
{
{
struct
jc42_data
*
data
;
int
config
,
cap
,
err
;
struct
device
*
dev
=
&
client
->
dev
;
struct
device
*
dev
=
&
client
->
dev
;
struct
device
*
hwmon_dev
;
struct
jc42_data
*
data
;
int
config
,
cap
;
data
=
devm_kzalloc
(
dev
,
sizeof
(
struct
jc42_data
),
GFP_KERNEL
);
data
=
devm_kzalloc
(
dev
,
sizeof
(
struct
jc42_data
),
GFP_KERNEL
);
if
(
!
data
)
if
(
!
data
)
return
-
ENOMEM
;
return
-
ENOMEM
;
data
->
client
=
client
;
i2c_set_clientdata
(
client
,
data
);
i2c_set_clientdata
(
client
,
data
);
mutex_init
(
&
data
->
update_lock
);
mutex_init
(
&
data
->
update_lock
);
...
@@ -515,29 +515,18 @@ static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id)
...
@@ -515,29 +515,18 @@ static int jc42_probe(struct i2c_client *client, const struct i2c_device_id *id)
}
}
data
->
config
=
config
;
data
->
config
=
config
;
/* Register sysfs hooks */
hwmon_dev
=
devm_hwmon_device_register_with_groups
(
dev
,
client
->
name
,
err
=
sysfs_create_group
(
&
dev
->
kobj
,
&
jc42_group
);
data
,
if
(
err
)
jc42_groups
);
return
err
;
if
(
IS_ERR
(
hwmon_dev
))
return
PTR_ERR
(
hwmon_dev
);
data
->
hwmon_dev
=
hwmon_device_register
(
dev
);
if
(
IS_ERR
(
data
->
hwmon_dev
))
{
err
=
PTR_ERR
(
data
->
hwmon_dev
);
goto
exit_remove
;
}
return
0
;
return
0
;
exit_remove:
sysfs_remove_group
(
&
dev
->
kobj
,
&
jc42_group
);
return
err
;
}
}
static
int
jc42_remove
(
struct
i2c_client
*
client
)
static
int
jc42_remove
(
struct
i2c_client
*
client
)
{
{
struct
jc42_data
*
data
=
i2c_get_clientdata
(
client
);
struct
jc42_data
*
data
=
i2c_get_clientdata
(
client
);
hwmon_device_unregister
(
data
->
hwmon_dev
);
sysfs_remove_group
(
&
client
->
dev
.
kobj
,
&
jc42_group
);
/* Restore original configuration except hysteresis */
/* Restore original configuration except hysteresis */
if
((
data
->
config
&
~
JC42_CFG_HYST_MASK
)
!=
if
((
data
->
config
&
~
JC42_CFG_HYST_MASK
)
!=
...
@@ -553,8 +542,8 @@ static int jc42_remove(struct i2c_client *client)
...
@@ -553,8 +542,8 @@ static int jc42_remove(struct i2c_client *client)
static
struct
jc42_data
*
jc42_update_device
(
struct
device
*
dev
)
static
struct
jc42_data
*
jc42_update_device
(
struct
device
*
dev
)
{
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
jc42_data
*
data
=
dev_get_drvdata
(
dev
);
struct
jc42_data
*
data
=
i2c_get_clientdata
(
client
)
;
struct
i2c_client
*
client
=
data
->
client
;
struct
jc42_data
*
ret
=
data
;
struct
jc42_data
*
ret
=
data
;
int
val
;
int
val
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录