Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186410
b: refs/heads/master
c: cccfc9c
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare committed Mar 5, 2010
1 parent 19f18c4 commit 68302a5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4f3f51bc21d434f8d91a79438a1957ec0baa9e30
refs/heads/master: cccfc9c4bb3c7888f8249b36e08d6e115238c613
4 changes: 4 additions & 0 deletions trunk/Documentation/hwmon/it87
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ between trip point N and trip point N+1 then the PWM output value is
the one of trip point N. The automatic control mode is less flexible
than the manual control mode, but it reacts faster, is more robust and
doesn't use CPU cycles.

Trip points must be set properly before switching to automatic fan speed
control mode. The driver will perform basic integrity checks before
actually switching to automatic control mode.
32 changes: 32 additions & 0 deletions trunk/drivers/hwmon/it87.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,32 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
mutex_unlock(&data->update_lock);
return count;
}

/* Returns 0 if OK, -EINVAL otherwise */
static int check_trip_points(struct device *dev, int nr)
{
const struct it87_data *data = dev_get_drvdata(dev);
int i, err = 0;

if (has_old_autopwm(data)) {
for (i = 0; i < 3; i++) {
if (data->auto_temp[nr][i] > data->auto_temp[nr][i + 1])
err = -EINVAL;
}
for (i = 0; i < 2; i++) {
if (data->auto_pwm[nr][i] > data->auto_pwm[nr][i + 1])
err = -EINVAL;
}
}

if (err) {
dev_err(dev, "Inconsistent trip points, not switching to "
"automatic mode\n");
dev_err(dev, "Adjust the trip points and try again\n");
}
return err;
}

static ssize_t set_pwm_enable(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
Expand All @@ -731,6 +757,12 @@ static ssize_t set_pwm_enable(struct device *dev,
if (strict_strtol(buf, 10, &val) < 0 || val < 0 || val > 2)
return -EINVAL;

/* Check trip points before switching to automatic mode */
if (val == 2) {
if (check_trip_points(dev, nr) < 0)
return -EINVAL;
}

mutex_lock(&data->update_lock);

if (val == 0) {
Expand Down

0 comments on commit 68302a5

Please sign in to comment.