summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2011-06-09 18:05:16 -0700
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-07-28 00:17:33 -0700
commitdabaa0d2b4085a2037d80a40b86ba215f00b601e (patch)
tree1be3184d5eff3d571a66db264ed3e68f989c85e7 /drivers/hwmon
parent731b4cace10f105a81d622b70f9a35f577612d63 (diff)
downloadlinux-dabaa0d2b4085a2037d80a40b86ba215f00b601e.tar.gz
linux-dabaa0d2b4085a2037d80a40b86ba215f00b601e.tar.bz2
linux-dabaa0d2b4085a2037d80a40b86ba215f00b601e.zip
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)
ret = ERR_PTR(val);
goto abort;
}
- data->alarms &= 0x00ff;
- data->alarms |= ((u8) (val & 0x60)) << 8;
+ data->alarms = val << 8;
val = i2c_smbus_read_byte_data(client, MAX1668_REG_STAT2);
if (unlikely(val < 0)) {
ret = ERR_PTR(val);
goto abort;
}
- data->alarms &= 0xff00;
- data->alarms |= ((u8) val);
+ data->alarms |= val;
data->last_updated = jiffies;
data->valid = 1;
@@ -189,6 +187,19 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
return sprintf(buf, "%u\n", (data->alarms >> index) & 0x1);
}
+static ssize_t show_fault(struct device *dev,
+ struct device_attribute *devattr, char *buf)
+{
+ int index = to_sensor_dev_attr(devattr)->index;
+ struct max1668_data *data = max1668_update_device(dev);
+
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+
+ return sprintf(buf, "%u\n",
+ (data->alarms & (1 << 12)) && data->temp[index] == 127);
+}
+
static ssize_t set_temp_max(struct device *dev,
struct device_attribute *devattr,
const char *buf, size_t count)
@@ -276,6 +287,11 @@ static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 2);
static SENSOR_DEVICE_ATTR(temp5_min_alarm, S_IRUGO, show_alarm, NULL, 1);
static SENSOR_DEVICE_ATTR(temp5_max_alarm, S_IRUGO, show_alarm, NULL, 0);
+static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_fault, NULL, 1);
+static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_fault, NULL, 2);
+static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_fault, NULL, 3);
+static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_fault, NULL, 4);
+
/* Attributes common to MAX1668, MAX1989 and MAX1805 */
static struct attribute *max1668_attribute_common[] = {
&sensor_dev_attr_temp1_max.dev_attr.attr,
@@ -294,6 +310,9 @@ static struct attribute *max1668_attribute_common[] = {
&sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
&sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
&sensor_dev_attr_temp3_min_alarm.dev_attr.attr,
+
+ &sensor_dev_attr_temp2_fault.dev_attr.attr,
+ &sensor_dev_attr_temp3_fault.dev_attr.attr,
NULL
};
@@ -310,6 +329,9 @@ static struct attribute *max1668_attribute_unique[] = {
&sensor_dev_attr_temp4_min_alarm.dev_attr.attr,
&sensor_dev_attr_temp5_max_alarm.dev_attr.attr,
&sensor_dev_attr_temp5_min_alarm.dev_attr.attr,
+
+ &sensor_dev_attr_temp4_fault.dev_attr.attr,
+ &sensor_dev_attr_temp5_fault.dev_attr.attr,
NULL
};