Fix unchecked return status, batch 5
hwmon: Fix unchecked return status, batch 5 Fix up some hwmon drivers so that they no longer ignore return status from device_create_file(). Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Родитель
0e39e01c90
Коммит
87808be4f9
|
@ -34,6 +34,7 @@
|
||||||
#include <linux/hwmon.h>
|
#include <linux/hwmon.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/sysfs.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Addresses to scan
|
* Addresses to scan
|
||||||
|
@ -240,46 +241,44 @@ sysfs_alarms(FSCHER_REG_EVENTS)
|
||||||
sysfs_control(FSCHER_REG_CONTROL)
|
sysfs_control(FSCHER_REG_CONTROL)
|
||||||
sysfs_watchdog(FSCHER_REG_WDOG_CONTROL, FSCHER_REG_WDOG_STATE, FSCHER_REG_WDOG_PRESET)
|
sysfs_watchdog(FSCHER_REG_WDOG_CONTROL, FSCHER_REG_WDOG_STATE, FSCHER_REG_WDOG_PRESET)
|
||||||
|
|
||||||
#define device_create_file_fan(client, offset) \
|
static struct attribute *fscher_attributes[] = {
|
||||||
do { \
|
&dev_attr_revision.attr,
|
||||||
device_create_file(&client->dev, &dev_attr_fan##offset##_status); \
|
&dev_attr_alarms.attr,
|
||||||
device_create_file(&client->dev, &dev_attr_pwm##offset); \
|
&dev_attr_control.attr,
|
||||||
device_create_file(&client->dev, &dev_attr_fan##offset##_div); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_fan##offset##_input); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define device_create_file_temp(client, offset) \
|
&dev_attr_watchdog_status.attr,
|
||||||
do { \
|
&dev_attr_watchdog_control.attr,
|
||||||
device_create_file(&client->dev, &dev_attr_temp##offset##_status); \
|
&dev_attr_watchdog_preset.attr,
|
||||||
device_create_file(&client->dev, &dev_attr_temp##offset##_input); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define device_create_file_in(client, offset) \
|
&dev_attr_in0_input.attr,
|
||||||
do { \
|
&dev_attr_in1_input.attr,
|
||||||
device_create_file(&client->dev, &dev_attr_in##offset##_input); \
|
&dev_attr_in2_input.attr,
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define device_create_file_revision(client) \
|
&dev_attr_fan1_status.attr,
|
||||||
do { \
|
&dev_attr_fan1_div.attr,
|
||||||
device_create_file(&client->dev, &dev_attr_revision); \
|
&dev_attr_fan1_input.attr,
|
||||||
} while (0)
|
&dev_attr_pwm1.attr,
|
||||||
|
&dev_attr_fan2_status.attr,
|
||||||
|
&dev_attr_fan2_div.attr,
|
||||||
|
&dev_attr_fan2_input.attr,
|
||||||
|
&dev_attr_pwm2.attr,
|
||||||
|
&dev_attr_fan3_status.attr,
|
||||||
|
&dev_attr_fan3_div.attr,
|
||||||
|
&dev_attr_fan3_input.attr,
|
||||||
|
&dev_attr_pwm3.attr,
|
||||||
|
|
||||||
#define device_create_file_alarms(client) \
|
&dev_attr_temp1_status.attr,
|
||||||
do { \
|
&dev_attr_temp1_input.attr,
|
||||||
device_create_file(&client->dev, &dev_attr_alarms); \
|
&dev_attr_temp2_status.attr,
|
||||||
} while (0)
|
&dev_attr_temp2_input.attr,
|
||||||
|
&dev_attr_temp3_status.attr,
|
||||||
|
&dev_attr_temp3_input.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
#define device_create_file_control(client) \
|
static const struct attribute_group fscher_group = {
|
||||||
do { \
|
.attrs = fscher_attributes,
|
||||||
device_create_file(&client->dev, &dev_attr_control); \
|
};
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define device_create_file_watchdog(client) \
|
|
||||||
do { \
|
|
||||||
device_create_file(&client->dev, &dev_attr_watchdog_status); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_watchdog_control); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_watchdog_preset); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Real code
|
* Real code
|
||||||
|
@ -342,31 +341,19 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||||
fscher_init_client(new_client);
|
fscher_init_client(new_client);
|
||||||
|
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
|
if ((err = sysfs_create_group(&new_client->dev.kobj, &fscher_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_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_create_file_revision(new_client);
|
|
||||||
device_create_file_alarms(new_client);
|
|
||||||
device_create_file_control(new_client);
|
|
||||||
device_create_file_watchdog(new_client);
|
|
||||||
|
|
||||||
device_create_file_in(new_client, 0);
|
|
||||||
device_create_file_in(new_client, 1);
|
|
||||||
device_create_file_in(new_client, 2);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
exit_remove_files:
|
||||||
|
sysfs_remove_group(&new_client->dev.kobj, &fscher_group);
|
||||||
exit_detach:
|
exit_detach:
|
||||||
i2c_detach_client(new_client);
|
i2c_detach_client(new_client);
|
||||||
exit_free:
|
exit_free:
|
||||||
|
@ -381,6 +368,7 @@ static int fscher_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, &fscher_group);
|
||||||
|
|
||||||
if ((err = i2c_detach_client(client)))
|
if ((err = i2c_detach_client(client)))
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <linux/hwmon.h>
|
#include <linux/hwmon.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/sysfs.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Addresses to scan
|
* Addresses to scan
|
||||||
|
@ -432,6 +433,44 @@ static DEVICE_ATTR(in0_input, S_IRUGO, show_volt_12, NULL);
|
||||||
static DEVICE_ATTR(in1_input, S_IRUGO, show_volt_5, NULL);
|
static DEVICE_ATTR(in1_input, S_IRUGO, show_volt_5, NULL);
|
||||||
static DEVICE_ATTR(in2_input, S_IRUGO, show_volt_batt, NULL);
|
static DEVICE_ATTR(in2_input, S_IRUGO, show_volt_batt, NULL);
|
||||||
|
|
||||||
|
static struct attribute *fscpos_attributes[] = {
|
||||||
|
&dev_attr_event.attr,
|
||||||
|
&dev_attr_in0_input.attr,
|
||||||
|
&dev_attr_in1_input.attr,
|
||||||
|
&dev_attr_in2_input.attr,
|
||||||
|
|
||||||
|
&dev_attr_wdog_control.attr,
|
||||||
|
&dev_attr_wdog_preset.attr,
|
||||||
|
&dev_attr_wdog_state.attr,
|
||||||
|
|
||||||
|
&dev_attr_temp1_input.attr,
|
||||||
|
&dev_attr_temp1_status.attr,
|
||||||
|
&dev_attr_temp1_reset.attr,
|
||||||
|
&dev_attr_temp2_input.attr,
|
||||||
|
&dev_attr_temp2_status.attr,
|
||||||
|
&dev_attr_temp2_reset.attr,
|
||||||
|
&dev_attr_temp3_input.attr,
|
||||||
|
&dev_attr_temp3_status.attr,
|
||||||
|
&dev_attr_temp3_reset.attr,
|
||||||
|
|
||||||
|
&dev_attr_fan1_input.attr,
|
||||||
|
&dev_attr_fan1_status.attr,
|
||||||
|
&dev_attr_fan1_ripple.attr,
|
||||||
|
&dev_attr_pwm1.attr,
|
||||||
|
&dev_attr_fan2_input.attr,
|
||||||
|
&dev_attr_fan2_status.attr,
|
||||||
|
&dev_attr_fan2_ripple.attr,
|
||||||
|
&dev_attr_pwm2.attr,
|
||||||
|
&dev_attr_fan3_input.attr,
|
||||||
|
&dev_attr_fan3_status.attr,
|
||||||
|
&dev_attr_fan3_ripple.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group fscpos_group = {
|
||||||
|
.attrs = fscpos_attributes,
|
||||||
|
};
|
||||||
|
|
||||||
static int fscpos_attach_adapter(struct i2c_adapter *adapter)
|
static int fscpos_attach_adapter(struct i2c_adapter *adapter)
|
||||||
{
|
{
|
||||||
if (!(adapter->class & I2C_CLASS_HWMON))
|
if (!(adapter->class & I2C_CLASS_HWMON))
|
||||||
|
@ -497,42 +536,19 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||||
dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision);
|
dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision);
|
||||||
|
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
|
if ((err = sysfs_create_group(&new_client->dev.kobj, &fscpos_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_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_event);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in0_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in1_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in2_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_wdog_control);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_wdog_preset);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_wdog_state);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp1_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp1_status);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp1_reset);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp2_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp2_status);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp2_reset);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp3_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp3_status);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_temp3_reset);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan1_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan1_status);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan1_ripple);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_pwm1);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan2_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan2_status);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan2_ripple);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_pwm2);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan3_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan3_status);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan3_ripple);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
exit_remove_files:
|
||||||
|
sysfs_remove_group(&new_client->dev.kobj, &fscpos_group);
|
||||||
exit_detach:
|
exit_detach:
|
||||||
i2c_detach_client(new_client);
|
i2c_detach_client(new_client);
|
||||||
exit_free:
|
exit_free:
|
||||||
|
@ -547,6 +563,7 @@ static int fscpos_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, &fscpos_group);
|
||||||
|
|
||||||
if ((err = i2c_detach_client(client)))
|
if ((err = i2c_detach_client(client)))
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include <linux/hwmon.h>
|
#include <linux/hwmon.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/sysfs.h>
|
||||||
|
|
||||||
/* Addresses to scan */
|
/* Addresses to scan */
|
||||||
static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
|
static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
|
||||||
|
@ -340,6 +341,42 @@ static DEVICE_ATTR(beep_enable, S_IWUSR|S_IRUGO,
|
||||||
static DEVICE_ATTR(beep_mask, S_IWUSR|S_IRUGO,
|
static DEVICE_ATTR(beep_mask, S_IWUSR|S_IRUGO,
|
||||||
show_beep_mask, set_beep_mask);
|
show_beep_mask, set_beep_mask);
|
||||||
|
|
||||||
|
static struct attribute *gl518_attributes[] = {
|
||||||
|
&dev_attr_in0_input.attr,
|
||||||
|
&dev_attr_in1_input.attr,
|
||||||
|
&dev_attr_in2_input.attr,
|
||||||
|
&dev_attr_in3_input.attr,
|
||||||
|
&dev_attr_in0_min.attr,
|
||||||
|
&dev_attr_in1_min.attr,
|
||||||
|
&dev_attr_in2_min.attr,
|
||||||
|
&dev_attr_in3_min.attr,
|
||||||
|
&dev_attr_in0_max.attr,
|
||||||
|
&dev_attr_in1_max.attr,
|
||||||
|
&dev_attr_in2_max.attr,
|
||||||
|
&dev_attr_in3_max.attr,
|
||||||
|
|
||||||
|
&dev_attr_fan1_auto.attr,
|
||||||
|
&dev_attr_fan1_input.attr,
|
||||||
|
&dev_attr_fan2_input.attr,
|
||||||
|
&dev_attr_fan1_min.attr,
|
||||||
|
&dev_attr_fan2_min.attr,
|
||||||
|
&dev_attr_fan1_div.attr,
|
||||||
|
&dev_attr_fan2_div.attr,
|
||||||
|
|
||||||
|
&dev_attr_temp1_input.attr,
|
||||||
|
&dev_attr_temp1_max.attr,
|
||||||
|
&dev_attr_temp1_max_hyst.attr,
|
||||||
|
|
||||||
|
&dev_attr_alarms.attr,
|
||||||
|
&dev_attr_beep_enable.attr,
|
||||||
|
&dev_attr_beep_mask.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group gl518_group = {
|
||||||
|
.attrs = gl518_attributes,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Real code
|
* Real code
|
||||||
*/
|
*/
|
||||||
|
@ -420,43 +457,19 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||||
gl518_init_client((struct i2c_client *) new_client);
|
gl518_init_client((struct i2c_client *) new_client);
|
||||||
|
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
|
if ((err = sysfs_create_group(&new_client->dev.kobj, &gl518_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_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in0_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in1_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in2_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in3_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in0_min);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in1_min);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in2_min);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in3_min);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in0_max);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in1_max);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in2_max);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_in3_max);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan1_auto);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan1_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan2_input);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan1_min);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan2_min);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan1_div);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_fan2_div);
|
|
||||||
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_alarms);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_beep_enable);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_beep_mask);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* OK, this is not exactly good programming practice, usually. But it is
|
exit_remove_files:
|
||||||
very code-efficient in this case. */
|
sysfs_remove_group(&new_client->dev.kobj, &gl518_group);
|
||||||
|
|
||||||
exit_detach:
|
exit_detach:
|
||||||
i2c_detach_client(new_client);
|
i2c_detach_client(new_client);
|
||||||
exit_free:
|
exit_free:
|
||||||
|
@ -490,6 +503,7 @@ static int gl518_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, &gl518_group);
|
||||||
|
|
||||||
if ((err = i2c_detach_client(client)))
|
if ((err = i2c_detach_client(client)))
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <linux/hwmon-vid.h>
|
#include <linux/hwmon-vid.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/sysfs.h>
|
||||||
|
|
||||||
/* Type of the extra sensor */
|
/* Type of the extra sensor */
|
||||||
static unsigned short extra_sensor_type;
|
static unsigned short extra_sensor_type;
|
||||||
|
@ -190,55 +191,29 @@ static DEVICE_ATTR(type##item, S_IRUGO, get_##type##0##item, NULL);
|
||||||
#define sysfs_vid(n) \
|
#define sysfs_vid(n) \
|
||||||
sysfs_ro_n(cpu, n, _vid, GL520_REG_VID_INPUT)
|
sysfs_ro_n(cpu, n, _vid, GL520_REG_VID_INPUT)
|
||||||
|
|
||||||
#define device_create_file_vid(client, n) \
|
|
||||||
device_create_file(&client->dev, &dev_attr_cpu##n##_vid)
|
|
||||||
|
|
||||||
#define sysfs_in(n) \
|
#define sysfs_in(n) \
|
||||||
sysfs_ro_n(in, n, _input, GL520_REG_IN##n##INPUT) \
|
sysfs_ro_n(in, n, _input, GL520_REG_IN##n##INPUT) \
|
||||||
sysfs_rw_n(in, n, _min, GL520_REG_IN##n##_MIN) \
|
sysfs_rw_n(in, n, _min, GL520_REG_IN##n##_MIN) \
|
||||||
sysfs_rw_n(in, n, _max, GL520_REG_IN##n##_MAX) \
|
sysfs_rw_n(in, n, _max, GL520_REG_IN##n##_MAX) \
|
||||||
|
|
||||||
#define device_create_file_in(client, n) \
|
|
||||||
({device_create_file(&client->dev, &dev_attr_in##n##_input); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_in##n##_min); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_in##n##_max);})
|
|
||||||
|
|
||||||
#define sysfs_fan(n) \
|
#define sysfs_fan(n) \
|
||||||
sysfs_ro_n(fan, n, _input, GL520_REG_FAN_INPUT) \
|
sysfs_ro_n(fan, n, _input, GL520_REG_FAN_INPUT) \
|
||||||
sysfs_rw_n(fan, n, _min, GL520_REG_FAN_MIN) \
|
sysfs_rw_n(fan, n, _min, GL520_REG_FAN_MIN) \
|
||||||
sysfs_rw_n(fan, n, _div, GL520_REG_FAN_DIV)
|
sysfs_rw_n(fan, n, _div, GL520_REG_FAN_DIV)
|
||||||
|
|
||||||
#define device_create_file_fan(client, n) \
|
|
||||||
({device_create_file(&client->dev, &dev_attr_fan##n##_input); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_fan##n##_min); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_fan##n##_div);})
|
|
||||||
|
|
||||||
#define sysfs_fan_off(n) \
|
#define sysfs_fan_off(n) \
|
||||||
sysfs_rw_n(fan, n, _off, GL520_REG_FAN_OFF) \
|
sysfs_rw_n(fan, n, _off, GL520_REG_FAN_OFF) \
|
||||||
|
|
||||||
#define device_create_file_fan_off(client, n) \
|
|
||||||
device_create_file(&client->dev, &dev_attr_fan##n##_off)
|
|
||||||
|
|
||||||
#define sysfs_temp(n) \
|
#define sysfs_temp(n) \
|
||||||
sysfs_ro_n(temp, n, _input, GL520_REG_TEMP##n##_INPUT) \
|
sysfs_ro_n(temp, n, _input, GL520_REG_TEMP##n##_INPUT) \
|
||||||
sysfs_rw_n(temp, n, _max, GL520_REG_TEMP##n##_MAX) \
|
sysfs_rw_n(temp, n, _max, GL520_REG_TEMP##n##_MAX) \
|
||||||
sysfs_rw_n(temp, n, _max_hyst, GL520_REG_TEMP##n##_MAX_HYST)
|
sysfs_rw_n(temp, n, _max_hyst, GL520_REG_TEMP##n##_MAX_HYST)
|
||||||
|
|
||||||
#define device_create_file_temp(client, n) \
|
|
||||||
({device_create_file(&client->dev, &dev_attr_temp##n##_input); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_temp##n##_max); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_temp##n##_max_hyst);})
|
|
||||||
|
|
||||||
#define sysfs_alarms() \
|
#define sysfs_alarms() \
|
||||||
sysfs_ro(alarms, , GL520_REG_ALARMS) \
|
sysfs_ro(alarms, , GL520_REG_ALARMS) \
|
||||||
sysfs_rw(beep_enable, , GL520_REG_BEEP_ENABLE) \
|
sysfs_rw(beep_enable, , GL520_REG_BEEP_ENABLE) \
|
||||||
sysfs_rw(beep_mask, , GL520_REG_BEEP_MASK)
|
sysfs_rw(beep_mask, , GL520_REG_BEEP_MASK)
|
||||||
|
|
||||||
#define device_create_file_alarms(client) \
|
|
||||||
({device_create_file(&client->dev, &dev_attr_alarms); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_beep_enable); \
|
|
||||||
device_create_file(&client->dev, &dev_attr_beep_mask);})
|
|
||||||
|
|
||||||
|
|
||||||
sysfs_vid(0)
|
sysfs_vid(0)
|
||||||
|
|
||||||
|
@ -511,6 +486,59 @@ static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct attribute *gl520_attributes[] = {
|
||||||
|
&dev_attr_cpu0_vid.attr,
|
||||||
|
|
||||||
|
&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_fan1_input.attr,
|
||||||
|
&dev_attr_fan1_min.attr,
|
||||||
|
&dev_attr_fan1_div.attr,
|
||||||
|
&dev_attr_fan1_off.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_alarms.attr,
|
||||||
|
&dev_attr_beep_enable.attr,
|
||||||
|
&dev_attr_beep_mask.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group gl520_group = {
|
||||||
|
.attrs = gl520_attributes,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *gl520_attributes_opt[] = {
|
||||||
|
&dev_attr_in4_input.attr,
|
||||||
|
&dev_attr_in4_min.attr,
|
||||||
|
&dev_attr_in4_max.attr,
|
||||||
|
|
||||||
|
&dev_attr_temp2_input.attr,
|
||||||
|
&dev_attr_temp2_max.attr,
|
||||||
|
&dev_attr_temp2_max_hyst.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group gl520_group_opt = {
|
||||||
|
.attrs = gl520_attributes_opt,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Real code
|
* Real code
|
||||||
|
@ -572,33 +600,39 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||||
gl520_init_client(new_client);
|
gl520_init_client(new_client);
|
||||||
|
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
|
if ((err = sysfs_create_group(&new_client->dev.kobj, &gl520_group)))
|
||||||
|
goto exit_detach;
|
||||||
|
|
||||||
|
if (data->two_temps) {
|
||||||
|
if ((err = device_create_file(&new_client->dev,
|
||||||
|
&dev_attr_temp2_input))
|
||||||
|
|| (err = device_create_file(&new_client->dev,
|
||||||
|
&dev_attr_temp2_max))
|
||||||
|
|| (err = device_create_file(&new_client->dev,
|
||||||
|
&dev_attr_temp2_max_hyst)))
|
||||||
|
goto exit_remove_files;
|
||||||
|
} else {
|
||||||
|
if ((err = device_create_file(&new_client->dev,
|
||||||
|
&dev_attr_in4_input))
|
||||||
|
|| (err = device_create_file(&new_client->dev,
|
||||||
|
&dev_attr_in4_min))
|
||||||
|
|| (err = device_create_file(&new_client->dev,
|
||||||
|
&dev_attr_in4_max)))
|
||||||
|
goto exit_remove_files;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_create_file_vid(new_client, 0);
|
|
||||||
|
|
||||||
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);
|
|
||||||
if (!data->two_temps)
|
|
||||||
device_create_file_in(new_client, 4);
|
|
||||||
|
|
||||||
device_create_file_fan(new_client, 1);
|
|
||||||
device_create_file_fan(new_client, 2);
|
|
||||||
device_create_file_fan_off(new_client, 1);
|
|
||||||
|
|
||||||
device_create_file_temp(new_client, 1);
|
|
||||||
if (data->two_temps)
|
|
||||||
device_create_file_temp(new_client, 2);
|
|
||||||
|
|
||||||
device_create_file_alarms(new_client);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
exit_remove_files:
|
||||||
|
sysfs_remove_group(&new_client->dev.kobj, &gl520_group);
|
||||||
|
sysfs_remove_group(&new_client->dev.kobj, &gl520_group_opt);
|
||||||
exit_detach:
|
exit_detach:
|
||||||
i2c_detach_client(new_client);
|
i2c_detach_client(new_client);
|
||||||
exit_free:
|
exit_free:
|
||||||
|
@ -652,6 +686,8 @@ static int gl520_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, &gl520_group);
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &gl520_group_opt);
|
||||||
|
|
||||||
if ((err = i2c_detach_client(client)))
|
if ((err = i2c_detach_client(client)))
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <linux/hwmon-vid.h>
|
#include <linux/hwmon-vid.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/sysfs.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -758,8 +759,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_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
|
show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
|
@ -768,8 +767,88 @@ 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 struct attribute *it87_attributes[] = {
|
||||||
|
&sensor_dev_attr_in0_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in1_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in2_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in3_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in4_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in5_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in6_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in7_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in8_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in0_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in1_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in2_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in3_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in4_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in5_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in6_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in7_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in0_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in1_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in2_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in3_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in4_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in5_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in6_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in7_max.dev_attr.attr,
|
||||||
|
|
||||||
|
&sensor_dev_attr_temp1_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp2_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp3_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp1_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp2_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp3_max.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp1_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp2_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp3_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp1_type.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp2_type.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp3_type.dev_attr.attr,
|
||||||
|
|
||||||
|
&dev_attr_alarms.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group it87_group = {
|
||||||
|
.attrs = it87_attributes,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *it87_attributes_opt[] = {
|
||||||
|
&sensor_dev_attr_fan1_input16.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan1_min16.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan2_input16.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan2_min16.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan3_input16.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan3_min16.dev_attr.attr,
|
||||||
|
|
||||||
|
&sensor_dev_attr_fan1_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan1_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan1_div.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan2_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan2_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan2_div.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan3_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan3_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan3_div.dev_attr.attr,
|
||||||
|
|
||||||
|
&sensor_dev_attr_pwm1_enable.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_pwm2_enable.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_pwm3_enable.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_pwm1.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_pwm2.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_pwm3.dev_attr.attr,
|
||||||
|
|
||||||
|
&dev_attr_vrm.attr,
|
||||||
|
&dev_attr_cpu0_vid.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group it87_group_opt = {
|
||||||
|
.attrs = it87_attributes_opt,
|
||||||
|
};
|
||||||
|
|
||||||
/* This function is called when:
|
/* This function is called when:
|
||||||
* it87_driver is inserted (when this module is loaded), for each
|
* it87_driver is inserted (when this module is loaded), for each
|
||||||
|
@ -948,107 +1027,78 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||||
it87_init_client(new_client, data);
|
it87_init_client(new_client, data);
|
||||||
|
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
data->class_dev = hwmon_device_register(&new_client->dev);
|
if ((err = sysfs_create_group(&new_client->dev.kobj, &it87_group)))
|
||||||
if (IS_ERR(data->class_dev)) {
|
|
||||||
err = PTR_ERR(data->class_dev);
|
|
||||||
goto ERROR3;
|
goto ERROR3;
|
||||||
}
|
|
||||||
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_type.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_type.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_type.dev_attr);
|
|
||||||
|
|
||||||
/* Do not create fan files for disabled fans */
|
/* Do not create fan files for disabled fans */
|
||||||
if (data->type == it8716 || data->type == it8718) {
|
if (data->type == it8716 || data->type == it8718) {
|
||||||
/* 16-bit tachometers */
|
/* 16-bit tachometers */
|
||||||
if (data->has_fan & (1 << 0)) {
|
if (data->has_fan & (1 << 0)) {
|
||||||
device_create_file(&new_client->dev,
|
if ((err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan1_input16.dev_attr);
|
&sensor_dev_attr_fan1_input16.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan1_min16.dev_attr);
|
&sensor_dev_attr_fan1_min16.dev_attr)))
|
||||||
|
goto ERROR4;
|
||||||
}
|
}
|
||||||
if (data->has_fan & (1 << 1)) {
|
if (data->has_fan & (1 << 1)) {
|
||||||
device_create_file(&new_client->dev,
|
if ((err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan2_input16.dev_attr);
|
&sensor_dev_attr_fan2_input16.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan2_min16.dev_attr);
|
&sensor_dev_attr_fan2_min16.dev_attr)))
|
||||||
|
goto ERROR4;
|
||||||
}
|
}
|
||||||
if (data->has_fan & (1 << 2)) {
|
if (data->has_fan & (1 << 2)) {
|
||||||
device_create_file(&new_client->dev,
|
if ((err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan3_input16.dev_attr);
|
&sensor_dev_attr_fan3_input16.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan3_min16.dev_attr);
|
&sensor_dev_attr_fan3_min16.dev_attr)))
|
||||||
|
goto ERROR4;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* 8-bit tachometers with clock divider */
|
/* 8-bit tachometers with clock divider */
|
||||||
if (data->has_fan & (1 << 0)) {
|
if (data->has_fan & (1 << 0)) {
|
||||||
device_create_file(&new_client->dev,
|
if ((err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan1_input.dev_attr);
|
&sensor_dev_attr_fan1_input.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan1_min.dev_attr);
|
&sensor_dev_attr_fan1_min.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan1_div.dev_attr);
|
&sensor_dev_attr_fan1_div.dev_attr)))
|
||||||
|
goto ERROR4;
|
||||||
}
|
}
|
||||||
if (data->has_fan & (1 << 1)) {
|
if (data->has_fan & (1 << 1)) {
|
||||||
device_create_file(&new_client->dev,
|
if ((err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan2_input.dev_attr);
|
&sensor_dev_attr_fan2_input.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan2_min.dev_attr);
|
&sensor_dev_attr_fan2_min.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan2_div.dev_attr);
|
&sensor_dev_attr_fan2_div.dev_attr)))
|
||||||
|
goto ERROR4;
|
||||||
}
|
}
|
||||||
if (data->has_fan & (1 << 2)) {
|
if (data->has_fan & (1 << 2)) {
|
||||||
device_create_file(&new_client->dev,
|
if ((err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan3_input.dev_attr);
|
&sensor_dev_attr_fan3_input.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan3_min.dev_attr);
|
&sensor_dev_attr_fan3_min.dev_attr))
|
||||||
device_create_file(&new_client->dev,
|
|| (err = device_create_file(&new_client->dev,
|
||||||
&sensor_dev_attr_fan3_div.dev_attr);
|
&sensor_dev_attr_fan3_div.dev_attr)))
|
||||||
|
goto ERROR4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_alarms);
|
|
||||||
if (enable_pwm_interface) {
|
if (enable_pwm_interface) {
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm1_enable.dev_attr);
|
if ((err = device_create_file(&new_client->dev,
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm2_enable.dev_attr);
|
&sensor_dev_attr_pwm1_enable.dev_attr))
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm3_enable.dev_attr);
|
|| (err = device_create_file(&new_client->dev,
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr);
|
&sensor_dev_attr_pwm2_enable.dev_attr))
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr);
|
|| (err = device_create_file(&new_client->dev,
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr);
|
&sensor_dev_attr_pwm3_enable.dev_attr))
|
||||||
|
|| (err = device_create_file(&new_client->dev,
|
||||||
|
&sensor_dev_attr_pwm1.dev_attr))
|
||||||
|
|| (err = device_create_file(&new_client->dev,
|
||||||
|
&sensor_dev_attr_pwm2.dev_attr))
|
||||||
|
|| (err = device_create_file(&new_client->dev,
|
||||||
|
&sensor_dev_attr_pwm3.dev_attr)))
|
||||||
|
goto ERROR4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->type == it8712 || data->type == it8716
|
if (data->type == it8712 || data->type == it8716
|
||||||
|
@ -1056,12 +1106,24 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||||
data->vrm = vid_which_vrm();
|
data->vrm = vid_which_vrm();
|
||||||
/* VID reading from Super-I/O config space if available */
|
/* VID reading from Super-I/O config space if available */
|
||||||
data->vid = vid_value;
|
data->vid = vid_value;
|
||||||
device_create_file_vrm(new_client);
|
if ((err = device_create_file(&new_client->dev,
|
||||||
device_create_file_vid(new_client);
|
&dev_attr_vrm))
|
||||||
|
|| (err = device_create_file(&new_client->dev,
|
||||||
|
&dev_attr_cpu0_vid)))
|
||||||
|
goto ERROR4;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->class_dev = hwmon_device_register(&new_client->dev);
|
||||||
|
if (IS_ERR(data->class_dev)) {
|
||||||
|
err = PTR_ERR(data->class_dev);
|
||||||
|
goto ERROR4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
ERROR4:
|
||||||
|
sysfs_remove_group(&new_client->dev.kobj, &it87_group);
|
||||||
|
sysfs_remove_group(&new_client->dev.kobj, &it87_group_opt);
|
||||||
ERROR3:
|
ERROR3:
|
||||||
i2c_detach_client(new_client);
|
i2c_detach_client(new_client);
|
||||||
ERROR2:
|
ERROR2:
|
||||||
|
@ -1079,6 +1141,8 @@ static int it87_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, &it87_group);
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &it87_group_opt);
|
||||||
|
|
||||||
if ((err = i2c_detach_client(client)))
|
if ((err = i2c_detach_client(client)))
|
||||||
return err;
|
return err;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче