hwmon: (lm95245) Fix hysteresis temperatures
Hysteresis temperatures are defined as absolute temperatures, not as delta value from the critical temperatures. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Jean Delvare <jdelvare@suse.de>
This commit is contained in:
parent
7981c5846a
commit
408c15eaca
@ -272,27 +272,38 @@ static ssize_t set_limit(struct device *dev, struct device_attribute *attr,
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t show_crit_hyst(struct device *dev, struct device_attribute *attr,
|
||||||
|
char *buf)
|
||||||
|
{
|
||||||
|
struct lm95245_data *data = lm95245_update_device(dev);
|
||||||
|
int index = to_sensor_dev_attr(attr)->index;
|
||||||
|
int hyst = data->regs[index] - data->regs[8];
|
||||||
|
|
||||||
|
return snprintf(buf, PAGE_SIZE - 1, "%d\n", hyst * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t set_crit_hyst(struct device *dev, struct device_attribute *attr,
|
static ssize_t set_crit_hyst(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = to_i2c_client(dev);
|
struct i2c_client *client = to_i2c_client(dev);
|
||||||
struct lm95245_data *data = i2c_get_clientdata(client);
|
struct lm95245_data *data = i2c_get_clientdata(client);
|
||||||
|
int index = to_sensor_dev_attr(attr)->index;
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
int hyst, limit;
|
||||||
|
|
||||||
if (kstrtoul(buf, 10, &val) < 0)
|
if (kstrtoul(buf, 10, &val) < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
val /= 1000;
|
|
||||||
|
|
||||||
val = clamp_val(val, 0, 31);
|
|
||||||
|
|
||||||
mutex_lock(&data->update_lock);
|
mutex_lock(&data->update_lock);
|
||||||
|
|
||||||
data->valid = 0;
|
limit = i2c_smbus_read_byte_data(client, lm95245_reg_address[index]);
|
||||||
|
hyst = limit - val / 1000;
|
||||||
|
hyst = clamp_val(hyst, 0, 31);
|
||||||
|
data->regs[8] = hyst;
|
||||||
|
|
||||||
/* shared crit hysteresis */
|
/* shared crit hysteresis */
|
||||||
i2c_smbus_write_byte_data(client, LM95245_REG_RW_COMMON_HYSTERESIS,
|
i2c_smbus_write_byte_data(client, LM95245_REG_RW_COMMON_HYSTERESIS,
|
||||||
val);
|
hyst);
|
||||||
|
|
||||||
mutex_unlock(&data->update_lock);
|
mutex_unlock(&data->update_lock);
|
||||||
|
|
||||||
@ -378,16 +389,16 @@ static ssize_t set_interval(struct device *dev, struct device_attribute *attr,
|
|||||||
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_input, NULL, 0);
|
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_input, NULL, 0);
|
||||||
static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_limit,
|
static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_limit,
|
||||||
set_limit, 6);
|
set_limit, 6);
|
||||||
static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_limit,
|
static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_crit_hyst,
|
||||||
set_crit_hyst, 8);
|
set_crit_hyst, 6);
|
||||||
static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL,
|
static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL,
|
||||||
STATUS1_LOC);
|
STATUS1_LOC);
|
||||||
|
|
||||||
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, 2);
|
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, 2);
|
||||||
static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_limit,
|
static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_limit,
|
||||||
set_limit, 7);
|
set_limit, 7);
|
||||||
static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_limit,
|
static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_crit_hyst,
|
||||||
set_crit_hyst, 8);
|
set_crit_hyst, 7);
|
||||||
static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL,
|
static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL,
|
||||||
STATUS1_RTCRIT);
|
STATUS1_RTCRIT);
|
||||||
static SENSOR_DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type,
|
static SENSOR_DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type,
|
||||||
|
Loading…
Reference in New Issue
Block a user