Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
8d373552
Commit
8d373552
authored
Sep 01, 2013
by
Guenter Roeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hwmon: (max6697) Convert to use devm_hwmon_device_register_with_groups
Signed-off-by:
Guenter Roeck
<
linux@roeck-us.net
>
parent
3710263f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
37 deletions
+17
-37
drivers/hwmon/max6697.c
drivers/hwmon/max6697.c
+17
-37
No files found.
drivers/hwmon/max6697.c
View file @
8d373552
...
...
@@ -77,7 +77,7 @@ struct max6697_chip_data {
};
struct
max6697_data
{
struct
device
*
hwmon_dev
;
struct
i2c_client
*
client
;
enum
chips
type
;
const
struct
max6697_chip_data
*
chip
;
...
...
@@ -181,8 +181,8 @@ static const struct max6697_chip_data max6697_chip_data[] = {
static
struct
max6697_data
*
max6697_update_device
(
struct
device
*
dev
)
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
max6697_data
*
data
=
i2c_get_clientdata
(
client
)
;
struct
max6697_data
*
data
=
dev_get_drvdata
(
dev
);
struct
i2c_client
*
client
=
data
->
client
;
struct
max6697_data
*
ret
=
data
;
int
val
;
int
i
;
...
...
@@ -303,8 +303,7 @@ static ssize_t set_temp(struct device *dev,
{
int
nr
=
to_sensor_dev_attr_2
(
devattr
)
->
nr
;
int
index
=
to_sensor_dev_attr_2
(
devattr
)
->
index
;
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
max6697_data
*
data
=
i2c_get_clientdata
(
client
);
struct
max6697_data
*
data
=
dev_get_drvdata
(
dev
);
long
temp
;
int
ret
;
...
...
@@ -316,7 +315,7 @@ static ssize_t set_temp(struct device *dev,
temp
=
DIV_ROUND_CLOSEST
(
temp
,
1000
)
+
data
->
temp_offset
;
temp
=
clamp_val
(
temp
,
0
,
data
->
type
==
max6581
?
255
:
127
);
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
]
:
MAX6697_REG_CRIT
[
nr
],
temp
);
...
...
@@ -405,8 +404,7 @@ static umode_t max6697_is_visible(struct kobject *kobj, struct attribute *attr,
int
index
)
{
struct
device
*
dev
=
container_of
(
kobj
,
struct
device
,
kobj
);
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
max6697_data
*
data
=
i2c_get_clientdata
(
client
);
struct
max6697_data
*
data
=
dev_get_drvdata
(
dev
);
const
struct
max6697_chip_data
*
chip
=
data
->
chip
;
int
channel
=
index
/
6
;
/* channel number */
int
nr
=
index
%
6
;
/* attribute index within channel */
...
...
@@ -489,6 +487,7 @@ static struct attribute *max6697_attributes[] = {
static
const
struct
attribute_group
max6697_group
=
{
.
attrs
=
max6697_attributes
,
.
is_visible
=
max6697_is_visible
,
};
__ATTRIBUTE_GROUPS
(
max6697
);
static
void
max6697_get_config_of
(
struct
device_node
*
node
,
struct
max6697_platform_data
*
pdata
)
...
...
@@ -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
p
;
const
struct
max6697_chip_data
*
chip
=
data
->
chip
;
...
...
@@ -625,6 +624,7 @@ static int max6697_probe(struct i2c_client *client,
struct
i2c_adapter
*
adapter
=
client
->
adapter
;
struct
device
*
dev
=
&
client
->
dev
;
struct
max6697_data
*
data
;
struct
device
*
hwmon_dev
;
int
err
;
if
(
!
i2c_check_functionality
(
adapter
,
I2C_FUNC_SMBUS_BYTE_DATA
))
...
...
@@ -636,37 +636,18 @@ static int max6697_probe(struct i2c_client *client,
data
->
type
=
id
->
driver_data
;
data
->
chip
=
&
max6697_chip_data
[
data
->
type
];
i2c_set_clientdata
(
client
,
data
);
data
->
client
=
client
;
mutex_init
(
&
data
->
update_lock
);
err
=
max6697_init_chip
(
client
);
err
=
max6697_init_chip
(
data
,
client
);
if
(
err
)
return
err
;
err
=
sysfs_create_group
(
&
client
->
dev
.
kobj
,
&
max6697_group
);
if
(
err
)
return
err
;
data
->
hwmon_dev
=
hwmon_device_register
(
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
);
hwmon_dev
=
devm_hwmon_device_register_with_groups
(
dev
,
client
->
name
,
data
,
max6697_groups
);
if
(
IS_ERR
(
hwmon_dev
))
return
PTR_ERR
(
hwmon_dev
);
return
0
;
}
...
...
@@ -692,7 +673,6 @@ static struct i2c_driver max6697_driver = {
.
name
=
"max6697"
,
},
.
probe
=
max6697_probe
,
.
remove
=
max6697_remove
,
.
id_table
=
max6697_id
,
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment