pc87360: Delete sysfs files on device deletion
pc87360: Delete sysfs files on device deletion Add 4 explicit attribute groups for the 5 sensor types: voltage (in), therm, temp, and fan & pwm (together in one group). Use sysfs_remove_group() to drop them, but keeps the existing startup code, which calls device_create_file in loops. Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
44646c19b4
commit
941c5c05cf
@@ -328,6 +328,12 @@ static struct sensor_device_attribute fan_min[] = {
|
|||||||
SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2),
|
SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define FAN_UNIT_ATTRS(X) \
|
||||||
|
&fan_input[X].dev_attr.attr, \
|
||||||
|
&fan_status[X].dev_attr.attr, \
|
||||||
|
&fan_div[X].dev_attr.attr, \
|
||||||
|
&fan_min[X].dev_attr.attr
|
||||||
|
|
||||||
static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||||
@@ -360,6 +366,19 @@ static struct sensor_device_attribute pwm[] = {
|
|||||||
SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2),
|
SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct attribute * pc8736x_fan_attr_array[] = {
|
||||||
|
FAN_UNIT_ATTRS(0),
|
||||||
|
FAN_UNIT_ATTRS(1),
|
||||||
|
FAN_UNIT_ATTRS(2),
|
||||||
|
&pwm[0].dev_attr.attr,
|
||||||
|
&pwm[1].dev_attr.attr,
|
||||||
|
&pwm[2].dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
static const struct attribute_group pc8736x_fan_group = {
|
||||||
|
.attrs = pc8736x_fan_attr_array,
|
||||||
|
};
|
||||||
|
|
||||||
static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||||
@@ -472,6 +491,12 @@ static struct sensor_device_attribute in_max[] = {
|
|||||||
SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10),
|
SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define VIN_UNIT_ATTRS(X) \
|
||||||
|
&in_input[X].dev_attr.attr, \
|
||||||
|
&in_status[X].dev_attr.attr, \
|
||||||
|
&in_min[X].dev_attr.attr, \
|
||||||
|
&in_max[X].dev_attr.attr
|
||||||
|
|
||||||
static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
|
static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct pc87360_data *data = pc87360_update_device(dev);
|
struct pc87360_data *data = pc87360_update_device(dev);
|
||||||
@@ -500,6 +525,27 @@ static ssize_t show_in_alarms(struct device *dev, struct device_attribute *attr,
|
|||||||
}
|
}
|
||||||
static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL);
|
static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL);
|
||||||
|
|
||||||
|
static struct attribute *pc8736x_vin_attr_array[] = {
|
||||||
|
VIN_UNIT_ATTRS(0),
|
||||||
|
VIN_UNIT_ATTRS(1),
|
||||||
|
VIN_UNIT_ATTRS(2),
|
||||||
|
VIN_UNIT_ATTRS(3),
|
||||||
|
VIN_UNIT_ATTRS(4),
|
||||||
|
VIN_UNIT_ATTRS(5),
|
||||||
|
VIN_UNIT_ATTRS(6),
|
||||||
|
VIN_UNIT_ATTRS(7),
|
||||||
|
VIN_UNIT_ATTRS(8),
|
||||||
|
VIN_UNIT_ATTRS(9),
|
||||||
|
VIN_UNIT_ATTRS(10),
|
||||||
|
&dev_attr_cpu0_vid.attr,
|
||||||
|
&dev_attr_vrm.attr,
|
||||||
|
&dev_attr_alarms_in.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
static const struct attribute_group pc8736x_vin_group = {
|
||||||
|
.attrs = pc8736x_vin_attr_array,
|
||||||
|
};
|
||||||
|
|
||||||
static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||||
@@ -618,6 +664,23 @@ static struct sensor_device_attribute therm_crit[] = {
|
|||||||
show_therm_crit, set_therm_crit, 2+11),
|
show_therm_crit, set_therm_crit, 2+11),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define THERM_UNIT_ATTRS(X) \
|
||||||
|
&therm_input[X].dev_attr.attr, \
|
||||||
|
&therm_status[X].dev_attr.attr, \
|
||||||
|
&therm_min[X].dev_attr.attr, \
|
||||||
|
&therm_max[X].dev_attr.attr, \
|
||||||
|
&therm_crit[X].dev_attr.attr
|
||||||
|
|
||||||
|
static struct attribute * pc8736x_therm_attr_array[] = {
|
||||||
|
THERM_UNIT_ATTRS(0),
|
||||||
|
THERM_UNIT_ATTRS(1),
|
||||||
|
THERM_UNIT_ATTRS(2),
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
static const struct attribute_group pc8736x_therm_group = {
|
||||||
|
.attrs = pc8736x_therm_attr_array,
|
||||||
|
};
|
||||||
|
|
||||||
static ssize_t show_temp_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t show_temp_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||||
@@ -736,6 +799,25 @@ static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *att
|
|||||||
}
|
}
|
||||||
static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL);
|
static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL);
|
||||||
|
|
||||||
|
#define TEMP_UNIT_ATTRS(X) \
|
||||||
|
&temp_input[X].dev_attr.attr, \
|
||||||
|
&temp_status[X].dev_attr.attr, \
|
||||||
|
&temp_min[X].dev_attr.attr, \
|
||||||
|
&temp_max[X].dev_attr.attr, \
|
||||||
|
&temp_crit[X].dev_attr.attr
|
||||||
|
|
||||||
|
static struct attribute * pc8736x_temp_attr_array[] = {
|
||||||
|
TEMP_UNIT_ATTRS(0),
|
||||||
|
TEMP_UNIT_ATTRS(1),
|
||||||
|
TEMP_UNIT_ATTRS(2),
|
||||||
|
/* include the few miscellaneous atts here */
|
||||||
|
&dev_attr_alarms_temp.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
static const struct attribute_group pc8736x_temp_group = {
|
||||||
|
.attrs = pc8736x_temp_attr_array,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Device detection, registration and update
|
* Device detection, registration and update
|
||||||
*/
|
*/
|
||||||
@@ -1009,6 +1091,11 @@ static int pc87360_detach_client(struct i2c_client *client)
|
|||||||
|
|
||||||
hwmon_device_unregister(data->class_dev);
|
hwmon_device_unregister(data->class_dev);
|
||||||
|
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &pc8736x_temp_group);
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &pc8736x_fan_group);
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &pc8736x_therm_group);
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &pc8736x_vin_group);
|
||||||
|
|
||||||
if ((i = i2c_detach_client(client)))
|
if ((i = i2c_detach_client(client)))
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user