diff options
author | Hans de Goede <hdegoede@redhat.com> | 2011-03-09 14:57:12 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-03-15 01:39:24 -0400 |
commit | 78aa4f72b30e4f2c631f6f550a911aad24769cfd (patch) | |
tree | 75e5b1c6f962ae97add4086e1c96eae22985b837 /drivers/hwmon/f71882fg.c | |
parent | 2a91946ac94765d22ebdc4afdeb2bf7028bfe623 (diff) |
hwmon/f71882fg: Separate temp beep sysfs attr from the other temp sysfs attr
This is a preparation patch for adding support for more different models.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/f71882fg.c')
-rw-r--r-- | drivers/hwmon/f71882fg.c | 76 |
1 files changed, 53 insertions, 23 deletions
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index b8b4bc9db03d..62352fd397df 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c | |||
@@ -127,6 +127,14 @@ static const char f71882fg_has_in1_alarm[5] = { | |||
127 | 0, /* f8000 */ | 127 | 0, /* f8000 */ |
128 | }; | 128 | }; |
129 | 129 | ||
130 | static const char f71882fg_has_beep[5] = { | ||
131 | 0, /* f71858fg */ | ||
132 | 1, /* f71862fg */ | ||
133 | 1, /* f71882fg */ | ||
134 | 1, /* f71889fg */ | ||
135 | 0, /* f8000 */ | ||
136 | }; | ||
137 | |||
130 | static struct platform_device *f71882fg_pdev; | 138 | static struct platform_device *f71882fg_pdev; |
131 | 139 | ||
132 | /* Super-I/O Function prototypes */ | 140 | /* Super-I/O Function prototypes */ |
@@ -324,7 +332,7 @@ static struct sensor_device_attribute_2 f71858fg_temp_attr[] = { | |||
324 | }; | 332 | }; |
325 | 333 | ||
326 | /* Temp attr for the standard models */ | 334 | /* Temp attr for the standard models */ |
327 | static struct sensor_device_attribute_2 fxxxx_temp_attr[3][11] = { { | 335 | static struct sensor_device_attribute_2 fxxxx_temp_attr[3][9] = { { |
328 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 1), | 336 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 1), |
329 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, | 337 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, |
330 | store_temp_max, 0, 1), | 338 | store_temp_max, 0, 1), |
@@ -334,15 +342,11 @@ static struct sensor_device_attribute_2 fxxxx_temp_attr[3][11] = { { | |||
334 | the max and crit alarms separately and lm_sensors v2 depends on the | 342 | the max and crit alarms separately and lm_sensors v2 depends on the |
335 | presence of temp#_alarm files. The same goes for temp2/3 _alarm. */ | 343 | presence of temp#_alarm files. The same goes for temp2/3 _alarm. */ |
336 | SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 1), | 344 | SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 1), |
337 | SENSOR_ATTR_2(temp1_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
338 | store_temp_beep, 0, 1), | ||
339 | SENSOR_ATTR_2(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit, | 345 | SENSOR_ATTR_2(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
340 | store_temp_crit, 0, 1), | 346 | store_temp_crit, 0, 1), |
341 | SENSOR_ATTR_2(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | 347 | SENSOR_ATTR_2(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
342 | 0, 1), | 348 | 0, 1), |
343 | SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5), | 349 | SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5), |
344 | SENSOR_ATTR_2(temp1_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
345 | store_temp_beep, 0, 5), | ||
346 | SENSOR_ATTR_2(temp1_type, S_IRUGO, show_temp_type, NULL, 0, 1), | 350 | SENSOR_ATTR_2(temp1_type, S_IRUGO, show_temp_type, NULL, 0, 1), |
347 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), | 351 | SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 1), |
348 | }, { | 352 | }, { |
@@ -353,15 +357,11 @@ static struct sensor_device_attribute_2 fxxxx_temp_attr[3][11] = { { | |||
353 | store_temp_max_hyst, 0, 2), | 357 | store_temp_max_hyst, 0, 2), |
354 | /* Should be temp2_max_alarm, see temp1_alarm note */ | 358 | /* Should be temp2_max_alarm, see temp1_alarm note */ |
355 | SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 2), | 359 | SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 2), |
356 | SENSOR_ATTR_2(temp2_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
357 | store_temp_beep, 0, 2), | ||
358 | SENSOR_ATTR_2(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit, | 360 | SENSOR_ATTR_2(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
359 | store_temp_crit, 0, 2), | 361 | store_temp_crit, 0, 2), |
360 | SENSOR_ATTR_2(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | 362 | SENSOR_ATTR_2(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
361 | 0, 2), | 363 | 0, 2), |
362 | SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6), | 364 | SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6), |
363 | SENSOR_ATTR_2(temp2_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
364 | store_temp_beep, 0, 6), | ||
365 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 2), | 365 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 2), |
366 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), | 366 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), |
367 | }, { | 367 | }, { |
@@ -372,19 +372,33 @@ static struct sensor_device_attribute_2 fxxxx_temp_attr[3][11] = { { | |||
372 | store_temp_max_hyst, 0, 3), | 372 | store_temp_max_hyst, 0, 3), |
373 | /* Should be temp3_max_alarm, see temp1_alarm note */ | 373 | /* Should be temp3_max_alarm, see temp1_alarm note */ |
374 | SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 3), | 374 | SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 3), |
375 | SENSOR_ATTR_2(temp3_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
376 | store_temp_beep, 0, 3), | ||
377 | SENSOR_ATTR_2(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit, | 375 | SENSOR_ATTR_2(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit, |
378 | store_temp_crit, 0, 3), | 376 | store_temp_crit, 0, 3), |
379 | SENSOR_ATTR_2(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, | 377 | SENSOR_ATTR_2(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, |
380 | 0, 3), | 378 | 0, 3), |
381 | SENSOR_ATTR_2(temp3_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 7), | 379 | SENSOR_ATTR_2(temp3_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 7), |
382 | SENSOR_ATTR_2(temp3_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
383 | store_temp_beep, 0, 7), | ||
384 | SENSOR_ATTR_2(temp3_type, S_IRUGO, show_temp_type, NULL, 0, 3), | 380 | SENSOR_ATTR_2(temp3_type, S_IRUGO, show_temp_type, NULL, 0, 3), |
385 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 3), | 381 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 3), |
386 | } }; | 382 | } }; |
387 | 383 | ||
384 | /* Temp attr for models which can beep on temp alarm */ | ||
385 | static struct sensor_device_attribute_2 fxxxx_temp_beep_attr[3][2] = { { | ||
386 | SENSOR_ATTR_2(temp1_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
387 | store_temp_beep, 0, 1), | ||
388 | SENSOR_ATTR_2(temp1_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
389 | store_temp_beep, 0, 5), | ||
390 | }, { | ||
391 | SENSOR_ATTR_2(temp2_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
392 | store_temp_beep, 0, 2), | ||
393 | SENSOR_ATTR_2(temp2_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
394 | store_temp_beep, 0, 6), | ||
395 | }, { | ||
396 | SENSOR_ATTR_2(temp3_max_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
397 | store_temp_beep, 0, 3), | ||
398 | SENSOR_ATTR_2(temp3_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep, | ||
399 | store_temp_beep, 0, 7), | ||
400 | } }; | ||
401 | |||
388 | /* Temp attr for the f8000 | 402 | /* Temp attr for the f8000 |
389 | Note on the f8000 temp_ovt (crit) is used as max, and temp_high (max) | 403 | Note on the f8000 temp_ovt (crit) is used as max, and temp_high (max) |
390 | is used as hysteresis value to clear alarms | 404 | is used as hysteresis value to clear alarms |
@@ -989,17 +1003,19 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
989 | data->temp_hyst[1] = f71882fg_read8(data, | 1003 | data->temp_hyst[1] = f71882fg_read8(data, |
990 | F71882FG_REG_TEMP_HYST(1)); | 1004 | F71882FG_REG_TEMP_HYST(1)); |
991 | } | 1005 | } |
1006 | /* All but the f71858fg / f8000 have this register */ | ||
1007 | if ((data->type != f71858fg) && (data->type != f8000)) { | ||
1008 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); | ||
1009 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; | ||
1010 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; | ||
1011 | data->temp_type[3] = (reg & 0x08) ? 2 : 4; | ||
1012 | } | ||
992 | 1013 | ||
993 | if (data->type == f71862fg || data->type == f71882fg || | 1014 | if (f71882fg_has_beep[data->type]) { |
994 | data->type == f71889fg) { | ||
995 | data->fan_beep = f71882fg_read8(data, | 1015 | data->fan_beep = f71882fg_read8(data, |
996 | F71882FG_REG_FAN_BEEP); | 1016 | F71882FG_REG_FAN_BEEP); |
997 | data->temp_beep = f71882fg_read8(data, | 1017 | data->temp_beep = f71882fg_read8(data, |
998 | F71882FG_REG_TEMP_BEEP); | 1018 | F71882FG_REG_TEMP_BEEP); |
999 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); | ||
1000 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; | ||
1001 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; | ||
1002 | data->temp_type[3] = (reg & 0x08) ? 2 : 4; | ||
1003 | } | 1019 | } |
1004 | 1020 | ||
1005 | data->pwm_enable = f71882fg_read8(data, | 1021 | data->pwm_enable = f71882fg_read8(data, |
@@ -1979,6 +1995,15 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1979 | if (err) | 1995 | if (err) |
1980 | goto exit_unregister_sysfs; | 1996 | goto exit_unregister_sysfs; |
1981 | 1997 | ||
1998 | if (f71882fg_has_beep[data->type]) { | ||
1999 | err = f71882fg_create_sysfs_files(pdev, | ||
2000 | &fxxxx_temp_beep_attr[0][0], | ||
2001 | ARRAY_SIZE(fxxxx_temp_beep_attr[0]) | ||
2002 | * nr_temps); | ||
2003 | if (err) | ||
2004 | goto exit_unregister_sysfs; | ||
2005 | } | ||
2006 | |||
1982 | for (i = 0; i < F71882FG_MAX_INS; i++) { | 2007 | for (i = 0; i < F71882FG_MAX_INS; i++) { |
1983 | if (f71882fg_has_in[data->type][i]) { | 2008 | if (f71882fg_has_in[data->type][i]) { |
1984 | err = device_create_file(&pdev->dev, | 2009 | err = device_create_file(&pdev->dev, |
@@ -2042,8 +2067,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
2042 | if (err) | 2067 | if (err) |
2043 | goto exit_unregister_sysfs; | 2068 | goto exit_unregister_sysfs; |
2044 | 2069 | ||
2045 | if (data->type == f71862fg || data->type == f71882fg || | 2070 | if (f71882fg_has_beep[data->type]) { |
2046 | data->type == f71889fg) { | ||
2047 | err = f71882fg_create_sysfs_files(pdev, | 2071 | err = f71882fg_create_sysfs_files(pdev, |
2048 | fxxxx_fan_beep_attr, nr_fans); | 2072 | fxxxx_fan_beep_attr, nr_fans); |
2049 | if (err) | 2073 | if (err) |
@@ -2147,6 +2171,12 @@ static int f71882fg_remove(struct platform_device *pdev) | |||
2147 | &fxxxx_temp_attr[0][0], | 2171 | &fxxxx_temp_attr[0][0], |
2148 | ARRAY_SIZE(fxxxx_temp_attr[0]) * nr_temps); | 2172 | ARRAY_SIZE(fxxxx_temp_attr[0]) * nr_temps); |
2149 | } | 2173 | } |
2174 | if (f71882fg_has_beep[data->type]) { | ||
2175 | f71882fg_remove_sysfs_files(pdev, | ||
2176 | &fxxxx_temp_beep_attr[0][0], | ||
2177 | ARRAY_SIZE(fxxxx_temp_beep_attr[0]) * nr_temps); | ||
2178 | } | ||
2179 | |||
2150 | for (i = 0; i < F71882FG_MAX_INS; i++) { | 2180 | for (i = 0; i < F71882FG_MAX_INS; i++) { |
2151 | if (f71882fg_has_in[data->type][i]) { | 2181 | if (f71882fg_has_in[data->type][i]) { |
2152 | device_remove_file(&pdev->dev, | 2182 | device_remove_file(&pdev->dev, |
@@ -2164,10 +2194,10 @@ static int f71882fg_remove(struct platform_device *pdev) | |||
2164 | f71882fg_remove_sysfs_files(pdev, &fxxxx_fan_attr[0][0], | 2194 | f71882fg_remove_sysfs_files(pdev, &fxxxx_fan_attr[0][0], |
2165 | ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans); | 2195 | ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans); |
2166 | 2196 | ||
2167 | if (data->type == f71862fg || data->type == f71882fg || | 2197 | if (f71882fg_has_beep[data->type]) { |
2168 | data->type == f71889fg) | ||
2169 | f71882fg_remove_sysfs_files(pdev, | 2198 | f71882fg_remove_sysfs_files(pdev, |
2170 | fxxxx_fan_beep_attr, nr_fans); | 2199 | fxxxx_fan_beep_attr, nr_fans); |
2200 | } | ||
2171 | 2201 | ||
2172 | switch (data->type) { | 2202 | switch (data->type) { |
2173 | case f71862fg: | 2203 | case f71862fg: |