Stage a development patch (possibly incomplete) that might not be the
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / queues / thinkpad-acpi / thinkpad-acpi-report-missing-thermal-sensors.patch
blobfe175d1aa0c7eb72e58d233f5981697fee47a4a6
1 From ad953f83f52e33d88b0f21cb1e841aa11cc0bffd Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Wed, 3 Oct 2007 01:43:54 -0300
4 Subject: ACPI: thinkpad-acpi: report missing thermal sensors as faulty
6 The libsensors4/lm-sensors 3.0.0 hwmon interface defines that missing
7 sensors should be reported by a <foo>_fault attribute.
9 Add such _fault files for thermal sensors, and set them to 1 if the
10 firmware is returning +/-128 (sensor not available).
12 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
13 ---
14 drivers/misc/thinkpad_acpi.c | 56 +++++++++++++++++++++++++++++++++++++++---
15 1 files changed, 52 insertions(+), 4 deletions(-)
17 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
18 index 5f741a1..f8e06c6 100644
19 --- a/drivers/misc/thinkpad_acpi.c
20 +++ b/drivers/misc/thinkpad_acpi.c
21 @@ -3832,8 +3832,55 @@ static struct sensor_device_attribute sensor_dev_attr_thermal_temp_input[] = {
22 THERMAL_SENSOR_ATTR_TEMP(16, 15),
25 +#undef THERMAL_SENSOR_ATTR_TEMP
27 +/* sysfs temp##_fault -------------------------------------------------- */
29 +static ssize_t thermal_temp_fault_show(struct device *dev,
30 + struct device_attribute *attr,
31 + char *buf)
33 + struct sensor_device_attribute *sensor_attr =
34 + to_sensor_dev_attr(attr);
35 + int idx = sensor_attr->index;
36 + s32 value;
37 + int res;
39 + res = thermal_get_sensor(idx, &value);
40 + if (res)
41 + return res;
43 + return snprintf(buf, PAGE_SIZE, "%d\n",
44 + (value == TP_EC_THERMAL_TMP_NA * 1000));
47 +#define THERMAL_SENSOR_ATTR_FAULT(_idxA, _idxB) \
48 + SENSOR_ATTR(temp##_idxA##_fault, S_IRUGO, thermal_temp_fault_show, NULL, _idxB)
50 +static struct sensor_device_attribute sensor_dev_attr_thermal_temp_fault[] = {
51 + THERMAL_SENSOR_ATTR_FAULT(1, 0),
52 + THERMAL_SENSOR_ATTR_FAULT(2, 1),
53 + THERMAL_SENSOR_ATTR_FAULT(3, 2),
54 + THERMAL_SENSOR_ATTR_FAULT(4, 3),
55 + THERMAL_SENSOR_ATTR_FAULT(5, 4),
56 + THERMAL_SENSOR_ATTR_FAULT(6, 5),
57 + THERMAL_SENSOR_ATTR_FAULT(7, 6),
58 + THERMAL_SENSOR_ATTR_FAULT(8, 7),
59 + THERMAL_SENSOR_ATTR_FAULT(9, 8),
60 + THERMAL_SENSOR_ATTR_FAULT(10, 9),
61 + THERMAL_SENSOR_ATTR_FAULT(11, 10),
62 + THERMAL_SENSOR_ATTR_FAULT(12, 11),
63 + THERMAL_SENSOR_ATTR_FAULT(13, 12),
64 + THERMAL_SENSOR_ATTR_FAULT(14, 13),
65 + THERMAL_SENSOR_ATTR_FAULT(15, 14),
66 + THERMAL_SENSOR_ATTR_FAULT(16, 15),
67 +};
69 +#undef THERMAL_SENSOR_ATTR_FAULT
71 #define THERMAL_ATTRS(X) \
72 - &sensor_dev_attr_thermal_temp_input[X].dev_attr.attr
73 + &sensor_dev_attr_thermal_temp_input[X].dev_attr.attr, \
74 + &sensor_dev_attr_thermal_temp_fault[X].dev_attr.attr
76 static struct attribute *thermal_temp_input_attr[] = {
77 THERMAL_ATTRS(8),
78 @@ -3855,16 +3902,17 @@ static struct attribute *thermal_temp_input_attr[] = {
79 NULL
82 +#undef THERMAL_ATTRS
84 static const struct attribute_group thermal_temp_input16_group = {
85 .attrs = thermal_temp_input_attr
88 static const struct attribute_group thermal_temp_input8_group = {
89 - .attrs = &thermal_temp_input_attr[8]
90 + /* 8 times the number of items in THERMAL_ATTRS */
91 + .attrs = &thermal_temp_input_attr[16]
94 -#undef THERMAL_SENSOR_ATTR_TEMP
95 -#undef THERMAL_ATTRS
97 /* --------------------------------------------------------------------- */
99 --
100 1.5.4.2