Commit c1685f61 authored by Mark M. Hoffman's avatar Mark M. Hoffman Committed by Greg Kroah-Hartman

hwmon: Fix unchecked return status, batch 1

hwmon: Fix unchecked return status, batch 1

Fix up some hwmon drivers so that they no longer ignore return status
from device_create_file().
Signed-off-by: default avatarMark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent a1fdcb96
...@@ -298,12 +298,6 @@ sysfs_in(4); ...@@ -298,12 +298,6 @@ sysfs_in(4);
sysfs_in(5); sysfs_in(5);
sysfs_in(6); sysfs_in(6);
#define device_create_file_in(client, offset) do { \
device_create_file(&client->dev, &dev_attr_in##offset##_input); \
device_create_file(&client->dev, &dev_attr_in##offset##_min); \
device_create_file(&client->dev, &dev_attr_in##offset##_max); \
} while (0)
/* 3 Fans */ /* 3 Fans */
static ssize_t show_fan(struct device *dev, char *buf, int nr) static ssize_t show_fan(struct device *dev, char *buf, int nr)
{ {
...@@ -421,12 +415,6 @@ sysfs_fan(1); ...@@ -421,12 +415,6 @@ sysfs_fan(1);
sysfs_fan(2); sysfs_fan(2);
sysfs_fan(3); sysfs_fan(3);
#define device_create_file_fan(client, offset) do { \
device_create_file(&client->dev, &dev_attr_fan##offset##_input); \
device_create_file(&client->dev, &dev_attr_fan##offset##_min); \
device_create_file(&client->dev, &dev_attr_fan##offset##_div); \
} while (0)
/* 4 Temp. Sensors */ /* 4 Temp. Sensors */
static int sprintf_temp_from_reg(u16 reg, char *buf, int nr) static int sprintf_temp_from_reg(u16 reg, char *buf, int nr)
{ {
...@@ -515,12 +503,6 @@ sysfs_temp(3); ...@@ -515,12 +503,6 @@ sysfs_temp(3);
sysfs_temp(4); sysfs_temp(4);
/* VID */ /* VID */
#define device_create_file_temp(client, num) do { \
device_create_file(&client->dev, &dev_attr_temp##num##_input); \
device_create_file(&client->dev, &dev_attr_temp##num##_max); \
device_create_file(&client->dev, &dev_attr_temp##num##_max_hyst); \
} while (0)
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 asb100_data *data = asb100_update_device(dev); struct asb100_data *data = asb100_update_device(dev);
...@@ -528,8 +510,6 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char ...@@ -528,8 +510,6 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char
} }
static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
#define device_create_file_vid(client) \
device_create_file(&client->dev, &dev_attr_cpu0_vid)
/* VRM */ /* VRM */
static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
...@@ -549,8 +529,6 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const ...@@ -549,8 +529,6 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const
/* Alarms */ /* Alarms */
static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
#define device_create_file_vrm(client) \
device_create_file(&client->dev, &dev_attr_vrm);
static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
{ {
...@@ -559,8 +537,6 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch ...@@ -559,8 +537,6 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch
} }
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
#define device_create_file_alarms(client) \
device_create_file(&client->dev, &dev_attr_alarms)
/* 1 PWM */ /* 1 PWM */
static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf)
...@@ -607,10 +583,65 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr ...@@ -607,10 +583,65 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr
static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1); static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1);
static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
show_pwm_enable1, set_pwm_enable1); show_pwm_enable1, set_pwm_enable1);
#define device_create_file_pwm1(client) do { \
device_create_file(&new_client->dev, &dev_attr_pwm1); \ static struct attribute *asb100_attributes[] = {
device_create_file(&new_client->dev, &dev_attr_pwm1_enable); \ &dev_attr_in0_input.attr,
} while (0) &dev_attr_in0_min.attr,
&dev_attr_in0_max.attr,
&dev_attr_in1_input.attr,
&dev_attr_in1_min.attr,
&dev_attr_in1_max.attr,
&dev_attr_in2_input.attr,
&dev_attr_in2_min.attr,
&dev_attr_in2_max.attr,
&dev_attr_in3_input.attr,
&dev_attr_in3_min.attr,
&dev_attr_in3_max.attr,
&dev_attr_in4_input.attr,
&dev_attr_in4_min.attr,
&dev_attr_in4_max.attr,
&dev_attr_in5_input.attr,
&dev_attr_in5_min.attr,
&dev_attr_in5_max.attr,
&dev_attr_in6_input.attr,
&dev_attr_in6_min.attr,
&dev_attr_in6_max.attr,
&dev_attr_fan1_input.attr,
&dev_attr_fan1_min.attr,
&dev_attr_fan1_div.attr,
&dev_attr_fan2_input.attr,
&dev_attr_fan2_min.attr,
&dev_attr_fan2_div.attr,
&dev_attr_fan3_input.attr,
&dev_attr_fan3_min.attr,
&dev_attr_fan3_div.attr,
&dev_attr_temp1_input.attr,
&dev_attr_temp1_max.attr,
&dev_attr_temp1_max_hyst.attr,
&dev_attr_temp2_input.attr,
&dev_attr_temp2_max.attr,
&dev_attr_temp2_max_hyst.attr,
&dev_attr_temp3_input.attr,
&dev_attr_temp3_max.attr,
&dev_attr_temp3_max_hyst.attr,
&dev_attr_temp4_input.attr,
&dev_attr_temp4_max.attr,
&dev_attr_temp4_max_hyst.attr,
&dev_attr_cpu0_vid.attr,
&dev_attr_vrm.attr,
&dev_attr_alarms.attr,
&dev_attr_pwm1.attr,
&dev_attr_pwm1_enable.attr,
NULL
};
static const struct attribute_group asb100_group = {
.attrs = asb100_attributes,
};
/* This function is called when: /* This function is called when:
asb100_driver is inserted (when this module is loaded), for each asb100_driver is inserted (when this module is loaded), for each
...@@ -810,38 +841,19 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -810,38 +841,19 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2)); data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2));
/* Register sysfs hooks */ /* Register sysfs hooks */
if ((err = sysfs_create_group(&new_client->dev.kobj, &asb100_group)))
goto ERROR3;
data->class_dev = hwmon_device_register(&new_client->dev); data->class_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->class_dev)) { if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev); err = PTR_ERR(data->class_dev);
goto ERROR3; goto ERROR4;
} }
device_create_file_in(new_client, 0);
device_create_file_in(new_client, 1);
device_create_file_in(new_client, 2);
device_create_file_in(new_client, 3);
device_create_file_in(new_client, 4);
device_create_file_in(new_client, 5);
device_create_file_in(new_client, 6);
device_create_file_fan(new_client, 1);
device_create_file_fan(new_client, 2);
device_create_file_fan(new_client, 3);
device_create_file_temp(new_client, 1);
device_create_file_temp(new_client, 2);
device_create_file_temp(new_client, 3);
device_create_file_temp(new_client, 4);
device_create_file_vid(new_client);
device_create_file_vrm(new_client);
device_create_file_alarms(new_client);
device_create_file_pwm1(new_client);
return 0; return 0;
ERROR4:
sysfs_remove_group(&new_client->dev.kobj, &asb100_group);
ERROR3: ERROR3:
i2c_detach_client(data->lm75[1]); i2c_detach_client(data->lm75[1]);
i2c_detach_client(data->lm75[0]); i2c_detach_client(data->lm75[0]);
...@@ -861,8 +873,10 @@ static int asb100_detach_client(struct i2c_client *client) ...@@ -861,8 +873,10 @@ static int asb100_detach_client(struct i2c_client *client)
int err; int err;
/* main client */ /* main client */
if (data) if (data) {
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &asb100_group);
}
if ((err = i2c_detach_client(client))) if ((err = i2c_detach_client(client)))
return err; return err;
......
...@@ -112,6 +112,18 @@ static int lm75_attach_adapter(struct i2c_adapter *adapter) ...@@ -112,6 +112,18 @@ static int lm75_attach_adapter(struct i2c_adapter *adapter)
return i2c_probe(adapter, &addr_data, lm75_detect); return i2c_probe(adapter, &addr_data, lm75_detect);
} }
static struct attribute *lm75_attributes[] = {
&dev_attr_temp1_input.attr,
&dev_attr_temp1_max.attr,
&dev_attr_temp1_max_hyst.attr,
NULL
};
static const struct attribute_group lm75_group = {
.attrs = lm75_attributes,
};
/* This function is called by i2c_probe */ /* This function is called by i2c_probe */
static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
...@@ -199,18 +211,19 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -199,18 +211,19 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
lm75_init_client(new_client); lm75_init_client(new_client);
/* Register sysfs hooks */ /* Register sysfs hooks */
if ((err = sysfs_create_group(&new_client->dev.kobj, &lm75_group)))
goto exit_detach;
data->class_dev = hwmon_device_register(&new_client->dev); data->class_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->class_dev)) { if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev); err = PTR_ERR(data->class_dev);
goto exit_detach; goto exit_remove;
} }
device_create_file(&new_client->dev, &dev_attr_temp1_max);
device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
device_create_file(&new_client->dev, &dev_attr_temp1_input);
return 0; return 0;
exit_remove:
sysfs_remove_group(&new_client->dev.kobj, &lm75_group);
exit_detach: exit_detach:
i2c_detach_client(new_client); i2c_detach_client(new_client);
exit_free: exit_free:
...@@ -223,6 +236,7 @@ static int lm75_detach_client(struct i2c_client *client) ...@@ -223,6 +236,7 @@ static int lm75_detach_client(struct i2c_client *client)
{ {
struct lm75_data *data = i2c_get_clientdata(client); struct lm75_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &lm75_group);
i2c_detach_client(client); i2c_detach_client(client);
kfree(data); kfree(data);
return 0; return 0;
......
...@@ -482,6 +482,50 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter) ...@@ -482,6 +482,50 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter)
return lm78_detect(adapter, isa_address, -1); return lm78_detect(adapter, isa_address, -1);
} }
static struct attribute *lm78_attributes[] = {
&dev_attr_in0_input.attr,
&dev_attr_in0_min.attr,
&dev_attr_in0_max.attr,
&dev_attr_in1_input.attr,
&dev_attr_in1_min.attr,
&dev_attr_in1_max.attr,
&dev_attr_in2_input.attr,
&dev_attr_in2_min.attr,
&dev_attr_in2_max.attr,
&dev_attr_in3_input.attr,
&dev_attr_in3_min.attr,
&dev_attr_in3_max.attr,
&dev_attr_in4_input.attr,
&dev_attr_in4_min.attr,
&dev_attr_in4_max.attr,
&dev_attr_in5_input.attr,
&dev_attr_in5_min.attr,
&dev_attr_in5_max.attr,
&dev_attr_in6_input.attr,
&dev_attr_in6_min.attr,
&dev_attr_in6_max.attr,
&dev_attr_temp1_input.attr,
&dev_attr_temp1_max.attr,
&dev_attr_temp1_max_hyst.attr,
&dev_attr_fan1_input.attr,
&dev_attr_fan1_min.attr,
&dev_attr_fan1_div.attr,
&dev_attr_fan2_input.attr,
&dev_attr_fan2_min.attr,
&dev_attr_fan2_div.attr,
&dev_attr_fan3_input.attr,
&dev_attr_fan3_min.attr,
&dev_attr_fan3_div.attr,
&dev_attr_alarms.attr,
&dev_attr_cpu0_vid.attr,
NULL
};
static const struct attribute_group lm78_group = {
.attrs = lm78_attributes,
};
/* This function is called by i2c_probe */ /* This function is called by i2c_probe */
static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
...@@ -616,50 +660,19 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -616,50 +660,19 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
} }
/* Register sysfs hooks */ /* Register sysfs hooks */
if ((err = sysfs_create_group(&new_client->dev.kobj, &lm78_group)))
goto ERROR3;
data->class_dev = hwmon_device_register(&new_client->dev); data->class_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->class_dev)) { if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev); err = PTR_ERR(data->class_dev);
goto ERROR3; goto ERROR4;
} }
device_create_file(&new_client->dev, &dev_attr_in0_input);
device_create_file(&new_client->dev, &dev_attr_in0_min);
device_create_file(&new_client->dev, &dev_attr_in0_max);
device_create_file(&new_client->dev, &dev_attr_in1_input);
device_create_file(&new_client->dev, &dev_attr_in1_min);
device_create_file(&new_client->dev, &dev_attr_in1_max);
device_create_file(&new_client->dev, &dev_attr_in2_input);
device_create_file(&new_client->dev, &dev_attr_in2_min);
device_create_file(&new_client->dev, &dev_attr_in2_max);
device_create_file(&new_client->dev, &dev_attr_in3_input);
device_create_file(&new_client->dev, &dev_attr_in3_min);
device_create_file(&new_client->dev, &dev_attr_in3_max);
device_create_file(&new_client->dev, &dev_attr_in4_input);
device_create_file(&new_client->dev, &dev_attr_in4_min);
device_create_file(&new_client->dev, &dev_attr_in4_max);
device_create_file(&new_client->dev, &dev_attr_in5_input);
device_create_file(&new_client->dev, &dev_attr_in5_min);
device_create_file(&new_client->dev, &dev_attr_in5_max);
device_create_file(&new_client->dev, &dev_attr_in6_input);
device_create_file(&new_client->dev, &dev_attr_in6_min);
device_create_file(&new_client->dev, &dev_attr_in6_max);
device_create_file(&new_client->dev, &dev_attr_temp1_input);
device_create_file(&new_client->dev, &dev_attr_temp1_max);
device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
device_create_file(&new_client->dev, &dev_attr_fan1_input);
device_create_file(&new_client->dev, &dev_attr_fan1_min);
device_create_file(&new_client->dev, &dev_attr_fan1_div);
device_create_file(&new_client->dev, &dev_attr_fan2_input);
device_create_file(&new_client->dev, &dev_attr_fan2_min);
device_create_file(&new_client->dev, &dev_attr_fan2_div);
device_create_file(&new_client->dev, &dev_attr_fan3_input);
device_create_file(&new_client->dev, &dev_attr_fan3_min);
device_create_file(&new_client->dev, &dev_attr_fan3_div);
device_create_file(&new_client->dev, &dev_attr_alarms);
device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
return 0; return 0;
ERROR4:
sysfs_remove_group(&new_client->dev.kobj, &lm78_group);
ERROR3: ERROR3:
i2c_detach_client(new_client); i2c_detach_client(new_client);
ERROR2: ERROR2:
...@@ -677,6 +690,7 @@ static int lm78_detach_client(struct i2c_client *client) ...@@ -677,6 +690,7 @@ static int lm78_detach_client(struct i2c_client *client)
int err; int err;
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &lm78_group);
if ((err = i2c_detach_client(client))) if ((err = i2c_detach_client(client)))
return err; return err;
......
...@@ -176,9 +176,6 @@ sysfs_temp(2); ...@@ -176,9 +176,6 @@ sysfs_temp(2);
sysfs_temp(3); sysfs_temp(3);
sysfs_temp(4); sysfs_temp(4);
#define device_create_file_temp(client, num) \
device_create_file(&client->dev, &dev_attr_temp##num##_input)
/* FAN: 1 RPM/bit /* FAN: 1 RPM/bit
REG: count of 90kHz pulses / revolution */ REG: count of 90kHz pulses / revolution */
static int fan_from_reg(u16 reg) static int fan_from_reg(u16 reg)
...@@ -205,8 +202,22 @@ sysfs_fan(2); ...@@ -205,8 +202,22 @@ sysfs_fan(2);
sysfs_fan(3); sysfs_fan(3);
sysfs_fan(4); sysfs_fan(4);
#define device_create_file_fan(client, num) \ static struct attribute *smsc47b397_attributes[] = {
device_create_file(&client->dev, &dev_attr_fan##num##_input) &dev_attr_temp1_input.attr,
&dev_attr_temp2_input.attr,
&dev_attr_temp3_input.attr,
&dev_attr_temp4_input.attr,
&dev_attr_fan1_input.attr,
&dev_attr_fan2_input.attr,
&dev_attr_fan3_input.attr,
&dev_attr_fan4_input.attr,
NULL
};
static const struct attribute_group smsc47b397_group = {
.attrs = smsc47b397_attributes,
};
static int smsc47b397_detach_client(struct i2c_client *client) static int smsc47b397_detach_client(struct i2c_client *client)
{ {
...@@ -214,6 +225,7 @@ static int smsc47b397_detach_client(struct i2c_client *client) ...@@ -214,6 +225,7 @@ static int smsc47b397_detach_client(struct i2c_client *client)
int err; int err;
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &smsc47b397_group);
if ((err = i2c_detach_client(client))) if ((err = i2c_detach_client(client)))
return err; return err;
...@@ -268,24 +280,19 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) ...@@ -268,24 +280,19 @@ static int smsc47b397_detect(struct i2c_adapter *adapter)
if ((err = i2c_attach_client(new_client))) if ((err = i2c_attach_client(new_client)))
goto error_free; goto error_free;
if ((err = sysfs_create_group(&new_client->dev.kobj, &smsc47b397_group)))
goto error_detach;
data->class_dev = hwmon_device_register(&new_client->dev); data->class_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->class_dev)) { if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev); err = PTR_ERR(data->class_dev);
goto error_detach; goto error_remove;
} }
device_create_file_temp(new_client, 1);
device_create_file_temp(new_client, 2);
device_create_file_temp(new_client, 3);
device_create_file_temp(new_client, 4);
device_create_file_fan(new_client, 1);
device_create_file_fan(new_client, 2);
device_create_file_fan(new_client, 3);
device_create_file_fan(new_client, 4);
return 0; return 0;
error_remove:
sysfs_remove_group(&new_client->dev.kobj, &smsc47b397_group);
error_detach: error_detach:
i2c_detach_client(new_client); i2c_detach_client(new_client);
error_free: error_free:
......
...@@ -512,13 +512,6 @@ static DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR, ...@@ -512,13 +512,6 @@ static DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR,
static DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR, static DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR,
show_regs_in_max0, store_regs_in_max0); show_regs_in_max0, store_regs_in_max0);
#define device_create_file_in(client, offset) \
do { \
device_create_file(&client->dev, &dev_attr_in##offset##_input); \
device_create_file(&client->dev, &dev_attr_in##offset##_min); \
device_create_file(&client->dev, &dev_attr_in##offset##_max); \
} while (0)
#define show_fan_reg(reg) \ #define show_fan_reg(reg) \
static ssize_t show_##reg (struct device *dev, char *buf, int nr) \ static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
{ \ { \
...@@ -576,12 +569,6 @@ sysfs_fan_min_offset(2); ...@@ -576,12 +569,6 @@ sysfs_fan_min_offset(2);
sysfs_fan_offset(3); sysfs_fan_offset(3);
sysfs_fan_min_offset(3); sysfs_fan_min_offset(3);
#define device_create_file_fan(client, offset) \
do { \
device_create_file(&client->dev, &dev_attr_fan##offset##_input); \
device_create_file(&client->dev, &dev_attr_fan##offset##_min); \
} while (0)
#define show_temp_reg(reg) \ #define show_temp_reg(reg) \
static ssize_t show_##reg (struct device *dev, char *buf, int nr) \ static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
{ \ { \
...@@ -656,13 +643,6 @@ sysfs_temp_offsets(1); ...@@ -656,13 +643,6 @@ sysfs_temp_offsets(1);
sysfs_temp_offsets(2); sysfs_temp_offsets(2);
sysfs_temp_offsets(3); sysfs_temp_offsets(3);
#define device_create_file_temp(client, offset) \
do { \
device_create_file(&client->dev, &dev_attr_temp##offset##_input); \
device_create_file(&client->dev, &dev_attr_temp##offset##_max); \
device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \
} while (0)
static ssize_t static ssize_t
show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
{ {
...@@ -670,8 +650,6 @@ show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -670,8 +650,6 @@ show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
} }
static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
#define device_create_file_vid(client) \
device_create_file(&client->dev, &dev_attr_cpu0_vid)
static ssize_t static ssize_t
show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
...@@ -692,8 +670,6 @@ store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf ...@@ -692,8 +670,6 @@ store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf
return count; return count;
} }
static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
#define device_create_file_vrm(client) \
device_create_file(&client->dev, &dev_attr_vrm)
static ssize_t static ssize_t
show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
...@@ -702,8 +678,6 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -702,8 +678,6 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", (long) data->alarms); return sprintf(buf, "%ld\n", (long) data->alarms);
} }
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
#define device_create_file_alarms(client) \
device_create_file(&client->dev, &dev_attr_alarms)
#define show_beep_reg(REG, reg) \ #define show_beep_reg(REG, reg) \
static ssize_t show_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \ static ssize_t show_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \
...@@ -766,12 +740,6 @@ static DEVICE_ATTR(beep_##reg, S_IRUGO | S_IWUSR, \ ...@@ -766,12 +740,6 @@ static DEVICE_ATTR(beep_##reg, S_IRUGO | S_IWUSR, \
sysfs_beep(ENABLE, enable); sysfs_beep(ENABLE, enable);
sysfs_beep(MASK, mask); sysfs_beep(MASK, mask);
#define device_create_file_beep(client) \
do { \
device_create_file(&client->dev, &dev_attr_beep_enable); \
device_create_file(&client->dev, &dev_attr_beep_mask); \
} while (0)
static ssize_t static ssize_t
show_fan_div_reg(struct device *dev, char *buf, int nr) show_fan_div_reg(struct device *dev, char *buf, int nr)
{ {
...@@ -837,11 +805,6 @@ sysfs_fan_div(1); ...@@ -837,11 +805,6 @@ sysfs_fan_div(1);
sysfs_fan_div(2); sysfs_fan_div(2);
sysfs_fan_div(3); sysfs_fan_div(3);
#define device_create_file_fan_div(client, offset) \
do { \
device_create_file(&client->dev, &dev_attr_fan##offset##_div); \
} while (0)
static ssize_t static ssize_t
show_pwm_reg(struct device *dev, char *buf, int nr) show_pwm_reg(struct device *dev, char *buf, int nr)
{ {
...@@ -896,11 +859,6 @@ sysfs_pwm(1); ...@@ -896,11 +859,6 @@ sysfs_pwm(1);
sysfs_pwm(2); sysfs_pwm(2);
sysfs_pwm(3); sysfs_pwm(3);
#define device_create_file_pwm(client, offset) \
do { \
device_create_file(&client->dev, &dev_attr_pwm##offset); \
} while (0)
static ssize_t static ssize_t
show_sensor_reg(struct device *dev, char *buf, int nr) show_sensor_reg(struct device *dev, char *buf, int nr)
{ {
...@@ -972,12 +930,6 @@ sysfs_sensor(1); ...@@ -972,12 +930,6 @@ sysfs_sensor(1);
sysfs_sensor(2); sysfs_sensor(2);
sysfs_sensor(3); sysfs_sensor(3);
#define device_create_file_sensor(client, offset) \
do { \
device_create_file(&client->dev, &dev_attr_temp##offset##_type); \
} while (0)
static int __init w83627hf_find(int sioaddr, unsigned short *addr) static int __init w83627hf_find(int sioaddr, unsigned short *addr)
{ {
u16 val; u16 val;
...@@ -1009,6 +961,85 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) ...@@ -1009,6 +961,85 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr)
return 0; return 0;
} }
static struct attribute *w83627hf_attributes[] = {
&dev_attr_in0_input.attr,
&dev_attr_in0_min.attr,
&dev_attr_in0_max.attr,
&dev_attr_in2_input.attr,
&dev_attr_in2_min.attr,
&dev_attr_in2_max.attr,
&dev_attr_in3_input.attr,
&dev_attr_in3_min.attr,
&dev_attr_in3_max.attr,
&dev_attr_in4_input.attr,
&dev_attr_in4_min.attr,
&dev_attr_in4_max.attr,
&dev_attr_in7_input.attr,
&dev_attr_in7_min.attr,
&dev_attr_in7_max.attr,
&dev_attr_in8_input.attr,
&dev_attr_in8_min.attr,
&dev_attr_in8_max.attr,
&dev_attr_fan1_input.attr,
&dev_attr_fan1_min.attr,
&dev_attr_fan1_div.attr,
&dev_attr_fan2_input.attr,
&dev_attr_fan2_min.attr,
&dev_attr_fan2_div.attr,
&dev_attr_temp1_input.attr,
&dev_attr_temp1_max.attr,
&dev_attr_temp1_max_hyst.attr,
&dev_attr_temp1_type.attr,
&dev_attr_temp2_input.attr,
&dev_attr_temp2_max.attr,
&dev_attr_temp2_max_hyst.attr,
&dev_attr_temp2_type.attr,
&dev_attr_alarms.attr,
&dev_attr_beep_enable.attr,
&dev_attr_beep_mask.attr,
&dev_attr_pwm1.attr,
&dev_attr_pwm2.attr,
NULL
};
static const struct attribute_group w83627hf_group = {
.attrs = w83627hf_attributes,
};
static struct attribute *w83627hf_attributes_opt[] = {
&dev_attr_in1_input.attr,
&dev_attr_in1_min.attr,
&dev_attr_in1_max.attr,
&dev_attr_in5_input.attr,
&dev_attr_in5_min.attr,
&dev_attr_in5_max.attr,
&dev_attr_in6_input.attr,
&dev_attr_in6_min.attr,
&dev_attr_in6_max.attr,
&dev_attr_fan3_input.attr,
&dev_attr_fan3_min.attr,
&dev_attr_fan3_div.attr,
&dev_attr_temp3_input.attr,
&dev_attr_temp3_max.attr,
&dev_attr_temp3_max_hyst.attr,
&dev_attr_temp3_type.attr,
&dev_attr_pwm3.attr,
NULL
};
static const struct attribute_group w83627hf_group_opt = {
.attrs = w83627hf_attributes_opt,
};
static int w83627hf_detect(struct i2c_adapter *adapter) static int w83627hf_detect(struct i2c_adapter *adapter)
{ {
int val, kind; int val, kind;
...@@ -1108,62 +1139,72 @@ static int w83627hf_detect(struct i2c_adapter *adapter) ...@@ -1108,62 +1139,72 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
data->fan_min[1] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(2)); data->fan_min[1] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(2));
data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3)); data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3));
/* Register sysfs hooks */ /* Register common device attributes */
data->class_dev = hwmon_device_register(&new_client->dev); if ((err = sysfs_create_group(&new_client->dev.kobj, &w83627hf_group)))
if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev);
goto ERROR3; goto ERROR3;
}
device_create_file_in(new_client, 0);
if (kind != w83697hf)
device_create_file_in(new_client, 1);
device_create_file_in(new_client, 2);
device_create_file_in(new_client, 3);
device_create_file_in(new_client, 4);
if (kind == w83627hf || kind == w83697hf) {
device_create_file_in(new_client, 5);
device_create_file_in(new_client, 6);
}
device_create_file_in(new_client, 7);
device_create_file_in(new_client, 8);
device_create_file_fan(new_client, 1);
device_create_file_fan(new_client, 2);
if (kind != w83697hf)
device_create_file_fan(new_client, 3);
device_create_file_temp(new_client, 1);
device_create_file_temp(new_client, 2);
if (kind != w83697hf)
device_create_file_temp(new_client, 3);
if (kind != w83697hf && data->vid != 0xff) { /* Register chip-specific device attributes */
device_create_file_vid(new_client); if (kind == w83627hf || kind == w83697hf)
device_create_file_vrm(new_client); if ((err = device_create_file(&new_client->dev,
} &dev_attr_in5_input))
|| (err = device_create_file(&new_client->dev,
&dev_attr_in5_min))
|| (err = device_create_file(&new_client->dev,
&dev_attr_in5_max))
|| (err = device_create_file(&new_client->dev,
&dev_attr_in6_input))
|| (err = device_create_file(&new_client->dev,
&dev_attr_in6_min))
|| (err = device_create_file(&new_client->dev,
&dev_attr_in6_max)))
goto ERROR4;
device_create_file_fan_div(new_client, 1);
device_create_file_fan_div(new_client, 2);
if (kind != w83697hf) if (kind != w83697hf)
device_create_file_fan_div(new_client, 3); if ((err = device_create_file(&new_client->dev,
&dev_attr_in1_input))
device_create_file_alarms(new_client); || (err = device_create_file(&new_client->dev,
&dev_attr_in1_min))
device_create_file_beep(new_client); || (err = device_create_file(&new_client->dev,
&dev_attr_in1_max))
|| (err = device_create_file(&new_client->dev,
&dev_attr_fan3_input))
|| (err = device_create_file(&new_client->dev,
&dev_attr_fan3_min))
|| (err = device_create_file(&new_client->dev,
&dev_attr_fan3_div))
|| (err = device_create_file(&new_client->dev,
&dev_attr_temp3_input))
|| (err = device_create_file(&new_client->dev,
&dev_attr_temp3_max))
|| (err = device_create_file(&new_client->dev,
&dev_attr_temp3_max_hyst))
|| (err = device_create_file(&new_client->dev,
&dev_attr_temp3_type)))
goto ERROR4;
if (kind != w83697hf && data->vid != 0xff)
if ((err = device_create_file(&new_client->dev,
&dev_attr_cpu0_vid))
|| (err = device_create_file(&new_client->dev,
&dev_attr_vrm)))
goto ERROR4;
device_create_file_pwm(new_client, 1);
device_create_file_pwm(new_client, 2);
if (kind == w83627thf || kind == w83637hf || kind == w83687thf) if (kind == w83627thf || kind == w83637hf || kind == w83687thf)
device_create_file_pwm(new_client, 3); if ((err = device_create_file(&new_client->dev,
&dev_attr_pwm3)))
goto ERROR4;
device_create_file_sensor(new_client, 1); data->class_dev = hwmon_device_register(&new_client->dev);
device_create_file_sensor(new_client, 2); if (IS_ERR(data->class_dev)) {
if (kind != w83697hf) err = PTR_ERR(data->class_dev);
device_create_file_sensor(new_client, 3); goto ERROR4;
}
return 0; return 0;
ERROR4:
sysfs_remove_group(&new_client->dev.kobj, &w83627hf_group);
sysfs_remove_group(&new_client->dev.kobj, &w83627hf_group_opt);
ERROR3: ERROR3:
i2c_detach_client(new_client); i2c_detach_client(new_client);
ERROR2: ERROR2:
...@@ -1181,6 +1222,9 @@ static int w83627hf_detach_client(struct i2c_client *client) ...@@ -1181,6 +1222,9 @@ static int w83627hf_detach_client(struct i2c_client *client)
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &w83627hf_group);
sysfs_remove_group(&client->dev.kobj, &w83627hf_group_opt);
if ((err = i2c_detach_client(client))) if ((err = i2c_detach_client(client)))
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment