Commit f5f64501 authored by Jean Delvare's avatar Jean Delvare

hwmon: (it87) Use strict_strtol instead of simple_strtol

For consistency and robustness, use strict_strtol instead of
simple_strtol.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 5f2dc798
...@@ -363,7 +363,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, ...@@ -363,7 +363,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); 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); mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val); data->in_min[nr] = IN_TO_REG(val);
...@@ -379,7 +382,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, ...@@ -379,7 +382,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); 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); mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val); data->in_max[nr] = IN_TO_REG(val);
...@@ -452,7 +458,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, ...@@ -452,7 +458,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); 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); mutex_lock(&data->update_lock);
data->temp_high[nr] = TEMP_TO_REG(val); data->temp_high[nr] = TEMP_TO_REG(val);
...@@ -467,7 +476,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, ...@@ -467,7 +476,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); 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); mutex_lock(&data->update_lock);
data->temp_low[nr] = TEMP_TO_REG(val); data->temp_low[nr] = TEMP_TO_REG(val);
...@@ -510,7 +522,10 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, ...@@ -510,7 +522,10 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); 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); mutex_lock(&data->update_lock);
...@@ -618,9 +633,12 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, ...@@ -618,9 +633,12 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); struct it87_data *data = dev_get_drvdata(dev);
int val = simple_strtol(buf, NULL, 10); long val;
u8 reg; u8 reg;
if (strict_strtol(buf, 10, &val) < 0)
return -EINVAL;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
reg = it87_read_value(data, IT87_REG_FAN_DIV); reg = it87_read_value(data, IT87_REG_FAN_DIV);
switch (nr) { switch (nr) {
...@@ -647,10 +665,13 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, ...@@ -647,10 +665,13 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); struct it87_data *data = dev_get_drvdata(dev);
unsigned long val = simple_strtoul(buf, NULL, 10); unsigned long val;
int min; int min;
u8 old; u8 old;
if (strict_strtoul(buf, 10, &val) < 0)
return -EINVAL;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
old = it87_read_value(data, IT87_REG_FAN_DIV); old = it87_read_value(data, IT87_REG_FAN_DIV);
...@@ -689,9 +710,9 @@ static ssize_t set_pwm_enable(struct device *dev, ...@@ -689,9 +710,9 @@ static ssize_t set_pwm_enable(struct device *dev,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); 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; return -EINVAL;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
...@@ -727,9 +748,9 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, ...@@ -727,9 +748,9 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); 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; return -EINVAL;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
...@@ -747,9 +768,12 @@ static ssize_t set_pwm_freq(struct device *dev, ...@@ -747,9 +768,12 @@ static ssize_t set_pwm_freq(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct it87_data *data = dev_get_drvdata(dev); struct it87_data *data = dev_get_drvdata(dev);
unsigned long val = simple_strtoul(buf, NULL, 10); unsigned long val;
int i; int i;
if (strict_strtoul(buf, 10, &val) < 0)
return -EINVAL;
/* Search for the nearest available frequency */ /* Search for the nearest available frequency */
for (i = 0; i < 7; i++) { for (i = 0; i < 7; i++) {
if (val > (pwm_freq[i] + pwm_freq[i+1]) / 2) if (val > (pwm_freq[i] + pwm_freq[i+1]) / 2)
...@@ -871,7 +895,10 @@ static ssize_t set_fan16_min(struct device *dev, struct device_attribute *attr, ...@@ -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); struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
int nr = sensor_attr->index; int nr = sensor_attr->index;
struct it87_data *data = dev_get_drvdata(dev); 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); mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN16_TO_REG(val); data->fan_min[nr] = FAN16_TO_REG(val);
...@@ -992,9 +1019,11 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, ...@@ -992,9 +1019,11 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct it87_data *data = dev_get_drvdata(dev); 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; data->vrm = val;
return count; return count;
......
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