Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186406
b: refs/heads/master
c: f5f6450
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare committed Mar 5, 2010
1 parent b86136d commit 89091ed
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5f2dc798cadd144659cc9f5b6fc2a0a12c6dbdb0
refs/heads/master: f5f64501e430784251b23625850ce6d690800acf
59 changes: 44 additions & 15 deletions trunk/drivers/hwmon/it87.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long val;

if (strict_strtoul(buf, 10, &val) < 0)
return -EINVAL;

mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val);
Expand All @@ -379,7 +382,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long val;

if (strict_strtoul(buf, 10, &val) < 0)
return -EINVAL;

mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val);
Expand Down Expand Up @@ -452,7 +458,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
int val = simple_strtol(buf, NULL, 10);
long val;

if (strict_strtol(buf, 10, &val) < 0)
return -EINVAL;

mutex_lock(&data->update_lock);
data->temp_high[nr] = TEMP_TO_REG(val);
Expand All @@ -467,7 +476,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
int val = simple_strtol(buf, NULL, 10);
long val;

if (strict_strtol(buf, 10, &val) < 0)
return -EINVAL;

mutex_lock(&data->update_lock);
data->temp_low[nr] = TEMP_TO_REG(val);
Expand Down Expand Up @@ -510,7 +522,10 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
int val = simple_strtol(buf, NULL, 10);
long val;

if (strict_strtol(buf, 10, &val) < 0)
return -EINVAL;

mutex_lock(&data->update_lock);

Expand Down Expand Up @@ -618,9 +633,12 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
int val = simple_strtol(buf, NULL, 10);
long val;
u8 reg;

if (strict_strtol(buf, 10, &val) < 0)
return -EINVAL;

mutex_lock(&data->update_lock);
reg = it87_read_value(data, IT87_REG_FAN_DIV);
switch (nr) {
Expand All @@ -647,10 +665,13 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long val;
int min;
u8 old;

if (strict_strtoul(buf, 10, &val) < 0)
return -EINVAL;

mutex_lock(&data->update_lock);
old = it87_read_value(data, IT87_REG_FAN_DIV);

Expand Down Expand Up @@ -689,9 +710,9 @@ static ssize_t set_pwm_enable(struct device *dev,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
int val = simple_strtol(buf, NULL, 10);
long val;

if (val < 0 || val > 2)
if (strict_strtol(buf, 10, &val) < 0 || val < 0 || val > 2)
return -EINVAL;

mutex_lock(&data->update_lock);
Expand Down Expand Up @@ -727,9 +748,9 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index;

struct it87_data *data = dev_get_drvdata(dev);
int val = simple_strtol(buf, NULL, 10);
long val;

if (val < 0 || val > 255)
if (strict_strtol(buf, 10, &val) < 0 || val < 0 || val > 255)
return -EINVAL;

mutex_lock(&data->update_lock);
Expand All @@ -747,9 +768,12 @@ static ssize_t set_pwm_freq(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct it87_data *data = dev_get_drvdata(dev);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long val;
int i;

if (strict_strtoul(buf, 10, &val) < 0)
return -EINVAL;

/* Search for the nearest available frequency */
for (i = 0; i < 7; i++) {
if (val > (pwm_freq[i] + pwm_freq[i+1]) / 2)
Expand Down Expand Up @@ -871,7 +895,10 @@ static ssize_t set_fan16_min(struct device *dev, struct device_attribute *attr,
struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev);
int val = simple_strtol(buf, NULL, 10);
long val;

if (strict_strtol(buf, 10, &val) < 0)
return -EINVAL;

mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN16_TO_REG(val);
Expand Down Expand Up @@ -992,9 +1019,11 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct it87_data *data = dev_get_drvdata(dev);
u32 val;
unsigned long val;

if (strict_strtoul(buf, 10, &val) < 0)
return -EINVAL;

val = simple_strtoul(buf, NULL, 10);
data->vrm = val;

return count;
Expand Down

0 comments on commit 89091ed

Please sign in to comment.