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
615fc8cb
Commit
615fc8cb
authored
Jul 06, 2013
by
Guenter Roeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hwmon: (nct6775) Convert to use hwmon_device_register_with_groups
Signed-off-by:
Guenter Roeck
<
linux@roeck-us.net
>
parent
c3b7cddc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
86 deletions
+36
-86
drivers/hwmon/nct6775.c
drivers/hwmon/nct6775.c
+36
-86
No files found.
drivers/hwmon/nct6775.c
View file @
615fc8cb
...
@@ -725,10 +725,9 @@ struct nct6775_data {
...
@@ -725,10 +725,9 @@ struct nct6775_data {
const
char
*
name
;
const
char
*
name
;
struct
device
*
hwmon_dev
;
struct
device
*
hwmon_dev
;
struct
attribute_group
*
group_in
;
struct
attribute_group
*
group_fan
;
int
num_attr_groups
;
struct
attribute_group
*
group_temp
;
const
struct
attribute_group
*
groups
[
6
];
struct
attribute_group
*
group_pwm
;
u16
reg_temp
[
5
][
NUM_TEMP
];
/* 0=temp, 1=temp_over, 2=temp_hyst,
u16
reg_temp
[
5
][
NUM_TEMP
];
/* 0=temp, 1=temp_over, 2=temp_hyst,
* 3=temp_crit, 4=temp_lcrit
* 3=temp_crit, 4=temp_lcrit
...
@@ -942,7 +941,7 @@ nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
...
@@ -942,7 +941,7 @@ nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
struct
sensor_device_attribute_2
*
a2
;
struct
sensor_device_attribute_2
*
a2
;
struct
attribute
**
attrs
;
struct
attribute
**
attrs
;
struct
sensor_device_template
**
t
;
struct
sensor_device_template
**
t
;
int
err
,
i
,
j
,
count
;
int
i
,
j
,
count
;
if
(
repeat
<=
0
)
if
(
repeat
<=
0
)
return
ERR_PTR
(
-
EINVAL
);
return
ERR_PTR
(
-
EINVAL
);
...
@@ -1002,10 +1001,6 @@ nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
...
@@ -1002,10 +1001,6 @@ nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
}
}
}
}
err
=
sysfs_create_group
(
&
dev
->
kobj
,
group
);
if
(
err
)
return
ERR_PTR
(
-
ENOMEM
);
return
group
;
return
group
;
}
}
...
@@ -2726,16 +2721,6 @@ store_fan_time(struct device *dev, struct device_attribute *attr,
...
@@ -2726,16 +2721,6 @@ store_fan_time(struct device *dev, struct device_attribute *attr,
return
count
;
return
count
;
}
}
static
ssize_t
show_name
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
struct
nct6775_data
*
data
=
dev_get_drvdata
(
dev
);
return
sprintf
(
buf
,
"%s
\n
"
,
data
->
name
);
}
static
DEVICE_ATTR
(
name
,
S_IRUGO
,
show_name
,
NULL
);
static
ssize_t
static
ssize_t
show_auto_pwm
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
show_auto_pwm
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
{
...
@@ -3062,16 +3047,16 @@ static umode_t nct6775_other_is_visible(struct kobject *kobj,
...
@@ -3062,16 +3047,16 @@ static umode_t nct6775_other_is_visible(struct kobject *kobj,
struct
device
*
dev
=
container_of
(
kobj
,
struct
device
,
kobj
);
struct
device
*
dev
=
container_of
(
kobj
,
struct
device
,
kobj
);
struct
nct6775_data
*
data
=
dev_get_drvdata
(
dev
);
struct
nct6775_data
*
data
=
dev_get_drvdata
(
dev
);
if
(
index
==
1
&&
!
data
->
have_vid
)
if
(
index
==
0
&&
!
data
->
have_vid
)
return
0
;
return
0
;
if
(
index
==
2
||
index
==
3
)
{
if
(
index
==
1
||
index
==
2
)
{
if
(
data
->
ALARM_BITS
[
INTRUSION_ALARM_BASE
+
index
-
2
]
<
0
)
if
(
data
->
ALARM_BITS
[
INTRUSION_ALARM_BASE
+
index
-
1
]
<
0
)
return
0
;
return
0
;
}
}
if
(
index
==
4
||
index
==
5
)
{
if
(
index
==
3
||
index
==
4
)
{
if
(
data
->
BEEP_BITS
[
INTRUSION_ALARM_BASE
+
index
-
4
]
<
0
)
if
(
data
->
BEEP_BITS
[
INTRUSION_ALARM_BASE
+
index
-
3
]
<
0
)
return
0
;
return
0
;
}
}
...
@@ -3084,13 +3069,12 @@ static umode_t nct6775_other_is_visible(struct kobject *kobj,
...
@@ -3084,13 +3069,12 @@ static umode_t nct6775_other_is_visible(struct kobject *kobj,
* Any change in order or content must be matched.
* Any change in order or content must be matched.
*/
*/
static
struct
attribute
*
nct6775_attributes_other
[]
=
{
static
struct
attribute
*
nct6775_attributes_other
[]
=
{
&
dev_attr_name
.
attr
,
&
dev_attr_cpu0_vid
.
attr
,
/* 0 */
&
dev_attr_cpu0_vid
.
attr
,
/* 1 */
&
sensor_dev_attr_intrusion0_alarm
.
dev_attr
.
attr
,
/* 1 */
&
sensor_dev_attr_intrusion0_alarm
.
dev_attr
.
attr
,
/* 2 */
&
sensor_dev_attr_intrusion1_alarm
.
dev_attr
.
attr
,
/* 2 */
&
sensor_dev_attr_intrusion1_alarm
.
dev_attr
.
attr
,
/* 3 */
&
sensor_dev_attr_intrusion0_beep
.
dev_attr
.
attr
,
/* 3 */
&
sensor_dev_attr_intrusion0_beep
.
dev_attr
.
attr
,
/* 4 */
&
sensor_dev_attr_intrusion1_beep
.
dev_attr
.
attr
,
/* 4 */
&
sensor_dev_attr_intrusion1_beep
.
dev_attr
.
attr
,
/* 5 */
&
sensor_dev_attr_beep_enable
.
dev_attr
.
attr
,
/* 5 */
&
sensor_dev_attr_beep_enable
.
dev_attr
.
attr
,
/* 6 */
NULL
NULL
};
};
...
@@ -3100,27 +3084,6 @@ static const struct attribute_group nct6775_group_other = {
...
@@ -3100,27 +3084,6 @@ static const struct attribute_group nct6775_group_other = {
.
is_visible
=
nct6775_other_is_visible
,
.
is_visible
=
nct6775_other_is_visible
,
};
};
/*
* Driver and device management
*/
static
void
nct6775_device_remove_files
(
struct
device
*
dev
)
{
struct
nct6775_data
*
data
=
dev_get_drvdata
(
dev
);
if
(
data
->
group_pwm
)
sysfs_remove_group
(
&
dev
->
kobj
,
data
->
group_pwm
);
if
(
data
->
group_in
)
sysfs_remove_group
(
&
dev
->
kobj
,
data
->
group_in
);
if
(
data
->
group_fan
)
sysfs_remove_group
(
&
dev
->
kobj
,
data
->
group_fan
);
if
(
data
->
group_temp
)
sysfs_remove_group
(
&
dev
->
kobj
,
data
->
group_temp
);
sysfs_remove_group
(
&
dev
->
kobj
,
&
nct6775_group_other
);
}
/* Get the monitoring functions started */
static
inline
void
nct6775_init_device
(
struct
nct6775_data
*
data
)
static
inline
void
nct6775_init_device
(
struct
nct6775_data
*
data
)
{
{
int
i
;
int
i
;
...
@@ -3871,51 +3834,39 @@ static int nct6775_probe(struct platform_device *pdev)
...
@@ -3871,51 +3834,39 @@ static int nct6775_probe(struct platform_device *pdev)
/* Register sysfs hooks */
/* Register sysfs hooks */
group
=
nct6775_create_attr_group
(
dev
,
&
nct6775_pwm_template_group
,
group
=
nct6775_create_attr_group
(
dev
,
&
nct6775_pwm_template_group
,
data
->
pwm_num
);
data
->
pwm_num
);
if
(
IS_ERR
(
group
))
{
if
(
IS_ERR
(
group
))
err
=
PTR_ERR
(
group
);
return
PTR_ERR
(
group
);
goto
exit_remove
;
}
data
->
groups
[
data
->
num_attr_groups
++
]
=
group
;
data
->
group_pwm
=
group
;
group
=
nct6775_create_attr_group
(
dev
,
&
nct6775_in_template_group
,
group
=
nct6775_create_attr_group
(
dev
,
&
nct6775_in_template_group
,
fls
(
data
->
have_in
));
fls
(
data
->
have_in
));
if
(
IS_ERR
(
group
))
{
if
(
IS_ERR
(
group
))
err
=
PTR_ERR
(
group
);
return
PTR_ERR
(
group
);
goto
exit_remove
;
}
data
->
groups
[
data
->
num_attr_groups
++
]
=
group
;
data
->
group_in
=
group
;
group
=
nct6775_create_attr_group
(
dev
,
&
nct6775_fan_template_group
,
group
=
nct6775_create_attr_group
(
dev
,
&
nct6775_fan_template_group
,
fls
(
data
->
has_fan
));
fls
(
data
->
has_fan
));
if
(
IS_ERR
(
group
))
{
if
(
IS_ERR
(
group
))
err
=
PTR_ERR
(
group
);
return
PTR_ERR
(
group
);
goto
exit_remove
;
}
data
->
groups
[
data
->
num_attr_groups
++
]
=
group
;
data
->
group_fan
=
group
;
group
=
nct6775_create_attr_group
(
dev
,
&
nct6775_temp_template_group
,
group
=
nct6775_create_attr_group
(
dev
,
&
nct6775_temp_template_group
,
fls
(
data
->
have_temp
));
fls
(
data
->
have_temp
));
if
(
IS_ERR
(
group
))
{
if
(
IS_ERR
(
group
))
err
=
PTR_ERR
(
group
);
return
PTR_ERR
(
group
);
goto
exit_remove
;
}
data
->
group_temp
=
group
;
err
=
sysfs_create_group
(
&
dev
->
kobj
,
&
nct6775_group_other
);
data
->
groups
[
data
->
num_attr_groups
++
]
=
group
;
if
(
err
)
data
->
groups
[
data
->
num_attr_groups
++
]
=
&
nct6775_group_other
;
goto
exit_remove
;
data
->
hwmon_dev
=
hwmon_device_register
(
dev
);
data
->
hwmon_dev
=
hwmon_device_register_with_groups
(
dev
,
data
->
name
,
if
(
IS_ERR
(
data
->
hwmon_dev
))
{
data
,
data
->
groups
);
err
=
PTR_ERR
(
data
->
hwmon_dev
);
if
(
IS_ERR
(
data
->
hwmon_dev
))
goto
exit_remove
;
return
PTR_ERR
(
data
->
hwmon_dev
);
}
return
0
;
return
0
;
exit_remove:
nct6775_device_remove_files
(
dev
);
return
err
;
}
}
static
int
nct6775_remove
(
struct
platform_device
*
pdev
)
static
int
nct6775_remove
(
struct
platform_device
*
pdev
)
...
@@ -3923,7 +3874,6 @@ static int nct6775_remove(struct platform_device *pdev)
...
@@ -3923,7 +3874,6 @@ static int nct6775_remove(struct platform_device *pdev)
struct
nct6775_data
*
data
=
platform_get_drvdata
(
pdev
);
struct
nct6775_data
*
data
=
platform_get_drvdata
(
pdev
);
hwmon_device_unregister
(
data
->
hwmon_dev
);
hwmon_device_unregister
(
data
->
hwmon_dev
);
nct6775_device_remove_files
(
&
pdev
->
dev
);
return
0
;
return
0
;
}
}
...
@@ -4102,7 +4052,7 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
...
@@ -4102,7 +4052,7 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
/*
/*
* when Super-I/O functions move to a separate file, the Super-I/O
* when Super-I/O functions move to a separate file, the Super-I/O
* bus will manage the lifetime of the device and this module will only keep
* bus will manage the lifetime of the device and this module will only keep
* track of the nct6775 driver. But since we platform_device_alloc(), we
* track of the nct6775 driver. But since we
use
platform_device_alloc(), we
* must keep track of the device
* must keep track of the device
*/
*/
static
struct
platform_device
*
pdev
[
2
];
static
struct
platform_device
*
pdev
[
2
];
...
...
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