Commit 5bfedac0 authored by Christian Hohnstaedt's avatar Christian Hohnstaedt Committed by Mark M. Hoffman

hwmon: Allow writing of negative trigger temperatures

- replace differing temperature variable types by long
- use strtol() instead of strtoul() for conversion
Signed-off-by: default avatarChristian Hohnstaedt <chohnstaedt@innominate.com>
Acked-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarMark M. Hoffman <mhoffman@lightlink.com>
parent dcf3b5fb
...@@ -172,7 +172,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, ...@@ -172,7 +172,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct ad7418_data *data = i2c_get_clientdata(client); struct ad7418_data *data = i2c_get_clientdata(client);
int temp = simple_strtol(buf, NULL, 10); long temp = simple_strtol(buf, NULL, 10);
mutex_lock(&data->lock); mutex_lock(&data->lock);
data->temp[attr->index] = LM75_TEMP_TO_REG(temp); data->temp[attr->index] = LM75_TEMP_TO_REG(temp);
......
...@@ -162,7 +162,7 @@ static ssize_t set_##value(struct device *dev, \ ...@@ -162,7 +162,7 @@ static ssize_t set_##value(struct device *dev, \
{ \ { \
struct i2c_client *client = to_i2c_client(dev); \ struct i2c_client *client = to_i2c_client(dev); \
struct adm1021_data *data = i2c_get_clientdata(client); \ struct adm1021_data *data = i2c_get_clientdata(client); \
int temp = simple_strtoul(buf, NULL, 10); \ long temp = simple_strtol(buf, NULL, 10); \
\ \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(temp); \ data->value = TEMP_TO_REG(temp); \
......
...@@ -143,7 +143,7 @@ static int FAN_FROM_REG(u8 val, int div) ...@@ -143,7 +143,7 @@ static int FAN_FROM_REG(u8 val, int div)
/* TEMP: 0.001C/bit (-128C to +127C) /* TEMP: 0.001C/bit (-128C to +127C)
REG: 1C/bit, two's complement */ REG: 1C/bit, two's complement */
static u8 TEMP_TO_REG(int temp) static u8 TEMP_TO_REG(long temp)
{ {
int ntemp = SENSORS_LIMIT(temp, ASB100_TEMP_MIN, ASB100_TEMP_MAX); int ntemp = SENSORS_LIMIT(temp, ASB100_TEMP_MIN, ASB100_TEMP_MAX);
ntemp += (ntemp<0 ? -500 : 500); ntemp += (ntemp<0 ? -500 : 500);
...@@ -448,7 +448,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \ ...@@ -448,7 +448,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
{ \ { \
struct i2c_client *client = to_i2c_client(dev); \ struct i2c_client *client = to_i2c_client(dev); \
struct asb100_data *data = i2c_get_clientdata(client); \ struct asb100_data *data = i2c_get_clientdata(client); \
unsigned long val = simple_strtoul(buf, NULL, 10); \ long val = simple_strtol(buf, NULL, 10); \
\ \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
switch (nr) { \ switch (nr) { \
......
...@@ -151,7 +151,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -151,7 +151,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct ds1621_data *data = ds1621_update_client(dev); struct ds1621_data *data = ds1621_update_client(dev);
u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); u16 val = LM75_TEMP_TO_REG(simple_strtol(buf, NULL, 10));
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp[attr->index] = val; data->temp[attr->index] = val;
......
...@@ -95,7 +95,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -95,7 +95,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct lm75_data *data = i2c_get_clientdata(client); struct lm75_data *data = i2c_get_clientdata(client);
int nr = attr->index; int nr = attr->index;
unsigned long temp = simple_strtoul(buf, NULL, 10); long temp = simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp[nr] = LM75_TEMP_TO_REG(temp); data->temp[nr] = LM75_TEMP_TO_REG(temp);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
/* TEMP: 0.001C/bit (-55C to +125C) /* TEMP: 0.001C/bit (-55C to +125C)
REG: (0.5C/bit, two's complement) << 7 */ REG: (0.5C/bit, two's complement) << 7 */
static inline u16 LM75_TEMP_TO_REG(int temp) static inline u16 LM75_TEMP_TO_REG(long temp)
{ {
int ntemp = SENSORS_LIMIT(temp, LM75_TEMP_MIN, LM75_TEMP_MAX); int ntemp = SENSORS_LIMIT(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
ntemp += (ntemp<0 ? -250 : 250); ntemp += (ntemp<0 ? -250 : 250);
......
...@@ -138,7 +138,7 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co ...@@ -138,7 +138,7 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
{ \ { \
struct i2c_client *client = to_i2c_client(dev); \ struct i2c_client *client = to_i2c_client(dev); \
struct lm77_data *data = i2c_get_clientdata(client); \ struct lm77_data *data = i2c_get_clientdata(client); \
long val = simple_strtoul(buf, NULL, 10); \ long val = simple_strtol(buf, NULL, 10); \
\ \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
data->value = val; \ data->value = val; \
......
...@@ -413,7 +413,7 @@ static int LM93_TEMP_FROM_REG(u8 reg) ...@@ -413,7 +413,7 @@ static int LM93_TEMP_FROM_REG(u8 reg)
/* TEMP: 1/1000 degrees C (-128C to +127C) /* TEMP: 1/1000 degrees C (-128C to +127C)
REG: 1C/bit, two's complement */ REG: 1C/bit, two's complement */
static u8 LM93_TEMP_TO_REG(int temp) static u8 LM93_TEMP_TO_REG(long temp)
{ {
int ntemp = SENSORS_LIMIT(temp, LM93_TEMP_MIN, LM93_TEMP_MAX); int ntemp = SENSORS_LIMIT(temp, LM93_TEMP_MIN, LM93_TEMP_MAX);
ntemp += (ntemp<0 ? -500 : 500); ntemp += (ntemp<0 ? -500 : 500);
...@@ -1268,7 +1268,7 @@ static ssize_t store_temp_min(struct device *dev, struct device_attribute *attr, ...@@ -1268,7 +1268,7 @@ static ssize_t store_temp_min(struct device *dev, struct device_attribute *attr,
int nr = (to_sensor_dev_attr(attr))->index; int nr = (to_sensor_dev_attr(attr))->index;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct lm93_data *data = i2c_get_clientdata(client); struct lm93_data *data = i2c_get_clientdata(client);
u32 val = simple_strtoul(buf, NULL, 10); long val = simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp_lim[nr].min = LM93_TEMP_TO_REG(val); data->temp_lim[nr].min = LM93_TEMP_TO_REG(val);
...@@ -1298,7 +1298,7 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute *attr, ...@@ -1298,7 +1298,7 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute *attr,
int nr = (to_sensor_dev_attr(attr))->index; int nr = (to_sensor_dev_attr(attr))->index;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct lm93_data *data = i2c_get_clientdata(client); struct lm93_data *data = i2c_get_clientdata(client);
u32 val = simple_strtoul(buf, NULL, 10); long val = simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp_lim[nr].max = LM93_TEMP_TO_REG(val); data->temp_lim[nr].max = LM93_TEMP_TO_REG(val);
...@@ -1329,7 +1329,7 @@ static ssize_t store_temp_auto_base(struct device *dev, ...@@ -1329,7 +1329,7 @@ static ssize_t store_temp_auto_base(struct device *dev,
int nr = (to_sensor_dev_attr(attr))->index; int nr = (to_sensor_dev_attr(attr))->index;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct lm93_data *data = i2c_get_clientdata(client); struct lm93_data *data = i2c_get_clientdata(client);
u32 val = simple_strtoul(buf, NULL, 10); long val = simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->block10.base[nr] = LM93_TEMP_TO_REG(val); data->block10.base[nr] = LM93_TEMP_TO_REG(val);
...@@ -1360,7 +1360,7 @@ static ssize_t store_temp_auto_boost(struct device *dev, ...@@ -1360,7 +1360,7 @@ static ssize_t store_temp_auto_boost(struct device *dev,
int nr = (to_sensor_dev_attr(attr))->index; int nr = (to_sensor_dev_attr(attr))->index;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct lm93_data *data = i2c_get_clientdata(client); struct lm93_data *data = i2c_get_clientdata(client);
u32 val = simple_strtoul(buf, NULL, 10); long val = simple_strtol(buf, NULL, 10);
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->boost[nr] = LM93_TEMP_TO_REG(val); data->boost[nr] = LM93_TEMP_TO_REG(val);
......
...@@ -223,7 +223,7 @@ temp1_from_reg(s8 reg) ...@@ -223,7 +223,7 @@ temp1_from_reg(s8 reg)
} }
static inline s8 static inline s8
temp1_to_reg(int temp, int min, int max) temp1_to_reg(long temp, int min, int max)
{ {
if (temp <= min) if (temp <= min)
return min / 1000; return min / 1000;
...@@ -805,7 +805,7 @@ store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ ...@@ -805,7 +805,7 @@ store_temp1_##reg(struct device *dev, struct device_attribute *attr, \
const char *buf, size_t count) \ const char *buf, size_t count) \
{ \ { \
struct w83627ehf_data *data = dev_get_drvdata(dev); \ struct w83627ehf_data *data = dev_get_drvdata(dev); \
u32 val = simple_strtoul(buf, NULL, 10); \ long val = simple_strtol(buf, NULL, 10); \
\ \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
data->temp1_##reg = temp1_to_reg(val, -128000, 127000); \ data->temp1_##reg = temp1_to_reg(val, -128000, 127000); \
...@@ -840,7 +840,7 @@ store_##reg(struct device *dev, struct device_attribute *attr, \ ...@@ -840,7 +840,7 @@ store_##reg(struct device *dev, struct device_attribute *attr, \
struct w83627ehf_data *data = dev_get_drvdata(dev); \ struct w83627ehf_data *data = dev_get_drvdata(dev); \
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; \
u32 val = simple_strtoul(buf, NULL, 10); \ long val = simple_strtol(buf, NULL, 10); \
\ \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
data->reg[nr] = LM75_TEMP_TO_REG(val); \ data->reg[nr] = LM75_TEMP_TO_REG(val); \
......
...@@ -263,7 +263,7 @@ static inline u8 FAN_TO_REG(long rpm, int div) ...@@ -263,7 +263,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
/* TEMP: 0.001C/bit (-128C to +127C) /* TEMP: 0.001C/bit (-128C to +127C)
REG: 1C/bit, two's complement */ REG: 1C/bit, two's complement */
static u8 TEMP_TO_REG(int temp) static u8 TEMP_TO_REG(long temp)
{ {
int ntemp = SENSORS_LIMIT(temp, TEMP_MIN, TEMP_MAX); int ntemp = SENSORS_LIMIT(temp, TEMP_MIN, TEMP_MAX);
ntemp += (ntemp<0 ? -500 : 500); ntemp += (ntemp<0 ? -500 : 500);
...@@ -642,9 +642,9 @@ static ssize_t \ ...@@ -642,9 +642,9 @@ static ssize_t \
store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
{ \ { \
struct w83627hf_data *data = dev_get_drvdata(dev); \ struct w83627hf_data *data = dev_get_drvdata(dev); \
u32 val; \ long val; \
\ \
val = simple_strtoul(buf, NULL, 10); \ val = simple_strtol(buf, NULL, 10); \
\ \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
\ \
......
...@@ -410,7 +410,7 @@ static ssize_t store_temp_##reg (struct device *dev, \ ...@@ -410,7 +410,7 @@ static ssize_t store_temp_##reg (struct device *dev, \
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); \ struct sensor_device_attribute *attr = to_sensor_dev_attr(da); \
struct w83781d_data *data = dev_get_drvdata(dev); \ struct w83781d_data *data = dev_get_drvdata(dev); \
int nr = attr->index; \ int nr = attr->index; \
s32 val; \ long val; \
\ \
val = simple_strtol(buf, NULL, 10); \ val = simple_strtol(buf, NULL, 10); \
\ \
......
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