aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2011-06-09 21:05:16 -0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-07-28 03:17:33 -0400
commitdabaa0d2b4085a2037d80a40b86ba215f00b601e (patch)
tree1be3184d5eff3d571a66db264ed3e68f989c85e7 /drivers/hwmon
parent731b4cace10f105a81d622b70f9a35f577612d63 (diff)
hwmon: (max1668) Add support for tempX_fault attributes
MAX1668 and compatibles have several external temperature sensors, but only a single FAULT status bit. If a fault occurs, the temperature reported on the affected sensors is 127 degrees C. Use this knowledge to report fault on external sensors. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/max1668.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/drivers/hwmon/max1668.c b/drivers/hwmon/max1668.c
index ddefb64b6ea2..20d1b2ddffb6 100644
--- a/drivers/hwmon/max1668.c
+++ b/drivers/hwmon/max1668.c
@@ -122,16 +122,14 @@ static struct max1668_data *max1668_update_device(struct device *dev)
122 ret = ERR_PTR(val); 122 ret = ERR_PTR(val);
123 goto abort; 123 goto abort;
124 } 124 }
125 data->alarms &= 0x00ff; 125 data->alarms = val << 8;
126 data->alarms |= ((u8) (val & 0x60)) << 8;
127 126
128 val = i2c_smbus_read_byte_data(client, MAX1668_REG_STAT2); 127 val = i2c_smbus_read_byte_data(client, MAX1668_REG_STAT2);
129 if (unlikely(val < 0)) { 128 if (unlikely(val < 0)) {
130 ret = ERR_PTR(val); 129 ret = ERR_PTR(val);
131 goto abort; 130 goto abort;
132 } 131 }
133 data->alarms &= 0xff00; 132 data->alarms |= val;
134 data->alarms |= ((u8) val);
135 133
136 data->last_updated = jiffies; 134 data->last_updated = jiffies;
137 data->valid = 1; 135 data->valid = 1;
@@ -189,6 +187,19 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
189 return sprintf(buf, "%u\n", (data->alarms >> index) & 0x1); 187 return sprintf(buf, "%u\n", (data->alarms >> index) & 0x1);
190} 188}
191 189
190static ssize_t show_fault(struct device *dev,
191 struct device_attribute *devattr, char *buf)
192{
193 int index = to_sensor_dev_attr(devattr)->index;
194 struct max1668_data *data = max1668_update_device(dev);
195
196 if (IS_ERR(data))
197 return PTR_ERR(data);
198
199 return sprintf(buf, "%u\n",
200 (data->alarms & (1 << 12)) && data->temp[index] == 127);
201}
202
192static ssize_t set_temp_max(struct device *dev, 203static ssize_t set_temp_max(struct device *dev,
193 struct device_attribute *devattr, 204 struct device_attribute *devattr,
194 const char *buf, size_t count) 205 const char *buf, size_t count)
@@ -276,6 +287,11 @@ static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 2);
276static SENSOR_DEVICE_ATTR(temp5_min_alarm, S_IRUGO, show_alarm, NULL, 1); 287static SENSOR_DEVICE_ATTR(temp5_min_alarm, S_IRUGO, show_alarm, NULL, 1);
277static SENSOR_DEVICE_ATTR(temp5_max_alarm, S_IRUGO, show_alarm, NULL, 0); 288static SENSOR_DEVICE_ATTR(temp5_max_alarm, S_IRUGO, show_alarm, NULL, 0);
278 289
290static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_fault, NULL, 1);
291static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_fault, NULL, 2);
292static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_fault, NULL, 3);
293static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_fault, NULL, 4);
294
279/* Attributes common to MAX1668, MAX1989 and MAX1805 */ 295/* Attributes common to MAX1668, MAX1989 and MAX1805 */
280static struct attribute *max1668_attribute_common[] = { 296static struct attribute *max1668_attribute_common[] = {
281 &sensor_dev_attr_temp1_max.dev_attr.attr, 297 &sensor_dev_attr_temp1_max.dev_attr.attr,
@@ -294,6 +310,9 @@ static struct attribute *max1668_attribute_common[] = {
294 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, 310 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
295 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, 311 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
296 &sensor_dev_attr_temp3_min_alarm.dev_attr.attr, 312 &sensor_dev_attr_temp3_min_alarm.dev_attr.attr,
313
314 &sensor_dev_attr_temp2_fault.dev_attr.attr,
315 &sensor_dev_attr_temp3_fault.dev_attr.attr,
297 NULL 316 NULL
298}; 317};
299 318
@@ -310,6 +329,9 @@ static struct attribute *max1668_attribute_unique[] = {
310 &sensor_dev_attr_temp4_min_alarm.dev_attr.attr, 329 &sensor_dev_attr_temp4_min_alarm.dev_attr.attr,
311 &sensor_dev_attr_temp5_max_alarm.dev_attr.attr, 330 &sensor_dev_attr_temp5_max_alarm.dev_attr.attr,
312 &sensor_dev_attr_temp5_min_alarm.dev_attr.attr, 331 &sensor_dev_attr_temp5_min_alarm.dev_attr.attr,
332
333 &sensor_dev_attr_temp4_fault.dev_attr.attr,
334 &sensor_dev_attr_temp5_fault.dev_attr.attr,
313 NULL 335 NULL
314}; 336};
315 337