Commit d7ac54b8 authored by Michael Abbott's avatar Michael Abbott Committed by James Toy

The ADM1023 temperature sensor supports higher resolution for its external

sensor (sensitivity of 1/8 deg C).  This patch makes this higher
resolution available through the appropriate temperature sysfs nodes.

Curiously, this functionality was available in the 2.4 kernel driver (but
formatted in a less helpful manner).

Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarMichael Abbott <michael.abbott@diamond.ac.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 0696b286
...@@ -85,14 +85,11 @@ struct adm1021_data { ...@@ -85,14 +85,11 @@ struct adm1021_data {
char valid; /* !=0 if following fields are valid */ char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */ unsigned long last_updated; /* In jiffies */
s8 temp_max[2]; /* Register values */ int temp_max[2]; /* Register values */
s8 temp_min[2]; int temp_min[2];
s8 temp[2]; int temp[2];
u8 alarms; u8 alarms;
/* Special values for ADM1023 only */ /* Special values for ADM1023 only */
u8 remote_temp_prec;
u8 remote_temp_os_prec;
u8 remote_temp_hyst_prec;
u8 remote_temp_offset; u8 remote_temp_offset;
u8 remote_temp_offset_prec; u8 remote_temp_offset_prec;
}; };
...@@ -141,7 +138,7 @@ static ssize_t show_temp(struct device *dev, ...@@ -141,7 +138,7 @@ static ssize_t show_temp(struct device *dev,
int index = to_sensor_dev_attr(devattr)->index; int index = to_sensor_dev_attr(devattr)->index;
struct adm1021_data *data = adm1021_update_device(dev); struct adm1021_data *data = adm1021_update_device(dev);
return sprintf(buf, "%d\n", 1000 * data->temp[index]); return sprintf(buf, "%d\n", data->temp[index]);
} }
static ssize_t show_temp_max(struct device *dev, static ssize_t show_temp_max(struct device *dev,
...@@ -150,7 +147,7 @@ static ssize_t show_temp_max(struct device *dev, ...@@ -150,7 +147,7 @@ static ssize_t show_temp_max(struct device *dev,
int index = to_sensor_dev_attr(devattr)->index; int index = to_sensor_dev_attr(devattr)->index;
struct adm1021_data *data = adm1021_update_device(dev); struct adm1021_data *data = adm1021_update_device(dev);
return sprintf(buf, "%d\n", 1000 * data->temp_max[index]); return sprintf(buf, "%d\n", data->temp_max[index]);
} }
static ssize_t show_temp_min(struct device *dev, static ssize_t show_temp_min(struct device *dev,
...@@ -159,7 +156,7 @@ static ssize_t show_temp_min(struct device *dev, ...@@ -159,7 +156,7 @@ static ssize_t show_temp_min(struct device *dev,
int index = to_sensor_dev_attr(devattr)->index; int index = to_sensor_dev_attr(devattr)->index;
struct adm1021_data *data = adm1021_update_device(dev); struct adm1021_data *data = adm1021_update_device(dev);
return sprintf(buf, "%d\n", 1000 * data->temp_min[index]); return sprintf(buf, "%d\n", data->temp_min[index]);
} }
static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
...@@ -412,25 +409,27 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) ...@@ -412,25 +409,27 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
dev_dbg(&client->dev, "Starting adm1021 update\n"); dev_dbg(&client->dev, "Starting adm1021 update\n");
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
data->temp[i] = i2c_smbus_read_byte_data(client, data->temp[i] = 1000 *
ADM1021_REG_TEMP(i)); (s8) i2c_smbus_read_byte_data(
data->temp_max[i] = i2c_smbus_read_byte_data(client, client, ADM1021_REG_TEMP(i));
ADM1021_REG_TOS_R(i)); data->temp_max[i] = 1000 *
data->temp_min[i] = i2c_smbus_read_byte_data(client, (s8) i2c_smbus_read_byte_data(
ADM1021_REG_THYST_R(i)); client, ADM1021_REG_TOS_R(i));
data->temp_min[i] = 1000 *
(s8) i2c_smbus_read_byte_data(
client, ADM1021_REG_THYST_R(i));
} }
data->alarms = i2c_smbus_read_byte_data(client, data->alarms = i2c_smbus_read_byte_data(client,
ADM1021_REG_STATUS) & 0x7c; ADM1021_REG_STATUS) & 0x7c;
if (data->type == adm1023) { if (data->type == adm1023) {
data->remote_temp_prec = /* The ADM1023 provides 3 extra bits of precision for
i2c_smbus_read_byte_data(client, * the remote sensor in extra registers. */
ADM1023_REG_REM_TEMP_PREC); data->temp[1] += 125 * (i2c_smbus_read_byte_data(
data->remote_temp_os_prec = client, ADM1023_REG_REM_TEMP_PREC) >> 5);
i2c_smbus_read_byte_data(client, data->temp_max[1] += 125 * (i2c_smbus_read_byte_data(
ADM1023_REG_REM_TOS_PREC); client, ADM1023_REG_REM_TOS_PREC) >> 5);
data->remote_temp_hyst_prec = data->temp_min[1] += 125 * (i2c_smbus_read_byte_data(
i2c_smbus_read_byte_data(client, client, ADM1023_REG_REM_THYST_PREC) >> 5);
ADM1023_REG_REM_THYST_PREC);
data->remote_temp_offset = data->remote_temp_offset =
i2c_smbus_read_byte_data(client, i2c_smbus_read_byte_data(client,
ADM1023_REG_REM_OFFSET); ADM1023_REG_REM_OFFSET);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment