aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/f71805f.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2006-12-12 12:18:29 -0500
committerJean Delvare <khali@arrakis.delvare>2006-12-12 12:18:29 -0500
commitc7176cb515edbc937006fd05fa391b0d926a337a (patch)
tree4cfd5b7d3bc9bd77b4754abb0b93b9b6cc68fd0c /drivers/hwmon/f71805f.c
parent51c997d80e1f625aea3426a8a9087f5830ac6db3 (diff)
hwmon/f71805f: Always create all fan inputs
Fans can be hotplugged, so we should create sysfs file even for fans which are disabled at driver load time. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/f71805f.c')
-rw-r--r--drivers/hwmon/f71805f.c74
1 files changed, 23 insertions, 51 deletions
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index ba5e7b70f8cc..37ba421789bc 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -132,7 +132,6 @@ superio_exit(int base)
132#define F71805F_REG_STATUS(nr) (0x36 + (nr)) 132#define F71805F_REG_STATUS(nr) (0x36 + (nr))
133 133
134/* individual register bits */ 134/* individual register bits */
135#define FAN_CTRL_SKIP 0x80
136#define FAN_CTRL_DC_MODE 0x10 135#define FAN_CTRL_DC_MODE 0x10
137#define FAN_CTRL_LATCH_FULL 0x08 136#define FAN_CTRL_LATCH_FULL 0x08
138#define FAN_CTRL_MODE_MASK 0x03 137#define FAN_CTRL_MODE_MASK 0x03
@@ -337,8 +336,6 @@ static struct f71805f_data *f71805f_update_device(struct device *dev)
337 F71805F_REG_IN_LOW(nr)); 336 F71805F_REG_IN_LOW(nr));
338 } 337 }
339 for (nr = 0; nr < 3; nr++) { 338 for (nr = 0; nr < 3; nr++) {
340 if (data->fan_ctrl[nr] & FAN_CTRL_SKIP)
341 continue;
342 data->fan_low[nr] = f71805f_read16(data, 339 data->fan_low[nr] = f71805f_read16(data,
343 F71805F_REG_FAN_LOW(nr)); 340 F71805F_REG_FAN_LOW(nr));
344 data->fan_target[nr] = f71805f_read16(data, 341 data->fan_target[nr] = f71805f_read16(data,
@@ -367,8 +364,6 @@ static struct f71805f_data *f71805f_update_device(struct device *dev)
367 F71805F_REG_IN(nr)); 364 F71805F_REG_IN(nr));
368 } 365 }
369 for (nr = 0; nr < 3; nr++) { 366 for (nr = 0; nr < 3; nr++) {
370 if (data->fan_ctrl[nr] & FAN_CTRL_SKIP)
371 continue;
372 data->fan[nr] = f71805f_read16(data, 367 data->fan[nr] = f71805f_read16(data,
373 F71805F_REG_FAN(nr)); 368 F71805F_REG_FAN(nr));
374 data->fan_ctrl[nr] = f71805f_read8(data, 369 data->fan_ctrl[nr] = f71805f_read8(data,
@@ -991,6 +986,29 @@ static struct attribute *f71805f_attributes[] = {
991 &sensor_dev_attr_in7_max.dev_attr.attr, 986 &sensor_dev_attr_in7_max.dev_attr.attr,
992 &sensor_dev_attr_in7_min.dev_attr.attr, 987 &sensor_dev_attr_in7_min.dev_attr.attr,
993 988
989 &sensor_dev_attr_fan1_input.dev_attr.attr,
990 &sensor_dev_attr_fan1_min.dev_attr.attr,
991 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
992 &sensor_dev_attr_fan1_target.dev_attr.attr,
993 &sensor_dev_attr_fan2_input.dev_attr.attr,
994 &sensor_dev_attr_fan2_min.dev_attr.attr,
995 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
996 &sensor_dev_attr_fan2_target.dev_attr.attr,
997 &sensor_dev_attr_fan3_input.dev_attr.attr,
998 &sensor_dev_attr_fan3_min.dev_attr.attr,
999 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
1000 &sensor_dev_attr_fan3_target.dev_attr.attr,
1001
1002 &sensor_dev_attr_pwm1.dev_attr.attr,
1003 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1004 &sensor_dev_attr_pwm1_mode.dev_attr.attr,
1005 &sensor_dev_attr_pwm2.dev_attr.attr,
1006 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1007 &sensor_dev_attr_pwm2_mode.dev_attr.attr,
1008 &sensor_dev_attr_pwm3.dev_attr.attr,
1009 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1010 &sensor_dev_attr_pwm3_mode.dev_attr.attr,
1011
994 &sensor_dev_attr_temp1_input.dev_attr.attr, 1012 &sensor_dev_attr_temp1_input.dev_attr.attr,
995 &sensor_dev_attr_temp1_max.dev_attr.attr, 1013 &sensor_dev_attr_temp1_max.dev_attr.attr,
996 &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, 1014 &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
@@ -1061,43 +1079,6 @@ static const struct attribute_group f71805f_group_optin[4] = {
1061 { .attrs = f71805f_attributes_optin[3] }, 1079 { .attrs = f71805f_attributes_optin[3] },
1062}; 1080};
1063 1081
1064static struct attribute *f71805f_attributes_fan[3][8] = {
1065 {
1066 &sensor_dev_attr_fan1_input.dev_attr.attr,
1067 &sensor_dev_attr_fan1_min.dev_attr.attr,
1068 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
1069 &sensor_dev_attr_fan1_target.dev_attr.attr,
1070 &sensor_dev_attr_pwm1.dev_attr.attr,
1071 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
1072 &sensor_dev_attr_pwm1_mode.dev_attr.attr,
1073 NULL
1074 }, {
1075 &sensor_dev_attr_fan2_input.dev_attr.attr,
1076 &sensor_dev_attr_fan2_min.dev_attr.attr,
1077 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
1078 &sensor_dev_attr_fan2_target.dev_attr.attr,
1079 &sensor_dev_attr_pwm2.dev_attr.attr,
1080 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
1081 &sensor_dev_attr_pwm2_mode.dev_attr.attr,
1082 NULL
1083 }, {
1084 &sensor_dev_attr_fan3_input.dev_attr.attr,
1085 &sensor_dev_attr_fan3_min.dev_attr.attr,
1086 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
1087 &sensor_dev_attr_fan3_target.dev_attr.attr,
1088 &sensor_dev_attr_pwm3.dev_attr.attr,
1089 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
1090 &sensor_dev_attr_pwm3_mode.dev_attr.attr,
1091 NULL
1092 }
1093};
1094
1095static const struct attribute_group f71805f_group_fan[3] = {
1096 { .attrs = f71805f_attributes_fan[0] },
1097 { .attrs = f71805f_attributes_fan[1] },
1098 { .attrs = f71805f_attributes_fan[2] },
1099};
1100
1101/* We don't include pwm_freq files in the arrays above, because they must be 1082/* We don't include pwm_freq files in the arrays above, because they must be
1102 created conditionally (only if pwm_mode is 1 == PWM) */ 1083 created conditionally (only if pwm_mode is 1 == PWM) */
1103static struct attribute *f71805f_attributes_pwm_freq[] = { 1084static struct attribute *f71805f_attributes_pwm_freq[] = {
@@ -1216,11 +1197,6 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
1216 goto exit_remove_files; 1197 goto exit_remove_files;
1217 } 1198 }
1218 for (i = 0; i < 3; i++) { 1199 for (i = 0; i < 3; i++) {
1219 if (data->fan_ctrl[i] & FAN_CTRL_SKIP)
1220 continue;
1221 if ((err = sysfs_create_group(&pdev->dev.kobj,
1222 &f71805f_group_fan[i])))
1223 goto exit_remove_files;
1224 /* If control mode is PWM, create pwm_freq file */ 1200 /* If control mode is PWM, create pwm_freq file */
1225 if (!(data->fan_ctrl[i] & FAN_CTRL_DC_MODE)) { 1201 if (!(data->fan_ctrl[i] & FAN_CTRL_DC_MODE)) {
1226 if ((err = sysfs_create_file(&pdev->dev.kobj, 1202 if ((err = sysfs_create_file(&pdev->dev.kobj,
@@ -1252,8 +1228,6 @@ exit_remove_files:
1252 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); 1228 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group);
1253 for (i = 0; i < 4; i++) 1229 for (i = 0; i < 4; i++)
1254 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); 1230 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]);
1255 for (i = 0; i < 3; i++)
1256 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]);
1257 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); 1231 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq);
1258exit_free: 1232exit_free:
1259 platform_set_drvdata(pdev, NULL); 1233 platform_set_drvdata(pdev, NULL);
@@ -1272,8 +1246,6 @@ static int __devexit f71805f_remove(struct platform_device *pdev)
1272 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); 1246 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group);
1273 for (i = 0; i < 4; i++) 1247 for (i = 0; i < 4; i++)
1274 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); 1248 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]);
1275 for (i = 0; i < 3; i++)
1276 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]);
1277 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); 1249 sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq);
1278 kfree(data); 1250 kfree(data);
1279 1251