diff options
author | Jean Delvare | 2007-11-29 23:47:54 +0100 |
---|---|---|
committer | Mark M. Hoffman | 2008-02-07 20:39:43 -0500 |
commit | 5b34dbcd88251508d02e48ad9b0f9b8232a13ee0 (patch) | |
tree | fdc0d9d1cfbf22240a73a13b08dae3ecf91cb33d /drivers/hwmon | |
parent | f67fdabfb94b0bb96623a4b48d22be5329a06277 (diff) |
hwmon: (adm1026) Don't create files for missing inputs
On the ADM1026, pins 27 and 28 can be used for two different functions:
either temp3, or in8+in9. We should only create the sysfs files for the
function that is configured, otherwise it is confusing for the user.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/adm1026.c | 70 |
1 files changed, 50 insertions, 20 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index a20af03f4fc6..8002f68240c4 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -1507,14 +1507,6 @@ static struct attribute *adm1026_attributes[] = { &sensor_dev_attr_in7_max.dev_attr.attr, &sensor_dev_attr_in7_min.dev_attr.attr, &sensor_dev_attr_in7_alarm.dev_attr.attr, - &sensor_dev_attr_in8_input.dev_attr.attr, - &sensor_dev_attr_in8_max.dev_attr.attr, - &sensor_dev_attr_in8_min.dev_attr.attr, - &sensor_dev_attr_in8_alarm.dev_attr.attr, - &sensor_dev_attr_in9_input.dev_attr.attr, - &sensor_dev_attr_in9_max.dev_attr.attr, - &sensor_dev_attr_in9_min.dev_attr.attr, - &sensor_dev_attr_in9_alarm.dev_attr.attr, &sensor_dev_attr_in10_input.dev_attr.attr, &sensor_dev_attr_in10_max.dev_attr.attr, &sensor_dev_attr_in10_min.dev_attr.attr, @@ -1583,28 +1575,18 @@ static struct attribute *adm1026_attributes[] = { &sensor_dev_attr_temp2_max.dev_attr.attr, &sensor_dev_attr_temp2_min.dev_attr.attr, &sensor_dev_attr_temp2_alarm.dev_attr.attr, - &sensor_dev_attr_temp3_input.dev_attr.attr, - &sensor_dev_attr_temp3_max.dev_attr.attr, - &sensor_dev_attr_temp3_min.dev_attr.attr, - &sensor_dev_attr_temp3_alarm.dev_attr.attr, &sensor_dev_attr_temp1_offset.dev_attr.attr, &sensor_dev_attr_temp2_offset.dev_attr.attr, - &sensor_dev_attr_temp3_offset.dev_attr.attr, &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr, &sensor_dev_attr_temp2_auto_point1_temp.dev_attr.attr, - &sensor_dev_attr_temp3_auto_point1_temp.dev_attr.attr, &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr.attr, &sensor_dev_attr_temp2_auto_point1_temp_hyst.dev_attr.attr, - &sensor_dev_attr_temp3_auto_point1_temp_hyst.dev_attr.attr, &sensor_dev_attr_temp1_auto_point2_temp.dev_attr.attr, &sensor_dev_attr_temp2_auto_point2_temp.dev_attr.attr, - &sensor_dev_attr_temp3_auto_point2_temp.dev_attr.attr, &sensor_dev_attr_temp1_crit.dev_attr.attr, &sensor_dev_attr_temp2_crit.dev_attr.attr, - &sensor_dev_attr_temp3_crit.dev_attr.attr, &dev_attr_temp1_crit_enable.attr, &dev_attr_temp2_crit_enable.attr, - &dev_attr_temp3_crit_enable.attr, &dev_attr_cpu0_vid.attr, &dev_attr_vrm.attr, &dev_attr_alarms.attr, @@ -1619,10 +1601,8 @@ static struct attribute *adm1026_attributes[] = { &dev_attr_pwm3_enable.attr, &dev_attr_temp1_auto_point1_pwm.attr, &dev_attr_temp2_auto_point1_pwm.attr, - &dev_attr_temp3_auto_point1_pwm.attr, &dev_attr_temp1_auto_point2_pwm.attr, &dev_attr_temp2_auto_point2_pwm.attr, - &dev_attr_temp3_auto_point2_pwm.attr, &dev_attr_analog_out.attr, NULL }; @@ -1631,6 +1611,40 @@ static const struct attribute_group adm1026_group = { .attrs = adm1026_attributes, }; +static struct attribute *adm1026_attributes_temp3[] = { + &sensor_dev_attr_temp3_input.dev_attr.attr, + &sensor_dev_attr_temp3_max.dev_attr.attr, + &sensor_dev_attr_temp3_min.dev_attr.attr, + &sensor_dev_attr_temp3_alarm.dev_attr.attr, + &sensor_dev_attr_temp3_offset.dev_attr.attr, + &sensor_dev_attr_temp3_auto_point1_temp.dev_attr.attr, + &sensor_dev_attr_temp3_auto_point1_temp_hyst.dev_attr.attr, + &sensor_dev_attr_temp3_auto_point2_temp.dev_attr.attr, + &sensor_dev_attr_temp3_crit.dev_attr.attr, + &dev_attr_temp3_crit_enable.attr, + &dev_attr_temp3_auto_point1_pwm.attr, + &dev_attr_temp3_auto_point2_pwm.attr, +}; + +static const struct attribute_group adm1026_group_temp3 = { + .attrs = adm1026_attributes_temp3, +}; + +static struct attribute *adm1026_attributes_in8_9[] = { + &sensor_dev_attr_in8_input.dev_attr.attr, + &sensor_dev_attr_in8_max.dev_attr.attr, + &sensor_dev_attr_in8_min.dev_attr.attr, + &sensor_dev_attr_in8_alarm.dev_attr.attr, + &sensor_dev_attr_in9_input.dev_attr.attr, + &sensor_dev_attr_in9_max.dev_attr.attr, + &sensor_dev_attr_in9_min.dev_attr.attr, + &sensor_dev_attr_in9_alarm.dev_attr.attr, +}; + +static const struct attribute_group adm1026_group_in8_9 = { + .attrs = adm1026_attributes_in8_9, +}; + static int adm1026_detect(struct i2c_adapter *adapter, int address, int kind) { @@ -1733,6 +1747,14 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, /* Register sysfs hooks */ if ((err = sysfs_create_group(&client->dev.kobj, &adm1026_group))) goto exitdetach; + if (data->config1 & CFG1_AIN8_9) + err = sysfs_create_group(&client->dev.kobj, + &adm1026_group_in8_9); + else + err = sysfs_create_group(&client->dev.kobj, + &adm1026_group_temp3); + if (err) + goto exitremove; data->hwmon_dev = hwmon_device_register(&client->dev); if (IS_ERR(data->hwmon_dev)) { @@ -1745,6 +1767,10 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, /* Error out and cleanup code */ exitremove: sysfs_remove_group(&client->dev.kobj, &adm1026_group); + if (data->config1 & CFG1_AIN8_9) + sysfs_remove_group(&client->dev.kobj, &adm1026_group_in8_9); + else + sysfs_remove_group(&client->dev.kobj, &adm1026_group_temp3); exitdetach: i2c_detach_client(client); exitfree: @@ -1758,6 +1784,10 @@ static int adm1026_detach_client(struct i2c_client *client) struct adm1026_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &adm1026_group); + if (data->config1 & CFG1_AIN8_9) + sysfs_remove_group(&client->dev.kobj, &adm1026_group_in8_9); + else + sysfs_remove_group(&client->dev.kobj, &adm1026_group_temp3); i2c_detach_client(client); kfree(data); return 0; |